When looking for different packages of creating timelines, I came across the following one:
\documentclass[12pt]{article}
\usepackage[a4paper]{geometry}
\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}
When typesetting, we get this:
But although the code says \usepackage{tikz}
, there is not a package with this name. According to the CTAN site, there is a macro package called pgf that «comes with a user-friendly syntax layer called TikZ.»
I have checked the pgf documentation, of course, but there doesn't seem to be a section related to the code I posted above. There are many options (some are very nice too), but nothing like what I'm searching. Am I missing something? I'd like to know what can I do beyond what that code offers (if there is something, of course).
Also: what is TikZPicture? Is this what I should be looking for? I'm quite confused at the moment.
Best Answer
pgf
is a huge toolbox for graphics in TeX.tikz
is something built on top of that, with much user-friendlier syntax. Most people usetikz
and notpgf
; the manual fortikz
(andpgf
at the same time) is calledpgfmanual
, which might be confusing.tikzpicture
is a LaTeX environment defined bytikz
.The code you mentioned uses
tikz
; I'd recommend you to read chapters/sections 1 (basic ideas), 2 (the first tutorial, with examples of (among others) lines and nodes), 15.10 (decorations) and 56 (\foreach
) ofpgfmanual
. Notice also that "snakes" were replaced by "decorations" in newer versions oftikz
.