GeneralHelp Creating Timelines

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
Bama Gambler
Posts: 13
Joined: Wed Aug 29, 2007 10:58 pm

Help Creating Timelines

Post by Bama Gambler »

Can somebody help me create timelines like this:
Image

I've looked through the PSTricks and tried some stuff with nodes, but I never got anything that looked good and it definitely took too long. I have a bunch of different timelines so I need a lot of flexibility in how many nodes and what I label the nodes (both above and below the timeline).

Image

Thanks in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Help Creating Timelines

Post by gmedina »

The PGF/TikZ package could be useful.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
Bama Gambler
Posts: 13
Joined: Wed Aug 29, 2007 10:58 pm

Help Creating Timelines

Post by Bama Gambler »

Thanks! That is great!

Here is a simple timeline.

Code: Select all

\[ 
\begin{tikzpicture}
 \draw (0,0) -- (2,0);
 \foreach \x/\xtext in {0/0/\ , 1/1/10, 2/2/20}
	\draw (\x cm,3pt) -- (\x cm,-3pt) node[below=3pt] {\x} node[above=6pt] {\xtext};
\end{tikzpicture}
 \]

But when I try to add a snaked line, I get errors. I can't even get this simplest snake line to draw.

Code: Select all

\begin{tikzpicture}
 \draw [->,snake=snake] (0,0) -- (2,0);
\end{tikzpicture}
Attached is the log file. Any ideas?
Attachments
timeline.log
(13.3 KiB) Downloaded 388 times
User avatar
Bama Gambler
Posts: 13
Joined: Wed Aug 29, 2007 10:58 pm

Re: Help Creating Timelines

Post by Bama Gambler »

Never mind. Google to the rescue again. I just needed to add this line of code:
\usetikzlibrary{snakes}
User avatar
Bama Gambler
Posts: 13
Joined: Wed Aug 29, 2007 10:58 pm

Help Creating Timelines

Post by Bama Gambler »

The following code gives me a nice timeline, but can you think of a way to streamline this? Maybe with a command somehow and passing an array for the nodes? I'm not sure if that is even possible.

Code: Select all

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{snakes} 

\begin{document}

\begin{tikzpicture}[snake=zigzag, line before snake = 5mm, line after snake = 5mm]
 %draw horizontal line	
 \draw (0,0) -- (2,0);
 \draw[snake] (2,0) -- (4,0);
 \draw (4,0) -- (5,0);
 \draw[snake] (5,0) -- (7,0);

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

 %draw nodes
 \draw (0,0) node[below=3pt] {$ 0 $} node[above=3pt] {$   $};
 \draw (1,0) node[below=3pt] {$ 1 $} node[above=3pt] {$ 10 $};
 \draw (2,0) node[below=3pt] {$ 2 $} node[above=3pt] {$ 20 $};
 \draw (3,0) node[below=3pt] {$  $} node[above=3pt] {$  $};
 \draw (4,0) node[below=3pt] {$ 5 $} node[above=3pt] {$ 50 $};
 \draw (5,0) node[below=3pt] {$ 6 $} node[above=3pt] {$ 60 $};
 \draw (6,0) node[below=3pt] {$  $} node[above=3pt] {$  $};
 \draw (7,0) node[below=3pt] {$ n $} node[above=3pt] {$ 10n $};
\end{tikzpicture}

\end{document}
User avatar
Bama Gambler
Posts: 13
Joined: Wed Aug 29, 2007 10:58 pm

Re: Help Creating Timelines

Post by Bama Gambler »

Never mind. I built a nice solution in Excel that creates the LaTeX code for me.
Post Reply