15

While putting together a "traditional" timeline, I kludged together a means of coloring my boxes in chronosys, but I would like the event boxes to be partially transparent.

This would allow better eye-tracking, particularly when events are close together, with different mark depths. Please see the below mock up, made with Gimp, for how this might look.

It would also be nice if the text was better aligned to the colorbox, notice the "s" in Darwin and the "m-" in Empire. My kludge code seems to work but produces errors. **(Thanks to Kola B., and see Gray vs. grey)

The code is below:

\documentclass[letterpaper,12pt,landscape]{article}
\usepackage[T1]{fontenc}
\usepackage{chronosys}

\begin{document}

\subsection*{Biographical cornerstones}
\startchronology[startyear=1850,stopyear=1950,height=0.5ex]

\chronoevent[textwidth=4.5cm,colorbox={grey!10},markdepth=100pt]%
{1882}{born in the Austrian part of the Austria-Hungarian Empire}
\chronoevent[textwidth=4cm,colorbox={grey!10},markdepth=40pt]%
{1885}{Publication of Darwin's Evolutionary Theory}

\stopchronology

\end{document}

A sample of the above when compiled:

enter image description here

A crude mock up of what this might look like:

The chronosys documentation does not mention transparency as an option, but as it uses Tikz (for drawing lines), and colorbox (for events) and I believe transparency is possible.

I tried the following, attempting to use how to specify transparent colors per cfr's reference:

\documentclass[letterpaper,12pt,landscape]{article}
\usepackage[T1]{fontenc}
\usepackage{chronosys}
\usepackage{transparent}

\begin{document}

\subsection*{Biographical cornerstones}
\startchronology[startyear=1850,stopyear=1950,height=0.5ex]

\chronoevent[textwidth=4.5cm,colorbox={gray!10},markdepth=100pt]%
{1881}{born in the Austrian part of the Austria-Hungarian Empire}
\chronoevent[textwidth=4cm,markdepth=40pt]%
{1885}{\transparent{0.3}\colorbox{blue}{Publication of Darwin's Evolutionary Theory}}

\stopchronology

\end{document}

But the result was this:

enter image description here

Changing the transparency affects the color of the box, making it lighter or darker, but not allowing the box to become more, or less, transparent. Notice that the text in the light blue box is very faint. The text within the box also becomes lighter or darker when the "transparency" is modified, an unwanted side effect.

Please advise if a solution exists using another timeline package other than chronosys It also occurred to me that another way of accomplishing the goal would be to somehow make the lines connecting the boxes semi transparent. The solution should be able to reflect month/day/year for events, with automatic horizontal placement of events on the timeline. If anyone knows how to turn percusse's answer into a MWE that would be appreciated. It does not matter if the answer is "plain-TeX" or "Tikz", or requires multiple compilation, or otherwise, just so long as it works.

Bravo to @cfr for the below solution which works perfectly. His solution makes for a different type of timeline than can be made with currently available LaTeX/TeX packages (at least with the packages that I know of).

Notwithstanding the wonderful solution presented, it still be helpful to have a "package" based solution, either with chronosys or another package.

A Feldman
  • 3,930
  • 1
    Have you already tried gray inthe place of grey? – Kola B. Feb 25 '16 at 00:14
  • That took care of all the error messages! – A Feldman Feb 25 '16 at 00:21
  • 4
    Austro-Hungarian Empire, if memory serves correctly. (No jokes about my age, please.) – cfr Feb 25 '16 at 02:43
  • I don't really understand the transparency bit. What will a transparent box on a white background look like exactly? Other than a paler shade of the colour? \documentclass[tikz,border=10pt,multi]{standalone} \begin{document} \begin{tikzpicture} \fill [blue, opacity=.5] (0,0) rectangle (1,1); \fill [blue] (1,0) rectangle (2,1); \fill [blue!50] (2,0) rectangle (3,1); \end{tikzpicture} \end{document} produces this. What is the difference between the left and right squares? – cfr Feb 25 '16 at 02:47
  • See http://tex.stackexchange.com/questions/45596/how-to-specify-transparent-colors?rq=1 for transparency options. (Question is restricted to XeTeX/LuaTeX, but the answers aren't!) – cfr Feb 25 '16 at 02:52
  • @cfr I'm looking for a "ghost" of a line going from the chronoevent marked 1881 through the 1885 chronoevent box that has the text regarding the publication of Darwin's Theory. I think it might look better. Thanks for the reference. – A Feldman Feb 25 '16 at 02:53
  • I would think it would make it less legible. But see the question I linked for options. – cfr Feb 25 '16 at 02:54
  • @cfr I did look at them, but I could not apply any of them as it seems that I cannot put a "" or a "\begin{}" or "\end{}" type statement in the "colorbox={}" field, which is why for the color of each I used "colorbox={gray!10}" – A Feldman Feb 25 '16 at 02:57
  • This should be easy. The package is TikZ. But it doesn't use any of the usual interface for doing anything. It doesn't, as far as I can tell, use PGF keys at all. If it did, customising it would take seconds - minutes at most. As it is, there's just a tangle of package-specific reinvention of the wheel. – cfr Feb 25 '16 at 03:18
  • 2
    I think it would be easier to reimplement this in TikZ directly than to figure out the package's code since doing the latter would probably never provide a very satisfying result. So I guess the question is whether you want to stick to chronosys and abandon transparency (probably) or abandon chronosys. There are some other existing solutions for drawing timelines chronology is one but there's also a TikZ-based solution on GitHub somewhere. If you are interested, I'll see if I can find the question which talks about it. – cfr Feb 25 '16 at 22:39
  • @cfr I would appreciate that, and much obliged. My use has dates crammed together, sometimes within a day or so of each other. This produces many lines to many events, so visually I think that some transparency may help eye tracking. – A Feldman Feb 25 '16 at 23:07
  • Apart from chronology, there is http://tex.stackexchange.com/questions/159835/milestone-graphic-in-tikz/159856#159856 which is TikZ-based and so would definitely support transparency. (Well chronosys is TikZ-based, too, but it takes a rather eccentric approach as far as I can see.) If you read the comments, you'll see I created a rather idiosyncratic (and much more compact) off-shoot of that project - hence my interest. – cfr Feb 26 '16 at 00:04
  • chronology is not bad for densely-packed timelines. It can be relatively economical. There are also some questions about this kind of thing around, too e.g. http://tex.stackexchange.com/questions/161257/how-to-use-chronology-package-to-draw-this-timeline (chronology tag) or search for the keyword timeline. – cfr Feb 26 '16 at 00:13
  • The package seems very rigid in its syntax and seemingly disregards the de facto TikZ/PGF programming style, which makes it rather difficult to modify in ways the package author did not foresee. Perhaps you are better off emailing him..? – jon Mar 04 '16 at 03:23
  • @jon Thank you for the suggestion. I went ahead and did that. – A Feldman Mar 04 '16 at 13:15
  • Some of the comments imply abandoning use of chronosys. My problem is that I have yet to find a mature timeline package other than chronosys that produces traditional timelines. The package made by @cfr https://github.com/cfiandra/timeline is beautiful and modern, but for my very ultra conservative audience would not be suitable. – A Feldman Mar 04 '16 at 14:18
  • @AFeldman I agree that package is beautiful and modern. I would be proud to have written it, but it is, in fact, none of mine! I adapted a small part of it for a project, but that's all. I can claim no credit for even a single line of the code. It was written when I was just at the very beginning of starting to learn Tikz;).|. – cfr Mar 04 '16 at 16:12
  • @jon I see you thought the same as me on reading the code ;). I was about to suggest emailing the author. @ OP If chronology is no good and you don't want the modern look of timeline then I think you have a few choices: (1) email the author (as you've done), (2) figure out the chronosys code (good luck), (3) implement the time line directly in TikZ (or other favoured package as preferred), (4) live without transparency. I can't see any easy way to use chronosys as is to do what you want. It just isn't designed to be extended: if it supports an option, great; if not, you're out of luck. – cfr Mar 04 '16 at 16:19
  • @cfr -- It is certainly not something designed to encourage third-party modifications! – jon Mar 05 '16 at 18:48
  • Is this possible using chronology? – A Feldman Mar 05 '16 at 21:22
  • Just look at the documentation. No, you can't do this. But it might offer an alternative. That was all. It draws what I guess are more traditional timelines. (I don't really know what's traditional in timeline terms, though.) Its documentation on CTAN is one page. If its examples aren't any good, then you can move on. I suspect you'll say no good, in which case, I think you are left with the choices I outlined above, maybe using Zarko's answer as a start if (3) appeals. Otherwise choosing one of the other options. chronosys is just more trouble than its worth - it ain't gonna happen. – cfr Mar 24 '16 at 02:01
  • How much point is there in distinguishing by day when you have a short length to represent a century or more? I can't imagine they'll be much visible difference between, say, 1873-01-23 and 1873-01-24. When you say that it must distinguish differences which are that fine-grained, how can ot exactly, in such a small space? – cfr Mar 25 '16 at 03:29
  • @cfr I really use a year as my period, not the century. – A Feldman Mar 25 '16 at 03:35
  • So do you need years ?! – cfr Mar 25 '16 at 03:54
  • I use a year as the period, and each event shows a month/day/year. By fine grained I mean that sometimes there will be events on consecutive days or separated only by a couple of days. – A Feldman Mar 25 '16 at 03:56

3 Answers3

8

Current version: chronos.
Please report bugs on codeberg.

Here's a basic version. Essentially, the style chronos sets up the basic timeline. chronos date can then be used to get the appropriate point on that timeline from which to drop the lines to the event nodes. Information from chronos date can also be used in the node itself. Here it is used to print the date before the node content.

I've used a loop to add events, but this is just to save typing. They could be added one by one if preferred.

The basic timeline schema should be laid out like this:

\begin{tikzpicture}
    [
      chronos={%
        <options>
      },
    ]
    <events and such on the timeline specified in the usual way>
\end{tikzpicture}

The options for chronos are as follows:

  • width=<dimension>,
  • height=<dimension>,
  • start date=YYYY-MM-DD,
  • end date=YYYY-MM-DD,

By default the timeline is 1pt high and 100mm wide and the start and end dates are at the beginning of the last millennium.

chronos date=YYYY-MM-DD can then be used in the picture to help place things on the timeline. For example, I use it below in a loop as follows where \i holds the date for the current iteration, \j holds the text and \k holds the distance to offset the node below the timeline.

\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};

