TiKZ decoration doesn't work

I am trying to get TikZ decorations to work, but so far without success. In this minimal example, I am trying to compile an example found in pgfmanual.pdf in section 20.2:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{decorations}

\begin{document}
\begin{tikzpicture}
\draw decorate [decoration=zigzag] {(0,0) -- (2,2)};
\end{tikzpicture}
\end{document}


I always get this error

"! Package pgfkeys Error: I do not know the key '/pgf/decoration/crosses'
and I am going to ignore it. Perhaps you misspelled it."


What is the problem?

• The section 20.2 is called Specifying a Uniform Opacity in the current version of PGF (2.10) and has nothing to do with decorations but transparency. I assume you have an older version. Some LaTeX distributions (e.g. Ubuntu TeXLive) don't update the packages often. It would be much better to state the section title instead. – Martin Scharrer May 17 '11 at 17:09
• Found it. In v2.10 it is section 21.2, named Decorating a Subpath Using the Decorate Path Command. – Martin Scharrer May 17 '11 at 17:17
• @Jake: There was no reason to delete your answer. I wrote my one in my editor to test it and didn't reload the page before posting mine, so I didn't saw yours. It's OK to have similar answers around. Just let the people decide which one to up-vote. I hope I didn't bullied you or something ;-) – Martin Scharrer May 17 '11 at 17:26
• General advice on the TikZ/PGF manual section numbering problem, include the name of the subsection and the version of TikZ/PGF that you're using. – Andrew Stacey May 17 '11 at 18:20
• I think the wrong error message was quoted. Shouldn't it be /pgf/decoration/zigzag?.Anyway: /pgf/decoration/crosses belongs to \usetikzlibrary{decorations.shapes} just in case someone else comes from google. – someonr Jan 2 '14 at 15:35

You need to also load the (sub-)library for the particular decoration (decorations.pathmorphing for zigzag). See also section 51 Decoration Library for more information (using PGF 3.1.5b, the section number can be different for other versions).

One issue with the otherwise great pgfmanual is, that it is hard to know which libraries are required for the examples.

\documentclass{article}

\usepackage{tikz}
%\usetikzlibrary{decorations}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzpicture}
\draw decorate [decoration={zigzag}] {(0,0) -- (2,2)};
\end{tikzpicture}
\end{document}

• Thank you! I agree with you upon required libraries being not very well documented. I will keep the changing section numbers in mind. – Turion May 17 '11 at 17:20