2

this is my first time ever trying to use complex templates that other people have made and this is giving me a problem.

So what I'm trying to do is to add a timeline (https://tex.stackexchange.com/a/197140) to a poster template (http://www.nathanieljohnston.com/2009/08/latex-poster-template/).

Unfortunately, what I get it is something like this:

enter image description here

This is the latex code:

\documentclass[final]{beamer}
\usepackage[scale=1.24]{beamerposter}
\usepackage{graphicx}           % allows us to import images
\usepackage{tikz}

%----------------------------------------------------------- % Define the column width and poster size % To set effective sepwid, onecolwid and twocolwid values, first choose how many columns you want and how much separation you want between columns % The separation I chose is 0.024 and I want 4 columns % Then set onecolwid to be (1-(4+1)0.024)/4 = 0.22 % Set twocolwid to be 2onecolwid + sepwid = 0.464 %-----------------------------------------------------------

\newlength{\sepwid} \newlength{\onecolwid} \newlength{\twocolwid} \newlength{\threecolwid} \setlength{\paperwidth}{48in} \setlength{\paperheight}{36in} \setlength{\sepwid}{0.024\paperwidth} \setlength{\onecolwid}{0.22\paperwidth} \setlength{\twocolwid}{0.464\paperwidth} \setlength{\threecolwid}{0.708\paperwidth} \setlength{\topmargin}{-0.5in} \usepackage{exscale}

%============================================================================== % build the poster timeline %==============================================================================