chronos date is fed \i i.e. the date and this sets both \thechronosthingdate and each of \chronosthingyear, \chronosthingmonth and \chronosthingday. The first is a number which can be used to calculate how far along the timeline to place the event. This should be at

({(\thechronosthingdate-\thechronosstartdate)*\chronosunit pt},0)

\thechronosstartdate holds a number corresponding to the start date of the timeline and \chronosunit holds the length in points allowed for each day. This is calculated when chronos is used from the start and end dates and the width. An offset of 10pt is allowed at each end so that the first date isn't right at the start nor the last date right at the end.

\chronosthingday, \chronosthingmonth and \chronosthingyear hold the day, month and year set by chronos date respectively and can be used in the content of nodes or labels, if desired.

Feeding our loop the following set of triples (\i/\j/\k)

  • {1001-11-05}/{No fireworks}/10pt
  • {1002-07-04}/{No fireworks}/80pt
  • {1002-05-01}/{May Day}/50pt
  • {1002-06-21}/{Summer Solstice}/10pt

thus yields

chronos

Complete code:

\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=1001-10-01,
  end date=1003-06-14,
  width=100mm,
  height=1pt,
  chronos date=1850-01-01,
}
\begin{document}
\begin{tikzpicture}
  [chronos]
  \foreach \i/\j/\k in {{1001-11-05}/{No fireworks}/10pt,{1002-07-04}/{No fireworks}/80pt,{1002-05-01}/{May Day}/50pt,{1002-06-21}/{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}
cfr
  • 198,882
  • Can't wait to try this out! Is it possible to have month/day/year rather than day/month/year? – A Feldman Mar 26 '16 at 02:30
  • I do have one question. What is the chronos date=1850-01-01 for? – A Feldman Mar 26 '16 at 03:09
  • 1
    You can just reverse the order they are printed in the node. Month/day/year is illogical in my opinion. Year - month - day or day - month -year is logical. But you can change them round if you prefer illogic. – cfr Mar 26 '16 at 03:10
  • It is good practice to set everything to some default. In this case, it needs to be a date after 1800 because datenumber starts from year 1800 by default and so it must be a later date because the default value is in effect when chronos date is initialised. – cfr Mar 26 '16 at 03:12
  • It's because chronos date executes \setmydatenumber{chronosthingdate}{\chronosthingyear}{\chronosthingmonth}{\chronosthingday} whereas /chronos/start date and /chronos/end date don't. So those defaults can be earlier than 1800. – cfr Mar 26 '16 at 03:14
  • Thanks, the month-day-year is still the only date format the courts in New York use, and with your kind advice I figured how to change that. Thanks for the explanation of the 1850 date. – A Feldman Mar 26 '16 at 03:14
  • @AFeldman I'm sure. But it is still illogical ;). I lived in the US for over a decade and I still insist it is illogical. – cfr Mar 26 '16 at 03:15
  • yes it is illogical, kind of like the imperial measurement system we still use. – A Feldman Mar 26 '16 at 03:16
  • you should make this into a package. It is a really good piece of work. – A Feldman Mar 26 '16 at 03:17
  • We use both. Which is even worse. However, US measures are not always the same as imperial e.g. liquid measures are different (a gallon of gas is less than a gallon of petrol, for example). Not that I cook with petrol, but it is crucial to know that 1 pint means something different if you use both British and American recipe books! – cfr Mar 26 '16 at 03:18
  • It would take a lot more work to make it into a package, I'm afraid. I'm having enough trouble with prooftrees as it is ;). – cfr Mar 26 '16 at 03:21
  • Well thank you, it is very usable, useful, and beautiful as it is! – A Feldman Mar 26 '16 at 03:47
  • @AFeldman Version 3 is at http://tex.stackexchange.com/a/324106/ ;). – cfr Aug 10 '16 at 23:10
  • @AFeldman I should have another update shortly. I'll update version 3 when I do. – cfr Aug 11 '16 at 13:35
  • @AFeldman Without year zero: http://tex.stackexchange.com/a/324857/ ;). – cfr Aug 15 '16 at 04:06
  • I think the 2017 version @gerrit, though the latest one is on my drive. – cfr Nov 19 '19 at 23:40
