[Tex/LaTex] Simple Vertical Timeline with Arrows

chronologytikz-pgf

I would like to know how to replicate the style of this vertical timeline where the arrows are pointing toward the relevant times on the line. If that is too broad of a request, it would be very helpful to simply guide me toward the basic structure. Any help is appreciated.

enter image description here

Best Answer

If you cannot avoid needing labels on both sides of the line, I would recommend putting the year labels on the line itself in the centre rather than off to one side. Here's a not terribly sophisticated format:

unsophisticated timeline

Obviously, it is possible to make the overall appearance much fancier according to preference, audience and content. However, the following kronos style provides the fundamental structure and determines the placement of labels and events according to the values of various variables which may be modified (start, end, step, height and width). \kronosevent*[]{} can then be used to place events on the line. The starred version places them right; the unstarred left. The first, optional argument can be used to set, for example, year to something other than the default (presumably required unless all events happen at the same time, in which case a timeline is of little use) and the mandatory argument specifies the event's description.

The above, for instance was specified using an optional argument to the tikzpicture environment, kronos. This sets the timeline up with the default values for start, end, step, width and height.

The picture then specifies 3 events - 2 on the left and 1 on the right. The first

  \kronosevent{Something here}

uses the default settings, which puts the event at 1850 to the left of the line. The second

  \kronosevent[year=300]{Something\\with a long\\description\\happened\\a while ago}

puts an event at the specified time (300CE) to the left of the line, while the third

  \kronosevent*[year=1457]{Major changes}

puts an event at 1457CE to the right of the line.

Complete code:

\documentclass[tikz,multi,border=10pt]{standalone}
\usepackage{xparse}
\usetikzlibrary{arrows.meta}
\pgfkeys{/pgf/number format,
  int detect,
  set thousands separator={},
}
\tikzset{
  kronos/.code={% http://tex.stackexchange.com/a/159856/ - Claudio Fiandrino
    \tikzset{%
      align=center,
      anchor=mid,
      /kronos/.cd,
      #1
    }%
    \pgfmathsetmacro\kronosunit{(\kronosheight-20pt)/(\kronosend-\kronosstart)}%
    \draw [line width=1pt]  (-.5*\kronoswidth,10pt) coordinate (kronos tl) ++(3.5pt,0) coordinate (kronos pre) -- ++(0,-\kronosheight) ++(\kronoswidth-3.5pt,0) coordinate (kronos br) ++(-3.5pt,0) coordinate (kronos post) -- (kronos post |- kronos pre);
    \coordinate (kronos start) at (0,0);
    \coordinate (kronos end) at ([yshift=10pt]kronos post);
    \pgfmathsetmacro\tempa{int(\kronosstart+\kronosstep)}%
    \foreach \i in {\kronosstart,\tempa,...,\kronosend} {%
      \node (\i) [font=\sffamily] at (0,{(\kronosstart-\i)*\kronosunit pt}) {\i};
      \draw [thick] (\i.west -| kronos pre) -- +(-3.5pt,0) (\i.east -| kronos post) -- +(3.5pt,0);
    }
  },
  kronos arrow/.style={{Stealth[]}-, thick, shorten <=2.5pt},
  kronos event/.search also={/kronos,/tikz},
  kronos event/year/.store in=\kronosyear,
  kronos event/year=1850,
  /kronos/.search also={/tikz},
  /kronos/.cd,
  start/.store in=\kronosstart,
  end/.store in=\kronosend,
  step/.store in=\kronosstep,
  width/.store in=\kronoswidth,
  height/.store in=\kronosheight,
  start=200,
  end=2000,
  width=10mm,
  height=100mm,
  step=200,
}
\NewDocumentCommand\kronosevent { s O {} m }
{%
  \tikzset{%
    kronos event/.cd,
    #2
  }
  \coordinate (a) at (0,{(\kronosstart-\kronosyear)*\kronosunit pt});
  \IfBooleanTF {#1}
  {%
    \draw [kronos arrow] (a -| kronos br) -- ++(30pt,0) node [anchor=west, align=left, font=\footnotesize\sffamily] {\textbf{\kronosyear} #3};
  }{%
    \draw [kronos arrow] (a -| kronos tl) -- ++(-30pt,0) node [anchor=east, align=left, font=\footnotesize\sffamily] {\textbf{\kronosyear} #3};
  }
}
\begin{document}
\begin{tikzpicture}
  [kronos]
  \kronosevent{Something here}
  \kronosevent[year=300]{Something\\with a long\\description\\happened\\a while ago}
  \kronosevent*[year=1457]{Major changes}
\end{tikzpicture}
\end{document}
Related Question