\makeatletter \newenvironment{timeline}[6]{

\newcommand{\startyear}{#1}
\newcommand{\tlendyear}{#2}

\newcommand{\yearcolumnwidth}{#3}
\newcommand{\rulecolumnwidth}{#4}
\newcommand{\entrycolumnwidth}{#5}
\newcommand{\timelineheight}{#6}

\newcommand{\templength}{}

\newcommand{\entrycounter}{0}

% https://tex.stackexchange.com/questions/85528/checking-whether-or-not-a-node-has-been-previously-defined
% https://tex.stackexchange.com/questions/37709/how-can-i-know-if-a-node-is-already-defined
\long\def\ifnodedefined##1##2##3{%
    \@ifundefined{pgf@sh@ns@##1}{##3}{##2}%
}

\newcommand{\ifnodeundefined}[2]{%
    \ifnodedefined{##1}{}{##2}
}

\newcommand{\drawtimeline}{%
    \draw[timelinerule] (\yearcolumnwidth+5pt, 0pt) -- (\yearcolumnwidth+5pt, -\timelineheight);
    \draw (\yearcolumnwidth+0pt, -10pt) -- (\yearcolumnwidth+10pt, -10pt);
    \draw (\yearcolumnwidth+0pt, -\timelineheight+15pt) -- (\yearcolumnwidth+10pt, -\timelineheight+15pt);

    \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\startyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
    \node[year] (year-\startyear) at (\yearcolumnwidth, \templength) {\startyear};

    \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\tlendyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
    \node[year] (year-\tlendyear) at (\yearcolumnwidth, \templength) {\tlendyear};
}

\newcommand{\entry}[2]{%
    % #1 is the year
    % #2 is the entry text

    \pgfmathtruncatemacro{\lastentrycount}{\entrycounter}
    \pgfmathtruncatemacro{\entrycounter}{\entrycounter + 1}

    \ifdim \lastentrycount pt > 0 pt%
        \node[entry] (entry-\entrycounter) [below of=entry-\lastentrycount] {##2};
    \else%
        \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\startyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
        \node[entry] (entry-\entrycounter) at (\yearcolumnwidth+\rulecolumnwidth+10pt, \templength) {##2};
    \fi

    \ifnodeundefined{year-##1}{%
        \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(##1, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
        \draw (\yearcolumnwidth+2.5pt, \templength) -- (\yearcolumnwidth+7.5pt, \templength);
        \node[year] (year-##1) at (\yearcolumnwidth, \templength) {##1};
    }

    \draw ($(year-##1.east)+(2.5pt, 0pt)$) -- ($(year-##1.east)+(7.5pt, 0pt)$) -- ($(entry-\entrycounter.west)-(5pt,0)$) -- (entry-\entrycounter.west);
}

\newcommand{\plainentry}[2]{% plainentry won't print date in the timeline
    % #1 is the year
    % #2 is the entry text

    \pgfmathtruncatemacro{\lastentrycount}{\entrycounter}
    \pgfmathtruncatemacro{\entrycounter}{\entrycounter + 1}

    \ifdim \lastentrycount pt > 0 pt%
        \node[entry] (entry-\entrycounter) [below of=entry-\lastentrycount] {##2};
    \else%
        \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\startyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
        \node[entry] (entry-\entrycounter) at (\yearcolumnwidth+\rulecolumnwidth+10pt, \templength) {##2};
    \fi

    \ifnodeundefined{invisible-year-##1}{%
        \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(##1, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
        \draw (\yearcolumnwidth+2.5pt, \templength) -- (\yearcolumnwidth+7.5pt, \templength);
        \node[year] (invisible-year-##1) at (\yearcolumnwidth, \templength) {};
    }

    \draw ($(invisible-year-##1.east)+(2.5pt, 0pt)$) -- ($(invisible-year-##1.east)+(7.5pt, 0pt)$) -- ($(entry-\entrycounter.west)-(5pt,0)$) -- (entry-\entrycounter.west);
}

\begin{tikzpicture}
    \tikzstyle{entry} = [%
        align=left,%
        text width=\entrycolumnwidth,%
        node distance=10mm,%
        anchor=west]
    \tikzstyle{year} = [anchor=east]
    \tikzstyle{timelinerule} = [%
        draw,%
        decoration={markings, mark=at position 1 with {\arrow[scale=1.5]{latex'}}},%
        postaction={decorate},%
        shorten >=0.4pt]

    \drawtimeline

} { \end{tikzpicture} \let\startyear@undefined \let\tlendyear@undefined \let\yearcolumnwidth@undefined \let\rulecolumnwidth@undefined \let\entrycolumnwidth@undefined \let\timelineheight@undefined \let\entrycounter@undefined \let\ifnodedefined@undefined \let\ifnodeundefined@undefined \let\drawtimeline@undefined \let\entry@undefined } \makeatother

%----------------------------------------------------------- % Start the poster itself %-----------------------------------------------------------

\begin{document} \begin{frame}[t] \begin{columns}[t] % the [t] option aligns the column's content at the top \begin{column}{\sepwid}\end{column} % empty spacer column \begin{column}{\twocolwid} \begin{block}{Timeline} \begin{timeline}{1900}{1990}{2cm}{2.5cm}{5cm}{12cm} \entry{1903}{Wilbur and Orville Wright fly the first powered airplane} \entry{1914}{Assassination of Franz Ferdinand} \plainentry{1917}{The October Revolution} \entry{1928}{Discovery of Penicillin} \plainentry{1929}{Stock Market Crash of 1929} \entry{1941}{Attack on Pearl Harbor} \plainentry{1944}{D-Day} \entry{1945}{The Bombing of Hiroshima} \plainentry{1947}{Creation of Israel as a Jewish State} \entry{1963}{US president John F. Kennedy assassinated in Dallas} \entry{1969}{The Moon Landing} \plainentry{1989}{Fall of the Berlin Wall} \end{timeline} \end{block} \end{column} \begin{column}{\sepwid}\end{column} % empty spacer column \begin{column}{\twocolwid}\end{column} % create a two-column-wide column and then \end{columns} \end{frame} \end{document}

Why does the line all start from the same initial point? Does it have to do with the document size difference?

I would really appreciate it if you could help. Thanks a lot!

Edited: Added \usetikzlibrary{arrows, calc, decorations.markings, positioning, backgrounds} and the initial points for each year is correct but the content attached to years are overlapping each other

enter image description here

1 Answers1

3

beamerposter scales up the default font size, which makes the hardcoded absolute lengths in timeline env inappropriate.

The following changes seem to work:

@@ -2,6 +2,7 @@
 \usepackage[scale=1.24]{beamerposter}
 \usepackage{graphicx}           % allows us to import images
 \usepackage{tikz}
+\usetikzlibrary{arrows, calc, decorations.markings, positioning, backgrounds}

%----------------------------------------------------------- % Define the column width and poster size @@ -114,8 +115,8 @@ \begin{tikzpicture} \tikzstyle{entry} = [% align=left,%

  •        text width=\entrycolumnwidth,%
    
  •        node distance=10mm,%
    
  •        text width=2\entrycolumnwidth,%
    
  •        node distance=2*10mm,%
           anchor=west]
       \tikzstyle{year} = [anchor=east]
       \tikzstyle{timelinerule} = [%
    

@@ -152,7 +153,7 @@ \begin{column}{\sepwid}\end{column} % empty spacer column \begin{column}{\twocolwid} \begin{block}{Timeline}

  •      \begin{timeline}{1900}{1990}{2cm}{2.5cm}{5cm}{12cm}
    
  •      \begin{timeline}{1900}{1990}{2cm}{2.5cm}{5cm}{24cm}
           \entry{1903}{Wilbur and Orville Wright fly the first powered airplane}
           \entry{1914}{Assassination of Franz Ferdinand}
           \plainentry{1917}{The October Revolution}
    
    

Full example

\documentclass[final]{beamer}
\usepackage[scale=1.24]{beamerposter}
\usepackage{graphicx}           % allows us to import images
\usepackage{tikz}
\usetikzlibrary{arrows, calc, decorations.markings, positioning, backgrounds}

%----------------------------------------------------------- % Define the column width and poster size % To set effective sepwid, onecolwid and twocolwid values, first choose how many columns you want and how much separation you want between columns % The separation I chose is 0.024 and I want 4 columns % Then set onecolwid to be (1-(4+1)0.024)/4 = 0.22 % Set twocolwid to be 2onecolwid + sepwid = 0.464 %-----------------------------------------------------------

\newlength{\sepwid} \newlength{\onecolwid} \newlength{\twocolwid} \newlength{\threecolwid} \setlength{\paperwidth}{48in} \setlength{\paperheight}{36in} \setlength{\sepwid}{0.024\paperwidth} \setlength{\onecolwid}{0.22\paperwidth} \setlength{\twocolwid}{0.464\paperwidth} \setlength{\threecolwid}{0.708\paperwidth} \setlength{\topmargin}{-0.5in} \usepackage{exscale}

%============================================================================== % build the poster timeline %==============================================================================

\makeatletter \newenvironment{timeline}[6]{

\newcommand{\startyear}{#1}
\newcommand{\tlendyear}{#2}

\newcommand{\yearcolumnwidth}{#3}
\newcommand{\rulecolumnwidth}{#4}
\newcommand{\entrycolumnwidth}{#5}
\newcommand{\timelineheight}{#6}

\newcommand{\templength}{}

\newcommand{\entrycounter}{0}

% https://tex.stackexchange.com/questions/85528/checking-whether-or-not-a-node-has-been-previously-defined
% https://tex.stackexchange.com/questions/37709/how-can-i-know-if-a-node-is-already-defined
\long\def\ifnodedefined##1##2##3{%
    \@ifundefined{pgf@sh@ns@##1}{##3}{##2}%
}

\newcommand{\ifnodeundefined}[2]{%
    \ifnodedefined{##1}{}{##2}
}

\newcommand{\drawtimeline}{%
    \draw[timelinerule] (\yearcolumnwidth+5pt, 0pt) -- (\yearcolumnwidth+5pt, -\timelineheight);
    \draw (\yearcolumnwidth+0pt, -10pt) -- (\yearcolumnwidth+10pt, -10pt);
    \draw (\yearcolumnwidth+0pt, -\timelineheight+15pt) -- (\yearcolumnwidth+10pt, -\timelineheight+15pt);

    \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\startyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
    \node[year] (year-\startyear) at (\yearcolumnwidth, \templength) {\startyear};

    \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\tlendyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
    \node[year] (year-\tlendyear) at (\yearcolumnwidth, \templength) {\tlendyear};
}

\newcommand{\entry}[2]{%
    % #1 is the year
    % #2 is the entry text

    \pgfmathtruncatemacro{\lastentrycount}{\entrycounter}
    \pgfmathtruncatemacro{\entrycounter}{\entrycounter + 1}

    \ifdim \lastentrycount pt > 0 pt%
        \node[entry] (entry-\entrycounter) [below of=entry-\lastentrycount] {##2};
    \else%
        \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\startyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
        \node[entry] (entry-\entrycounter) at (\yearcolumnwidth+\rulecolumnwidth+10pt, \templength) {##2};
    \fi

    \ifnodeundefined{year-##1}{%
        \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(##1, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
        \draw (\yearcolumnwidth+2.5pt, \templength) -- (\yearcolumnwidth+7.5pt, \templength);
        \node[year] (year-##1) at (\yearcolumnwidth, \templength) {##1};
    }

    \draw ($(year-##1.east)+(2.5pt, 0pt)$) -- ($(year-##1.east)+(7.5pt, 0pt)$) -- ($(entry-\entrycounter.west)-(5pt,0)$) -- (entry-\entrycounter.west);
}

\newcommand{\plainentry}[2]{% plainentry won't print date in the timeline
    % #1 is the year
    % #2 is the entry text

    \pgfmathtruncatemacro{\lastentrycount}{\entrycounter}
    \pgfmathtruncatemacro{\entrycounter}{\entrycounter + 1}

    \ifdim \lastentrycount pt > 0 pt%
        \node[entry] (entry-\entrycounter) [below of=entry-\lastentrycount] {##2};
    \else%
        \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\startyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
        \node[entry] (entry-\entrycounter) at (\yearcolumnwidth+\rulecolumnwidth+10pt, \templength) {##2};
    \fi

    \ifnodeundefined{invisible-year-##1}{%
        \pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(##1, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
        \draw (\yearcolumnwidth+2.5pt, \templength) -- (\yearcolumnwidth+7.5pt, \templength);
        \node[year] (invisible-year-##1) at (\yearcolumnwidth, \templength) {};
    }

    \draw ($(invisible-year-##1.east)+(2.5pt, 0pt)$) -- ($(invisible-year-##1.east)+(7.5pt, 0pt)$) -- ($(entry-\entrycounter.west)-(5pt,0)$) -- (entry-\entrycounter.west);
}

\begin{tikzpicture}
    \tikzstyle{entry} = [%
        align=left,%
        text width=2\entrycolumnwidth,%
        node distance=2*10mm,%
        anchor=west]
    \tikzstyle{year} = [anchor=east]
    \tikzstyle{timelinerule} = [%
        draw,%
        decoration={markings, mark=at position 1 with {\arrow[scale=1.5]{latex'}}},%
        postaction={decorate},%
        shorten >=0.4pt]

    \drawtimeline

} { \end{tikzpicture} \let\startyear@undefined \let\tlendyear@undefined \let\yearcolumnwidth@undefined \let\rulecolumnwidth@undefined \let\entrycolumnwidth@undefined \let\timelineheight@undefined \let\entrycounter@undefined \let\ifnodedefined@undefined \let\ifnodeundefined@undefined \let\drawtimeline@undefined \let\entry@undefined } \makeatother

%----------------------------------------------------------- % Start the poster itself %-----------------------------------------------------------

\begin{document} \begin{frame}[t] \begin{columns}[t] % the [t] option aligns the column's content at the top \begin{column}{\sepwid}\end{column} % empty spacer column \begin{column}{\twocolwid} \begin{block}{Timeline} \begin{timeline}{1900}{1990}{2cm}{2.5cm}{5cm}{24cm} \entry{1903}{Wilbur and Orville Wright fly the first powered airplane} \entry{1914}{Assassination of Franz Ferdinand} \plainentry{1917}{The October Revolution} \entry{1928}{Discovery of Penicillin} \plainentry{1929}{Stock Market Crash of 1929} \entry{1941}{Attack on Pearl Harbor} \plainentry{1944}{D-Day} \entry{1945}{The Bombing of Hiroshima} \plainentry{1947}{Creation of Israel as a Jewish State} \entry{1963}{US president John F. Kennedy assassinated in Dallas} \entry{1969}{The Moon Landing} \plainentry{1989}{Fall of the Berlin Wall} \end{timeline} \end{block} \end{column} \begin{column}{\sepwid}\end{column} % empty spacer column \begin{column}{\twocolwid}\end{column} % create a two-column-wide column and then \end{columns} \end{frame} \end{document}

enter image description here

muzimuzhi Z
  • 26,474