Controlling the highlight of dates and separation in a vertical timeline

beamertikz-pgf

I would like to use the solution of Timeline shared in several Beamer frames to
make a vertical timeline, that is, with the arrow pointing to the bottom of the slide.

\documentclass[t]{beamer}
%----------- width and color of progressbar
\usetheme[progressbar=frametitle,
% outer/progressbar=foot
]{metropolis}
\makeatletter
\setlength{\metropolis@titleseparator@linewidth}{2pt}
\setlength{\metropolis@progressonsectionpage@linewidth}{2pt}
\setlength{\metropolis@progressinheadfoot@linewidth}{2pt}
\makeatother
%------------
\setbeamertemplate{frame numbering}[fraction]
% \setbeamertemplate{navigation symbols}{}
% \useoutertheme{metropolis}
% \useinnertheme{metropolis}
\usefonttheme{metropolis}
\usetikzlibrary{overlay-beamer-styles}
\setbeamercovered{transparent=7}
\tikzset{
    highlight on/.style={alt={#1{fill=red!80!black,color=red!80!black}{fill=gray!30!white,color=gray!30!white}}},
}
\begin{document}

\begin{frame}[t]{Timeline}
    

    \frametitle{Timeline}
    \begin{tikzpicture}[xscale=0.5]
    \draw[line width=1.5mm,-latex,red!20] (-0.2,0) -- (20+0.2,0);
    \foreach \X [evaluate=\X as \Y using int(\X-2005),count=\Z] in {2009,2010,2012,2015,2016,2017} %<- these are the years not to be highlighted
    {
    \draw[highlight on=<0>] ({\Y-0.2},-0.5) -- ({\Y+0.2},-0.5) -- (\Y,-0.1) -- cycle;
    \node[anchor=south,highlight on=<0>,fill=white,rotate=45,anchor=south
    west,inner sep=0pt] at (\Y,0.2) {\X};
    }
    \foreach \X [evaluate=\X as \Y using int(\X-2000),count=\Z] in {} %<- these are the years which are to be highlighted
    {
    \draw[highlight on=<\Z>] ({\Y-0.2},-0.5) -- ({\Y+0.2},-0.5) -- (\Y,-0.1) -- cycle;
    \node[anchor=south,highlight on=<\Z>,fill=white,rotate=45,anchor=south
    west,inner sep=0pt] at (\Y,0.2) {\X};
    }
    \end{tikzpicture}
    
    
    
    \begin{itemize}
    \item<1> frame 1
    \item<2> frame 2
    \item<3> frame 3
    \item<4> frame 4
    \item<5> frame 5
    \item<6> frame 6
    \end{itemize}
    
\end{frame}
%--- Next Frame ---%

\end{document}

I would like also to know how to show two dates (e.g. 2009 and 2012) with the same item list (e.g. the first item in the itemize).
I also would like to know how I can control the length of the arrow and the separation between dates.

Best Answer

The solution below uses columns, the first one for the timeline and the second one for the itemized list.

\begin{columns}[b]
    \begin{column}{0.15\textwidth}
    ... tikzpicture ...
    \end{column}
    \begin{column}{0.8\textwidth}
    ... itemize ...
    \end{column}
\end{columns}

The length of the timeline is determined by the y coordinates in the \draw command and by the scale factor. Here, the line starts at 0.5 and goes down to -17 (the idea being that each decrement of 1 corresponds to 1 year). The scale factor is 0.38. The vertical position of the picture relative to the itemized list can be controlled by changing the magic number -5.5 in the baseline option.

\begin{tikzpicture}[scale=0.38,baseline={(0,-5.5)}]
\draw[line width=1mm,-latex,red!20] (0,0.5) -- +(0,-17);

Each item on the timeline is described by three values: the \Label, the \Offset in years, and the \Overlay specification. For the timeline in the example below, the list of items is specified as

\Label/\Offset/\Overlay in {2000/0/1,2001/1/2,2002/2/3,2005/5/4,2008/8/5,2009/9/6,2012/12/6,2015/15/7}

The overlay specifications in this list as well as in the itemized list determine when to highlight an item. If two items appear with the same frame number, they will be highlighted at the same time. You can also use more complex specifications to specify ranges etc.

Regarding the arrow heads, note the options -latex and -{Latex[length=8]} in the two draw commands. The first determines the arrow head of the timeline, the second the arrows marking the years on the timeline. You can replace them by any arrow in the tikz library arrows.meta.

enter image description here

\documentclass{beamer}
\setbeamercovered{transparent}
\setbeamertemplate{navigation symbols}{} % removes navigation symbols at the bottom left
\usepackage{tikz}
\usetikzlibrary{overlay-beamer-styles}
\usetikzlibrary{arrows.meta}
\tikzset{
    highlight on/.style={alt={#1{fill=red!80!black,color=red!80!black}{fill=gray!30!white,color=gray!30!white}}},
}
\begin{document}
\begin{frame}[t]{Timeline}
  \begin{columns}[b]
    \begin{column}{0.15\textwidth}
      \begin{tikzpicture}[scale=0.38,baseline={(0,-5.5)}]
      \draw[line width=1mm,-latex,red!20] (0,0.5) -- +(0,-17);
      \foreach \Label/\Offset/\Overlay in {2000/0/1,2001/1/2,2002/2/3,2005/5/4,2008/8/5,2009/9/6,2012/12/6,2015/15/7} {
        \def\Y{-\Offset}
        \draw[highlight on=<\Overlay>,-{Latex[length=8]}] (-0.5,\Y) -- (-0.1,\Y);
        \node[highlight on=<\Overlay>,anchor=west,fill=white,inner sep=0pt] at (0.4,\Y) {\Label};
      }
      \end{tikzpicture}
    \end{column}
    \begin{column}{0.8\textwidth}
      \begin{itemize}
      \item<1> November 2000: marmots start hibernating
      \item<2> August 2001: marmots eat
      \item<2> Semptember 2001: marmots eat
      \item<3> July 2002: marmots eat
      \item<4> May 2005: marmots awake from hibernation\
      \item<4> November 2005: marmots start hibernating again
      \item<5> May 2008: marmots drink honey liquor
      \item<6> 2009, 2012: noisy, marmots can't fall asleep
      \item<7> July 2015: marmots eat pineapple cake
      \end{itemize}
    \end{column}
  \end{columns}
\end{frame}
\end{document}

How to obtain an animated gif from pdf pages: Converting PDF slides to animated GIFs and videos with ImageMagick

Related Question