TransWikia.com

Create a minimalistic timeline with specific date (decimal date) for starting and ending points?

TeX - LaTeX Asked on July 1, 2021

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.

One Answer

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}

Correct answer by owmal on July 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP