2

I have a time line labeled with yeardate and a set of flags which I want to make 5 but cannot because I copied it from Drawing a Flag with Tikz

what I whant

I want each flag to include a citation and be placed at 1949, 1979, 1986, 1989 and 1992.

Here is what I have tried

\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

% begin bib
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{greenwade49,
    author  = "George D. Greenwade",
    title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
    year    = "1949",
    journal = "TUGBoat",
    volume  = "14",
    number  = "3",
    pages   = "342--351"
}
@article{greenwade79,
author  = "George D. Greenwade",
title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year    = "1979",
journal = "TUGBoat",
volume  = "14",
number  = "3",
pages   = "342--351"
}
@book{goossens86,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1986",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}
\end{filecontents}
%end bib
\usepackage{natbib}
% flag preamble
\usepackage{tikz}

\pgfmathsetmacro{\flagscalefactor}{0.2}
\pgfmathsetmacro{\flagrotationdegree}{0}
\newcommand{\flagpolecolor}{brown!60!black}
\newcommand{\flagcolor}{yellow!67!red}
\newcommand{\flagsymbol}{\cite{greenwade79}}
\newcommand{\flagsymbolcolor}{black}

\newcommand{\tikzflag}{%
\begin{scope}[scale=\flagscalefactor,rotate=\flagrotationdegree]
    \draw[fill=\flagpolecolor,thick] (0,0) -- ++ (0,8) arc (180:0:0.4 and 0.1) -- ++ (0,-8) arc (360:180:0.4 and 0.1);
    \draw[thick] (0,8) arc (180:360:0.4 and 0.1);
    \draw[fill=\flagcolor,thick] (0.8,7.5) to[out=-30,in=210] ++(3,0) to[out=30,in=150] ++ (3,0) -- ++ (0,-3) to [out=150,in=30] ++(-3,0) to[out=210,in=-30] ++(-3,0) -- cycle;
    \node[\flagsymbolcolor] at (3.8,6) {\textbf{\flagsymbol}};
\end{scope}
}

\newcommand{\questionflag}{%
\pgfmathsetmacro{\flagscalefactor}{0.2}
\pgfmathsetmacro{\flagrotationdegree}{0}
\renewcommand{\flagpolecolor}{brown!60!black}
\renewcommand{\flagcolor}{yellow}
\renewcommand{\flagsymbol}{\cite{greenwade79}}
\renewcommand{\flagsymbolcolor}{red}
\tikzflag
}

\newcommand{\importantflag}{%
\pgfmathsetmacro{\flagscalefactor}{0.2}
\pgfmathsetmacro{\flagrotationdegree}{0}
\renewcommand{\flagpolecolor}{brown!60!black}
\renewcommand{\flagcolor}{green!50!blue}
\renewcommand{\flagsymbol}{\cite{goossens86}}
\renewcommand{\flagsymbolcolor}{white}
\tikzflag
}
%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{frame}

\begin{tikzpicture}[%
every node/.style={
    font=\scriptsize,
    text height=1ex,
    text depth=.25ex,
},
]
% draw horizontal line   
\draw[->] (0,0) -- (12.5,0);

% draw vertical lines
\foreach \x in {0,1,...,12.5}{
    \draw (\x cm,3pt) -- (\x cm,0pt);
}

% place axis labels
\node[anchor=north] at (1,0) {$1950$};
\node[anchor=north] at (3,0) {$1960$};
\node[anchor=north] at (5,0) {$1970$};
\node[anchor=north] at (7,0) {$1980$};
\node[anchor=north] at (9,0) {1990};
\node[anchor=north] at (11,0) {$2000$};
%begin to draw flags
\end{tikzpicture}
\begin{tikzpicture}
\tikzflag
\end{tikzpicture}

\begin{tikzpicture}
\questionflag
\end{tikzpicture}

\begin{tikzpicture}
\importantflag
\end{tikzpicture}

\end{frame}
%bib config 
\bibliographystyle{plainnat}
\bibliography{\jobname} 

\end{document}

1 Answers1

3

This draws such a timeline. The flags are pics which use the tape shaped nodes, and adjust their widths to the content. At the moment the convention is that the north west anchor of that node sits a the location indicated by the date, but this can be changed. The coordinate system is such that the horizontal position is the year. This makes it more intuitive to place the flags.

\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tikz}
\usetikzlibrary{shapes.symbols}
% begin bib
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{greenwade49,
    author  = "George D. Greenwade",
    title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
    year    = "1949",
    journal = "TUGBoat",
    volume  = "14",
    number  = "3",
    pages   = "342--351"
}
@article{greenwade79,
author  = "George D. Greenwade",
title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year    = "1979",
journal = "TUGBoat",
volume  = "14",
number  = "3",
pages   = "342--351"
}
@book{goossens86,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1986",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}
@article{witten89,
      author         = "Witten, Edward",
      title          = "{Quantum Field Theory and the Jones Polynomial}",
      journal        = "Commun. Math. Phys.",
      volume         = "121",
      year           = "1989",
      pages          = "351-399",
      doi            = "10.1007/BF01217730",
      note           = "[,233(1988)]",
      reportNumber   = "IASSNS-HEP-88-33",
      SLACcitation   = "%%CITATION = CMPHA,121,351;%%"
}
@article{witten92,
      author         = "Witten, Edward",
      title          = "{The N matrix model and gauged WZW models}",
      journal        = "Nucl. Phys.",
      volume         = "B371",
      year           = "1992",
      pages          = "191-245",
      doi            = "10.1016/0550-3213(92)90235-4",
      reportNumber   = "IASSNS-HEP-91-26",
      SLACcitation   = "%%CITATION = NUPHA,B371,191;%%"
}

\end{filecontents*}
%end bib
\usepackage{natbib}
% flag preamble
\tikzset{pics/flag/.style={code={
\def\pv##1{\pgfkeysvalueof{/tikz/flags/##1}} 
\path (0,0) node[tape,draw,pic actions,anchor=south west](tmp){#1};
\draw[thin,fill=\pv{pole color}] (tmp.north west) 
rectangle ++ (-0.8ex,-3em); }},
flags/.cd,pole color/.initial=brown!60!black}
%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{frame}[t]

\begin{tikzpicture}[x=0.18cm,
nodes={font=\scriptsize,
    text height=1ex,
    text depth=.25ex,
}
]
% draw horizontal line   
\draw[-stealth] (1945,0) -- (2005,0);
% draw ticks
\draw foreach \X  in {1950,1960,...,2000}
 {(\X,0) -- ++ (0,3pt) node[above]{\X} };
% draw flags
\path foreach \X/\Citation/\FillC [count=\Y]in 
{1949/greenwade49/yellow,1979/greenwade79/blue!20,1986/goossens86/red!20,%
1989/witten89/cyan, 1992/witten92/orange}
{(\X,-1.4*\Y) pic[fill=\FillC]{flag={\cite{\Citation}}}};
\end{tikzpicture}
\end{frame}


\begin{frame}[t]
\frametitle{References}
\bibliographystyle{plainnat}
\bibliography{\jobname} 

\end{frame}

\end{document}

enter image description here

Or with the time-line at the bottom and the flags poles touching it.

\documentclass{beamer}
\usetheme{Madrid}
\usepackage{tikz}
\usetikzlibrary{shapes.symbols}
% begin bib
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{greenwade49,
    author  = "George D. Greenwade",
    title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
    year    = "1949",
    journal = "TUGBoat",
    volume  = "14",
    number  = "3",
    pages   = "342--351"
}
@article{greenwade79,
author  = "George D. Greenwade",
title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year    = "1979",
journal = "TUGBoat",
volume  = "14",
number  = "3",
pages   = "342--351"
}
@book{goossens86,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1986",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}
@article{witten89,
      author         = "Witten, Edward",
      title          = "{Quantum Field Theory and the Jones Polynomial}",
      journal        = "Commun. Math. Phys.",
      volume         = "121",
      year           = "1989",
      pages          = "351-399",
      doi            = "10.1007/BF01217730",
      note           = "[,233(1988)]",
      reportNumber   = "IASSNS-HEP-88-33",
      SLACcitation   = "%%CITATION = CMPHA,121,351;%%"
}
@article{witten92,
      author         = "Witten, Edward",
      title          = "{The N matrix model and gauged WZW models}",
      journal        = "Nucl. Phys.",
      volume         = "B371",
      year           = "1992",
      pages          = "191-245",
      doi            = "10.1016/0550-3213(92)90235-4",
      reportNumber   = "IASSNS-HEP-91-26",
      SLACcitation   = "%%CITATION = NUPHA,B371,191;%%"
}

\end{filecontents*}
%end bib
\usepackage{natbib}
% flag preamble
\tikzset{pics/flag/.style={code={
\def\pv##1{\pgfkeysvalueof{/tikz/flags/##1}} 
\path (0,0) node[tape,draw,pic actions,anchor=south west](tmp){#1};
\draw[thin,fill=\pv{pole color}] (tmp.north west) 
rectangle  ([xshift=-0.8ex]tmp.north west|-Base); }},
flags/.cd,pole color/.initial=brown!60!black}
%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{frame}[t]
\frametitle{A timeline}
\begin{tikzpicture}[x=0.18cm,
nodes={font=\scriptsize,
    text height=1ex,
    text depth=.25ex,
}
]
% draw horizontal line   
\draw[-stealth] (1945,0) coordinate(Base)  -- (2005,0);
% draw ticks
\draw foreach \X  in {1950,1960,...,2000}
 {(\X,0) -- ++ (0,-3pt) node[below]{\X} };
% draw flags
\path foreach \X/\Citation/\FillC [count=\Y]in 
{1949/greenwade49/yellow,1979/greenwade79/blue!20,1986/goossens86/red!20,%
1989/witten89/cyan, 1992/witten92/orange}
{(\X,7-1.2*\Y) pic[fill=\FillC]{flag={\cite{\Citation}}}};
\end{tikzpicture}
\end{frame}


\begin{frame}[t]
\frametitle{References}
\bibliographystyle{plainnat}
\bibliography{\jobname} 

\end{frame}

\end{document}

enter image description here

  • Your answer is great! I will want you to let the flags to use the timeline as the base while the flagsticks may vary in lengths (one taller than another) to allow for space. – Daniel James Jan 01 '20 at 19:12
  • @DanielJames I modified the post, hoping I interpreted the requests correctly. –  Jan 01 '20 at 19:23