How to create a timeline with LaTeX?

前端 未结 8 1434
感动是毒
感动是毒 2020-12-12 09:52

In history-books you often have timeline, where events and periods are marked on a line in the correct relative distance to each other. How is it possible to create somethin

相关标签:
8条回答
  • 2020-12-12 10:39

    Firstly, I prefer tikz guided solution, because it gives you more freedom. Secondly, I'm not posting anything totally new. It is obviously similar to Zoe Gagnon's answer, because he showed the way.

    I needed some year timeline and it took me some time (what a surprise!) to do it, so I'm sharing the results. I hope you'll like it.

    \documentclass[tikz]{standalone}
    \usepackage{verbatim}
    \begin{document}
    \newlength\yearposx
    \begin{tikzpicture}[scale=0.57] % timeline 1990-2010->
        % define coordinates (begin, used, end, arrow)
        \foreach \x in {1990,1992,2000,2002,2004,2005,2008,2009,2010,2011}{
            \pgfmathsetlength\yearposx{(\x-1990)*1cm};
            \coordinate (y\x)   at (\yearposx,0);
            \coordinate (y\x t) at (\yearposx,+3pt);
            \coordinate (y\x b) at (\yearposx,-3pt);
        }
        % draw horizontal line with arrow
        \draw [->] (y1990) -- (y2011);
        % draw ticks
       \foreach \x in {1992,2000,2002,2004,2005,2008,2009}
            \draw (y\x t) -- (y\x b);
        % annotate
        \foreach \x in {1992,2002,2005,2009}
            \node at (y\x) [below=3pt] {\x};
        \foreach \x in {2000,2004,2008}
            \node at (y\x) [above=3pt] {\x};
        \begin{comment}
        % for use in beamer class
        \only<2>    {\fill      (y1992) circle (5pt);}
        \only<3-5>  {\fill      (y2000) circle (5pt);}
        \only<4-5>  {\fill      (y2002) circle (5pt);}
        \only<5>    {\fill[red] (y2004) circle (5pt);}
        \only<6>    {\fill      (y2005) circle (5pt);}
        \only<7>    {\fill[red] (y2005) circle (5pt);}
        \only<8-11> {\fill      (y2008) circle (5pt);}
        \only<11>   {\fill      (y2009) circle (5pt);}
        \end{comment}
    \end{tikzpicture}
    \end{document}
    

    As you can see, it's tailored to beamer presentation (select part and also scale option), but if you really want to test it in a presentation, then you should move \newlength\yearposx outside of the frame definition, because otherwise you'll get error veritably stating that command \yearposx is already defined (unless you remove the selection part and any other frame-splitting commands from your frame).

    enter image description here

    0 讨论(0)
  • 2020-12-12 10:46

    Also the package chronosys provides a nice solution. Here's an example from the user manual:

    enter image description here

    0 讨论(0)
提交回复
热议问题