4

This question pops up every once in a while and I thought somebody will eventually go in, find the TikZ keys and change it.... But.... how much wrong can someone be?

Anyway, the author does some extremely conservative stuff and doesn't give in to the pgfkeys. Because why make things easier? (a typical trait of plain TeX users by the way even though pgfkeys work also in plain TeX).

So following his(it must be a he) steps, I've found out that the box is a colorbox but not a TikZ node. So your options are very limited

  • The author fixes it
  • You start defining an option such as

     \csname !chrverif\endcsname\gdef\csname !chr@eventopacity\endcsname{}%
     \csname !chrverif\endcsname\gdef\csname !chreventdefaultopacity\endcsname{1}%
    

    then place this option wherever is needed and also encapsulate the part that draws the box (starting with % %AFFICHAGE if I'm not mistaken) with transparency group. Then you will have strange issues such as pdflatex - transparent package seems not to work

With all respect, this package goes nowhere. Write your own simple TikZ package and you'll recover the functionality in a week or two with pgfkeys based syntax. Half of the package code reinvents (another trait of plain TeX users) pgfkeys option parsing. And another quarter is basically boxing unboxing content.

percusse
  • 157,807
3

To me is more simple to draw "Biographical cornerstones" in pure TikZ picture than to toil and moil with chronosys. With tikzpicture you have slightly more code, however with it you are awarded with full control on customization of nodes style. For example:

\documentclass{article}
    \usepackage{tikz}
    \usetikzlibrary{arrows.meta,positioning}

\begin{document}
\subsection*{Biographical cornerstones}
    \begin{center}
\begin{tikzpicture}[
    node distance = 0mm,
TN/.style args = {#1/#2}{% as Transparency Node
    fill=#1,
    fill opacity=#2,
    text opacity=1, align=flush left,
    inner sep=1mm, outer sep=0.25mm, below},
   TN/.default = gray!50/0.5,
      L/.style = {% as Line
    draw=gray, line width=1mm,
    {Bar[width=4mm,line width=0.4pt]}-{Bar[width=4mm,line width=0.4pt]}
                 }
                    ]
\draw[L]    ( 0,0)  coordinate (s)
                    node[above=2mm] {1850} -- + 
            (10,0)  node[above=2mm] {1950};
\draw (3.1,0) -- + (0,-2.4)
        node (e1)   [TN]              {1881}
        node (e1a)  [TN,below=of e1]  {born in the Austrian part\\
                                       of the Austria-Hungarian\\
                                       Empire};
\draw (3.5,0) -- + (0,-0.4) 
        node (e2)   [TN=blue!30/0.3]  {1885}
        node (e2a)  [TN=blue!30/0.7,
                     below=of e2]    {Publication of Darwin's\\
                                      Evolutionary Theory};
    \end{tikzpicture}
    \end{center}
\end{document}

This gives:

enter image description here

Zarko
  • 296,517
  • The above is excellent as it is exactly how this should look based on what I showed for the MWE. The problem I have is that I can live with the mark depth being hand written (chronosys requires this), but I need the placement of time intervals to be done programmatically (which chronosys does). Hand programming the horizontal placement of each day, month and year can become confusing, prone to error, and imprecise, not to mention a bit difficult, especially when one has a lot of the same month and year, but different days. I don't trust my eye to be true to the time intervals. – A Feldman Mar 07 '16 at 04:05
  • For years I use simple rule: in presented case the time intervals is 100 year --> 1 year is 1mm of horizontal distance. Simply, effectively :-) and manulay :-(. Otherwice, read Percusse answer (and wrote missing part of my approach that it be more similar to chronosys). This distances can be defined on the similar way as chronosys do. Unfortunately I can't test it since its installation in MikTeX is broken , missed are essential file(s) ... – Zarko Mar 07 '16 at 04:22