I could use some help in creating a vertical timeline with specific requirements. The timeline should display dates on the left side of a vertical line, with the corresponding labels on the right. The dates should be formatted as "year, month day" (e.g. "1938, January 13") in English. Ideally, the year would only be printed the first time a new year is used. The entries should be distributed proportionally along the length of the timeline based on their exact date.
I have provided a code that attempts to achieve this, but I'm having trouble getting the desired output. It does succeed in points 1 - 3, but I'm struggling with 4 and 5 ― although №5 is far more important to me than 4. I would appreciate any help or suggestions to modify the code and achieve the desired vertical timeline.
\documentclass[10pt]{article}
\usepackage[paperwidth=210mm,paperheight=297mm,tmargin=7.5mm,rmargin=7.5mm,bmargin=7.5mm,lmargin=7.5mm,vscale=1,hscale=1]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows, calc, decorations.markings, positioning}
\pagestyle{empty}
\makeatletter
\newenvironment{timeline}[6]{%
\newcommand{\startyear}{#1}
\newcommand{\tlendyear}{#2}
\newcommand{\yearcolumnwidth}{#3}
\newcommand{\rulecolumnwidth}{#4}
\newcommand{\entrycolumnwidth}{#5}
\newcommand{\timelineheight}{#6}
\newcommand{\templength}{}
\newcommand{\entrycounter}{0}
\long\def\ifnodedefined##1##2##3{%
\@ifundefined{pgf@sh@ns@##1}{##3}{##2}%
}
\newcommand{\ifnodeundefined}[2]{%
\ifnodedefined{##1}{}{##2}
}
\newcommand{\drawtimeline}{%
\draw[timelinerule] (\yearcolumnwidth+5pt, 0pt) -- (\yearcolumnwidth+5pt, -\timelineheight);
\draw (\yearcolumnwidth+0pt, -10pt) -- (\yearcolumnwidth+10pt, -10pt);
\draw (\yearcolumnwidth+0pt, -\timelineheight+15pt) -- (\yearcolumnwidth+10pt, -\timelineheight+15pt);
\pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\startyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
\node[year] (year-\startyear) at (\yearcolumnwidth, \templength) {\startyear};
\pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\tlendyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
\node[year] (year-\tlendyear) at (\yearcolumnwidth, \templength) {\tlendyear};
}
\newcommand{\entry}[4]{%
% #1 is the year
% #2 is the month
% #3 is the day
% #4 is the entry text
\pgfmathtruncatemacro{\lastentrycount}{\entrycounter}
\pgfmathtruncatemacro{\entrycounter}{\entrycounter + 1}
\ifdim \lastentrycount pt > 0 pt%
\node[entry] (entry-\entrycounter) [below of=entry-\lastentrycount] {##4};
\else%
\pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(\startyear, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
\node[entry] (entry-\entrycounter) at (\yearcolumnwidth+\rulecolumnwidth+10pt, \templength) {##4};
\fi
\ifnodeundefined{year-##1-##2-##3}{%
\pgfmathsetlengthmacro{\templength}{neg(add(multiply(subtract(##1, \startyear), divide(subtract(\timelineheight, 25), subtract(\tlendyear, \startyear))), 10))}
\draw (\yearcolumnwidth+2.5pt, \templength) -- (\yearcolumnwidth+7.5pt, \templength);
\node[year] (year-##1-##2-##3) at (\yearcolumnwidth, \templength) {##1, ##3 \ifcase##2\or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi};
}
\draw ($(year-##1-##2-##3.east)+(2.5pt, 0pt)$) -- ($(year-##1-##2-##3.east)+(7.5pt, 0pt)$) -- ($(entry-\entrycounter.west)-(5pt,0)$) -- (entry-\entrycounter.west);
}
\begin{tikzpicture}
\tikzstyle{entry} = [align=left,text width=\entrycolumnwidth,node distance=10mm,anchor=west]
\tikzstyle{year} = [anchor=east]
\tikzstyle{timelinerule} = [draw,decoration={markings, mark=at position 1 with {\arrow[scale=1.5]{latex'}}},postaction={decorate},shorten >=0.4pt]
\drawtimeline
}
{
\end{tikzpicture}
\let\startyear\@undefined
\let\tlendyear\@undefined
\let\yearcolumnwidth\@undefined
\let\rulecolumnwidth\@undefined
\let\entrycolumnwidth\@undefined
\let\timelineheight\@undefined
\let\entrycounter\@undefined
\let\ifnodedefined\@undefined
\let\ifnodeundefined\@undefined
\let\drawtimeline\@undefined
\let\entry\@undefined
}
\makeatother
\begin{document}
\begin{timeline}{1935}{1950}{2cm}{1.5cm}{13cm}{26cm}
\entry{1938}{9}{17}{Sudeten German Freikorps and other German paramilitary groups attacked Czechoslovak troops and institutions in the border areas}
\entry{1938}{9}{30}{Signing of the Betrayal of Munich by Hitler, Chamberlain, Daladier, and Mussolini: annexation of Sudetenland by Germany}
\entry{1939}{3}{15}{German army occupies Prague and establishes the Protectorate of Bohemia and Moravia, a puppet state with Konstantin Freiherr von Neurath at the helm}
\entry{1939}{7}{6}{Zentralstelle für jüdische Auswanderung in Böhmen und Mähren [Center for Jewish Emigration in Bohemia and Moravia] is established following the one in Vienna}
\entry{1939}{12}{1}{Jewish children are excluded from state schools}
\entry{1940}{6}{14}{Auschwitz extermination camp is established}
\entry{1941}{9}{27}{Reinhard Heydrich becomes the new Reichsprotektor and orders mass deportation of Jewish people and the reorganization of Terezín into a ghetto}
\entry{1941}{10}{16}{First transport from Prague to the Lodz ghetto}
\entry{1941}{11}{24}{First transport of Jewish people arrives in Terezín}
\end{timeline}
\end{document}
subtract(\startyear, \startyear)
is probably not correct.subtract(\tlendyear, \startyear)
so it fits in better with the rest of the code, for instance, makes it so that the start year of the timeline (1935) is printed right over the end year (1950, in this case).