4

This question is a continuation of post "Evolution bar with dates in a Beamer presentation".

The beamer-tikz code I am testing is:

\documentclass{beamer}
\setbeamercovered{transparent}
\usepackage{tikz}
\usetikzlibrary{overlay-beamer-styles}
 \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]
\frametitle{Timeline}
\begin{tikzpicture}%[scale=0.9, every node/.style={scale=0.6}]
% \draw[line width=2mm,-latex,red!20] (-0.2,0) -- (9,0);
\draw[line width=1mm,-latex,red!20] (-0.2,0) -- (\textwidth+0.2,0);
\foreach \X [evaluate=\X as \Y using int(\X-2000),count=\Z] in {2000,2001,2002,2005,2008,2015}
{
\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] at (\Y,0.2) {\X};
}
\end{tikzpicture}
\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
\end{itemize}
\end{frame}
\end{document}

However, the year 2015 seems to go out the timeline. Besides, I would like to create a second frame with the same timelines marks (2000,2001,2002,2005,2008,2015) but with items of 2008 and 2015 (\item<5> and \item<6>).

user1993416
  • 1,046

1 Answers1

6

Oh, so many marmots! ;-)

\documentclass{beamer}
\setbeamercovered{transparent}
\usepackage{tikz}
\usetikzlibrary{overlay-beamer-styles}
 \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]
\frametitle{Timeline}
\begin{tikzpicture}[xscale=0.5]%[scale=0.9, every node/.style={scale=0.6}]
% \draw[line width=2mm,-latex,red!20] (-0.2,0) -- (9,0);
\draw[line width=1mm,-latex,red!20] (-0.2,0) -- (20+0.2,0);
\foreach \X [evaluate=\X as \Y using int(\X-2000),count=\Z] in {2000,2001,2002,2005,2008,2015}
{
\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> 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> July 2015: marmots eat pineapple cake
\end{itemize}
\end{frame}
\end{document}

enter image description here

ADDENDUM: Continuation on the next frame.

\documentclass{beamer}
\setbeamercovered{transparent}
\usepackage{tikz}
\usetikzlibrary{overlay-beamer-styles}
 \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]
\frametitle{Timeline}
\begin{tikzpicture}[xscale=0.5]%[scale=0.9, every node/.style={scale=0.6}]
% \draw[line width=2mm,-latex,red!20] (-0.2,0) -- (9,0);
\draw[line width=1mm,-latex,red!20] (-0.2,0) -- (20+0.2,0);
\foreach \X [evaluate=\X as \Y using int(\X-2000),count=\Z] in {2000,2001,2002,2005,2008,2015}
{
\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> 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> July 2015: marmots eat pineapple cake
\end{itemize}
\end{frame}

\begin{frame}[t]
    \frametitle{Historial}
\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-2000),count=\Z] in {2000,2001,2002} %<- 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 {2005,2008,2015} %<- 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> November 2005: marmots start hibernating again
    \item<2> May 2008: marmots drink honey liquor
    \item<3> July 2015: marmots eat pineapple cake
\end{itemize}
\end{frame}
\end{document}

enter image description here

  • @user1993416 I just made this up. After using [xscale=0.5] and remembering that we live in 2018 (that's at least what TeXLive claims;-) I thought, that would be a reasonable choice. ;-) –  Jun 29 '18 at 16:38
  • 1
    @marmot even more marmots: https://github.com/samcarter8/tikzmarmots – samcarter_is_at_topanswers.xyz Jun 29 '18 at 17:24
  • 1
    @samcarter ;-) ;-) ;-) ;-) ;-) ;-) Is that a starting point for a package? ;-) ;-) –  Jun 29 '18 at 17:26
  • 1
  • @marmot Is there any way to split the items of the timeline y two frames, for example, \item<1> \item<2> and <3> in the first frame but with a complete timeline (from 2000 to 2015). I want all the years to appear in the timeline but talking only items of half of the set of years in the first frame (<1> to <4>) and the second half (2008 and 2015, i.e. <5> and <6>) in the second frame. I have tested the splitting but the for loop includes two slides for years 2008 and 2015 in the first frame and similar issue in the second frame. – user1993416 Jun 29 '18 at 17:47
  • @marmot The problem I have found in this solution is that it creates slides for all the years in each frame and not only the years the frame has items related to them. Is there any way to separate the items into two frames and keep the full timeline made with Tikz in the two frames?. – user1993416 Jun 29 '18 at 18:09
  • @user1993416 Sure, but all you need to do is to make the list on the second frame only contain the years you want to show, and draw the unwanted dates on frame 0, which does not exist. I'll post an example. –  Jun 29 '18 at 18:16
  • Does anyone know how to edit that code so as to have dates within a year? Like 1 march 2020, 11 march 2020 etc...? – llll Aug 25 '20 at 09:30