1

I want to create a timeline which looks like this:

enter image description here

It should be possible to use a specific date or decimaldate as the staring and ending points of the timeline as well as of events. Almost like in the following example using the chronology package:

\documentclass{scrreprt}
\usepackage{chronology}

\begin{document}

\begin{chronology}[1]{\decimaldate{1}{8}{2016}}{\decimaldate{\day}{\month}{\year}}{\textwidth}
    \event[\decimaldate{1}{8}{2016}]{\decimaldate{31}{12}{2016}}{}
    \event[\decimaldate{1}{8}{2017}]{\decimaldate{31}{12}{2018}}{}
    \event[\decimaldate{25}{1}{2020}]{\decimaldate{\day}{\month}{\year}}{}
\end{chronology}

\end{document}

enter image description here

Here the starting and ending points of the events can be exactly specified but not for the timeline itself. I want the timeline to start at August 1st 2016 and end on today's date (May 25th 2020). Also the looks of it is bulky, I want it to be more minimalistic as the following example using the chronosys package (modified version coming from this link: How do I develop a complex time line?):

\documentclass{scrreprt}
\usepackage{chronosys}

\begin{document}
\startchronology[align=left, startyear=2016,stopyear=\year, height=0pt, startdate=false, stopdate=false, dateselevation=0pt, arrow=false, box=true]
%
\chronograduation[event][dateselevation=0pt]{1}
\chronoperiode[color=green, startdate=false, bottomdepth=0pt, topheight=8pt, textdepth=-25pt, stopdate=false]{2016}{2017}{}
\stopchronology
\end{document}

enter image description here

With this timeline using the chronosys package, I can not specify exact dates. It gives me an error when using decimaldate or something like 2016.5.

I have also seen the moderntimeline package which looks like it would solve my problem, but using it without the moderncv documentclass is difficult as seen here, it does not look like the original: How can I use moderntimeline without moderncv?

I would like to stick to scrrepert.

owmal
  • 325

2 Answers2

1

I was able to solve my problem using only tikz for drawing and xfp for some basic calculations. The result looks like this:

enter image description here

The \decimaldate command comes from the chronosys package and can be imitated by using the following equation:

enter image description here

This is my code (notice the custom command \decdate which basically does the same as the \decimaldate command from the chronosys package):

\documentclass{scrreprt}
\usepackage{xfp} % for basic calculations
\usepackage{tikz}

\newcommand{\decdate}[3]{ % convert date to decimal number \fpeval{(#1-1)/31/12+(#2-1)/12+#3} } \newcommand{\roundup}[1]{\fpeval{ceil(#1)}} \newcommand{\rounddown}[1]{\fpeval{floor(#1)}}

\newcommand{\tlstart}{\decdate{1}{11}{2015}} % tl stands for timeline \newcommand{\tlend}{\decdate{30}{6}{2020}}

\newcommand{\tlconvert}[1]{\fpeval{(#1-\tlstart)/(\tlend-\tlstart)}\linewidth} % calculate decimaldate

\newcommand{\tldraw}{\draw[thick] (\tlconvert{\tlstart}, 0) -- (\tlconvert{\tlend}, 0); % loop through years and add years labels to timeline \foreach \i in {\roundup{\tlstart},...,\rounddown{\tlend}}{ \draw[thick] (\tlconvert{\i},0) -- (\tlconvert{\i},-0.15) node[anchor=north] {\i}; }} \newcommand{\tlentry}[6]{\fill[color=green] (\tlconvert{\decdate{#1}{#2}{#3}}, 0) rectangle (\tlconvert{\decdate{#4}{#5}{#6}}, 0.25);}

\begin{document}

\begin{tikzpicture}
    \tlentry{1}{8}{2016}{31}{12}{2016}
    \tlentry{1}{8}{2017}{31}{12}{2018}
    \tlentry{25}{1}{2020}{25}{5}{2020}
    \tldraw
\end{tikzpicture}

\end{document}

owmal
  • 325
1

EDIT: to utilise new phantom key available in chronos svn rev 9903 or later.

chronos can do this out-of-the-box and now offers a phantom option for creating items without labels. These are no longer invisible. They are no longer there.

Note that I took you at your word: the timeline starts at precisely the date specified and includes no margin, either.

chronos version

\documentclass{article}
% ateb: https://tex.stackexchange.com/a/702342/
\usepackage{chronos}% https://codeberg.org/cfr/chronos

\begin{document} \begin{chronos} [% ateb: https://tex.stackexchange.com/a/702342/ somewhat plain, timeline={% dates={2016-08-01}:{2020-05-25}, without eras, timeline margin'=0pt, timeline era margin'=0pt, timeline years=below, }, frame=false, period/phantom, every period+={above,phantom}, every lines+={line width=5pt,green}, line yshift'=2.5pt, lines on=background, ] \chronosperiod{dates={{2016-08-01}:{2017-01-01}},name=period 1} \chronosperiod{dates={{2017-08-01}:{2018-12-31}},name=period 2} \end{chronos} \end{document}

Note that the items must be named, even though they have no labels. chronos still uses name when creating coordinates to represent the item on the timeline --- and the item's main coordinate can be utilised later, if required, just as it could be if creating a labelled item.

cfr
  • 198,882