1

An absolutely wonderful package for timelines exists. I was attempting to use it to produce a timeline starting from one part of the previous day (the evening) through the next day. So times within days. Is there a way of doing this?

chronos.sty package

MWE (more on the non-working side)

\documentclass[tikz,multi,border=10pt]{standalone}
\usepackage{datenumber}
\usetikzlibrary{arrows.meta}
\newcounter{chronosstartdate}
\newcounter{chronosenddate}
\newcounter{chronosstartyear}
\newcounter{chronosendyear}
\newcounter{chronosyeardate}
\newcounter{chronosthingdate}
\pgfkeys{/pgf/number format,
    int detect,
    set thousands separator={},
}
\tikzset{
    chronos/.code={% https://tex.stackexchange.com/a/159856/ - Claudio Fiandrino
        \tikzset{%
            align=center,
            anchor=mid,
            /chronos/.cd,
            #1
        }%
        \setstartyear{\chronosstartyear}%
        \setmydatenumber{chronosstartdate}{\chronosstartyear}{\chronosstartmonth}{\chronosstartday}%
        \setmydatenumber{chronosenddate}{\chronosendyear}{\chronosendmonth}{\chronosendday}%
        \pgfmathsetmacro\chronosunit{(\chronoswidth-20pt)/(\thechronosenddate-\thechronosstartdate)}%
        \draw [line width=\chronosheight] (-10pt,0) coordinate (chronos pre) -- +(\chronoswidth,0) coordinate (chronos post);
        \coordinate (chronos start) at (0,0);
        \coordinate (chronos end) at ([xshift=-10pt]chronos post);
        \setcounter{chronosstartyear}{\chronosstartyear}%
        \setcounter{chronosendyear}{\chronosendyear}%
        \def\tempa{01}%
        \ifx\chronosstartmonth\tempa
        \ifx\chronosstartday\tempa
        \else\stepcounter{chronosstartyear}%
        \fi
        \else\stepcounter{chronosstartyear}%
        \fi
        \def\tempa{12}%
        \def\tempb{31}%
        \ifx\chronosendmonth\tempa
        \ifx\chronosendday\tempb
        \stepcounter{chronosendyear}%
        \fi
        \fi
        \foreach \i in {\thechronosstartyear,...,\thechronosendyear} {%
            \setmydatenumber{chronosyeardate}{\i}{01}{01}%
            \node [above, anchor=south] at ({(\thechronosyeardate-\thechronosstartdate)*\chronosunit pt},0) {\i}; }
    },
    chronos date/.code args={#1-#2-#3}{%
        \tikzset{%
            /chronos/.cd,
            thing year={#1},
            thing month={#2},
            thing day={#3},
        }%
        \setmydatenumber{chronosthingdate}{\chronosthingyear}{\chronosthingmonth}{\chronosthingday}%
    },
    /chronos/.search also={/tikz},
    /chronos/.cd,
    start year/.store in=\chronosstartyear,
    start month/.store in=\chronosstartmonth,
    start day/.store in=\chronosstartday,
    end year/.store in=\chronosendyear,
    end month/.store in=\chronosendmonth,
    end day/.store in=\chronosendday,
    thing year/.store in=\chronosthingyear,
    thing month/.store in=\chronosthingmonth,
    thing day/.store in=\chronosthingday,
    start date/.style args={#1-#2-#3}{%
        start year={#1},
        start month={#2},
        start day={#3},
    },
    end date/.style args={#1-#2-#3}{%
        end year={#1},
        end month={#2},
        end day={#3},
    },
    width/.store in=\chronoswidth,
    height/.store in=\chronosheight,
    start date=2023-06-01,
    end date=2023-06-02,
    width=100mm,
    height=1pt,
    chronos date=1850-01-01,
}
\begin{document}
    \begin{tikzpicture}
        [chronos]
        \foreach \i/\j/\k in {{2023-06-01}/{No fireworks}/20pt,{2023-06-01}/{No fireworks}/80pt,{2023-06-01}/{May Day}/50pt,{2023-06-01}/{Summer Solstice}/10pt}
        {%
            \path [postaction={draw=gray, -{Triangle[width=1.5pt,reversed,length=.75pt,fill=gray]}}, chronos date/.expanded={\i}] ({(\thechronosthingdate-\thechronosstartdate)*\chronosunit pt},0) -- +(0,-\k) node [anchor=north, fill opacity=.75, fill=gray!25, draw=gray, rounded corners, font=\footnotesize\sffamily] {\chronosthingday/\chronosthingmonth/\chronosthingyear\\\j};
        }
    \end{tikzpicture}
\end{document}

enter image description here

gernot
  • 49,614
A Feldman
  • 3,930
  • If this was within the scope of chronos, I would try to do something but, honestly, it isn't. Unless somebody can suggest an easy way of adding support for time of day, I'm going to say the package isn't intended to do it. The code uses pgfcalendar and datenumber. At least, it may not, but it currently claims to. (I really should comment my code.) Adding support for fractions of days would be a whole other thing. – cfr Jul 02 '23 at 05:47
  • Thanks that's what I was thinking might be the answer – A Feldman Jul 02 '23 at 18:08
  • OK, the current version doesn't use datenumber, but it definitely uses \pgfcalendardatetojulian. This the basis for all the calculations placement depends on from where to put marks on the timeline to where to place links to boxes marking events etc. It wouldn't be that hard to do something similar for periods of time as opposed to durations of years, but I don't think it makes sense for chronos to try to do it. My impression was there were already packages available for presenting timelines limited to months/weeks/days/hours which worked pretty well, but perhaps I'm mistaken about that. – cfr Jul 15 '23 at 01:56
  • At any rate, I think you should ask how you could do something similar, perhaps specifying the flavour of timeline you'd prefer. – cfr Jul 15 '23 at 01:57
  • Thanks @cfr appreciate your contributions to this and to the community! – A Feldman Jul 21 '23 at 01:00

0 Answers0