I found some examples of timelines on the site, but they don't seem fit for the type of graph I want to create.

Basically I'd like to create one of those timelines you see in books, where you compare several lifetimes of various authors, in order to see when they were born and when they died.

A realistic example of what I want to do is this:

timeline example

Note: the highlighting color is arbitrary and I don't require it to be of that particular grayscale. Although if an option to customize it was available, it would certainly be a plus.

However, there is a sort of limit. The timespan I want to cover consists of 150 years: from 1790 to 1940, and all of the packages I tried went over the page limit, even using the landscape option.

Update: I thank everyone for the help provided, the solutions look nice. But I think my example was a bit misleading. The reason that made me avoid choosing that solution or adopting the tabular one, was that the bars can only start and end at regular points, so if someone was born at "1903", the bars would not be able to indicate such dates in a precise way if we were using a table. I apologize if this undermines the answers, but I needed to point this out.

If this is taken into consideration in your answer but it was just not explicit or if I missed, please let me know.


This type of diagram is called gantt chart. One of the packages for generating those is pgfgantt. It is based on the TikZ graphic library.

Here's an example from the documentation:

gantt chart

Considering the number of years: That's more a design question, isn't it? You just have to choose an appropriate scale.

  • Not a design question, since the problem is not how they appear, but rather a technical question, because they simply don't fit in a A4 paper. If they fit in, I'd just tweak and see what I like most. :) By the way, thanks for the suggestion, I'll check it out. – Alenanno Mar 30 '12 at 19:12
  • @Alenanno Well if you make a 150-column table it's rather clear it won't fit on the page. But a 15-column table should fit :-) – Stephan Lehmke Mar 30 '12 at 19:16
  • Stephan, I was having a look at this, and it looks nice! I'll need to tweak around a bit to know it better, though. Can you see the update in my question? If this can support that solution, it'd be wonderful. But thanks anyway, since this package is still nice and could come in handy in the future! – Alenanno Mar 30 '12 at 22:38
  • Well, the point is you haven't yet told exactly what the actual diagram you want to make should look like. But as I understood the documentation of the pdfgantt package, you can design almost anything with it. It's "only" an extension of the very versatile graphics package tikz for making this kind of chart. – Stephan Lehmke Mar 30 '12 at 22:43

Not sure of existing packages but this gets close:

enter image description here



\hbox to 0pt{\hss\color{black}#1\hss}}

\global\count1 #1\relax
\global\advance\count1 -1790
\global\count3 #2\relax
\global\advance\count3 -#1\relax}%
\hskip0pt plus -.5fill\personbox{#3}\hskip0pt plus.5fill}\crcr}


\person{1810}{1920}{another person}
\person{1870}{1935}{a different person}
\rotatebox{90}{\llap{\smash{\ \ 1790}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1800}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1810}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1820}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1830}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1840}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1850}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1860}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1870}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1880}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1890}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1900}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1910}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1920}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1930}}}&&&&&&&&&&
\rotatebox{90}{\llap{\smash{\ \ 1940}}}
  • Thanks, this one looks nice! I have two side questions: 1) Can I change the kind of highlighting? I'm thinking about when I should print this one... :D 2) If possible, how do I rotate the dates below in order to be shown horizontally? Thank you! – Alenanno Mar 30 '12 at 20:55
  • well you can change anything, I just picked a light grey rule but you could change that, to not rotate the dates just don't have \rotatebox (but you'd need a smaller font to make them fit) – David Carlisle Mar 30 '12 at 21:18
  • The package is lscape? I'm asking so I can check the documentation. Although I doubt I'm going to understand something about it. By the way, now that I notice... it's a tabular? – Alenanno Mar 30 '12 at 21:51
  • 2
    Not sure what you mean. My solution has 150 1.7mm wide columns and the bars start and end in exactly the right column. the last row puts a label every 10 columns, you could label more of the columns, or all of them, but you'd need to work out some way of making the labels fit – David Carlisle Mar 30 '12 at 22:43
  • 1
    I upvoted your answer so you're closer to egreg. :D – Alenanno Oct 5 '12 at 20:14

use a simple tabular:


\begin{tabular}{| *5c | *5c |}                    \hline
 & & & \MC{3}{a person} & & & &                   \\\hline
 & \MC{4}{another person} & & & & &               \\\hline
 & & & & & & & \MC{3}{yet another person}         \\\hline
 & & & & \MC{4}{wow, another person again} & &    \\\hline
1965 & 1970 & 1975 & 1980 & 1985 & 1990 & 1995 & 2000 & 2005 & 2010\\\hline


enter image description here

  • That is how I made the example in my question, actually, but I wanted to know if there was a "better" way. :D – Alenanno Mar 30 '12 at 20:25
  • 5
    then yiu should have mentioned it ... – user2478 Mar 30 '12 at 20:48
  • I didn't think about mentioning it. :) – Alenanno Mar 30 '12 at 20:55
  • Herbert, see the update in my question about the table choice. – Alenanno Mar 30 '12 at 22:35

I'd like to provide my own answer to my question, because I actually found another way for this problem: TiKZ. I'm not sure what is the first thing that prompted me to use this package (if you think I might have took something from one of your answers, please let me know so I could attribute any external help), but I'm sure I used Box and Whisker plot from texample.net/tikz. The output is this one:

box and whisker plot

It's perfect for a timeline, but it needs some changes and from now on, I'll explain my changes and some adds to make it work. A note: There are certainly better ways to do some things I'm going to explain, if you find one, feel free to comment.

Also, this answer is going to be very long.

Setting up

First let's delete everything we don't need and let's keep the line below. If you typeset now, you'll get a line above. It's ok, we'll fill everything soon. I chose landscape but this depends on your timeline: does it consist of many years with a few events? Or only a few years with a lot of events?


\usepackage[a4paper, margin=1cm, landscape]{geometry}



       %draw horizontal line   
         \draw (0,0) -- (12,0);

       %draw vertical lines
         \foreach \x in {0,1,2,...,12}
           \draw (\x cm,3pt) -- (\x cm,-3pt);



Drawing the dates

Note: the previous solution for this has been proven to be somewhat tedious to do, but thanks to Torbjørn T.'s help, here is a fix (automatized):

\foreach \x [evaluate=\x as \year using int(1900+\x*10)] in {0,1,...,12}{ 

    \draw (\x,0) node[below=7pt,anchor=east,xshift=5pt,rotate=45] {$\year$}; 
    \draw (\x cm,3pt) -- (\x cm,-3pt);}

I think the simplest/best approach is to jump every 10 years. Why? Because if we set every ten years, it will be easier to set a date. For example: if the point 5 is 1950 and 6 is 1960, then 5.5 will be 1955! It's simple, right? The number perfectly correspond to dates. While if we just every 5 years, 5 will be 1950 and 6 = 1955, so 1953 will be 5.6... Not very intuitive.

Stretching the line

If you want the line to cover all of your page, after \being{tikzpicture}, add [x=2cm], for example:

stretching the line screenshot

Inserting data

There are two main ways to insert data. Let's retake the first screenshot:

box and whisker plot

One is the box with the content inside, the other one is the line. I'll take inspiration from the image in the question but change something, then post the code:

inserting data

Add this code after the date \foreach:

         \filldraw[fill=white] (5.5, 10) rectangle (9.5, 9) 
              node[midway, align=center, text width=7cm]{a person};

         \filldraw[fill=white] (6, 9) rectangle (12, 8) 
              node[midway, align=center, text width=7cm]{another person};

        \filldraw[fill=white] (1, 8) rectangle (5, 7) 
             node[midway, align=center, text width=7cm]{yet another person};

        \filldraw[fill=white] (3, 7) rectangle (7, 6) 
             node[midway, align=center, text width=7cm]{wow, another person again};

        \draw[|-|] (4.4, 4) -- (7.4, 4) node[midway, above, align=center, text width=7cm]{Event};

        \node[below] at (4.4,4) {\textsc{Start}};% label the hinge
        \node[below] at (7.4,4) {\textsc{End}};% label the hinge

        \draw[|-|] (0.8, 2) -- (0.9, 2) node[midway, above, align=center, text width=7cm]{Event};

A little explanation:

  • \filldraw[fill=white] creates a shape filled with white, (5.5, 10) rectangle (9.5, 9) decides what shape it is and it tells the coordinates in this order: (left, top) ... (right, bottom). So if you want to add more content in it, just make it taller, by writing (5.5, 12) rectangle (9.5, 8), for example.

  • node[midway, align=center, text width=7cm] is important. midway puts the text at the center, along with align, and text width makes it fit into the rectangle, otherwise it will go out of it.

  • \draw[|-|] (4.4, 4) -- (7.4, 4) draws a line from 4.4 to 7.4, at the 4th level. The [|-|] decides that style are the hinges, they could be arrows: [<->].

  • \node[below] at (4.4,4) {\textsc{Start}};% label the hinge, well, it's clear. The [below] can be changed to right or left, or above, of course.

Since this is a TiKZ picture, you can add arrows between rectangles, etc.

  • If you find any mistakes, please let me know! – Alenanno May 9 '12 at 11:15
  • 2
    Well the pgfgantt package I pointed to is based on TikZ and provides roughly the functionality you now re-engineered yourself :-) – Stephan Lehmke May 9 '12 at 11:37
  • 1
    Would it work to use something like \foreach \x [evaluate=\x as \year using int(1900+\x*10)] in {0,1,...,12} \draw (\x,0) node[below=7pt,anchor=east,xshift=5pt,rotate=45] {$\year$}; to draw the dates? – Torbjørn T. May 9 '12 at 11:41
  • @TorbjørnT. I'll give it a try later. Have you tried it? – Alenanno May 9 '12 at 12:04
  • @StephanLehmke It's a bit different though. At that time I tried it, but it didn't seem to be the best choice, although I liked the package itself! – Alenanno May 9 '12 at 12:05

If the output is only going to be viewed with a pdf reader then you can use the geometry package to create a very large virtual page. I choose 11 in high by 100in wide (226in is the max from I suspect a TeX dimension limit)

This makes nice timelines and if you have a plotter or a printer that can subdivide large pages you could get it printed. I used the slides class and \Huge just so you could see it work with a normal pdf view. With 12 pt characters I would get about 2700 characters per line.

\usepackage[paperwidth=100in, paperheight=11in,margin=1in]{geometry}
  • Actually I'd need to print this later, but thanks for your help! :) – Alenanno Mar 30 '12 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.