4
\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{pgf,tikz}
\usepackage{tikz}
\begin{document}

\frame{
\usetikzlibrary{decorations.pathmorphing}
\tikzstyle{kringel}=[decoration={random steps}]
\begin{tikzpicture}
 \draw[black] (3,2.5) decorate [kringel] {-- (2,5)};
\end{tikzpicture}

%\uncover<2->{test}
}
\end{document}

Compiles without any problems. If I replace

%\uncover<2->{test}

with

\uncover<2->{test}

then it does not compile and gives the following error:

./test.tex:18: Package tikz Error: You need to load a decoration library.

If I move the two lines

\usetikzlibrary{decorations.pathmorphing}
\tikzstyle{kringel}=[decoration={random steps}]

into the document header, i.e., before

\begin{document}

then it compiles and works. Can someone explain to me what is happening here?

4
  • 1
    You must call \usetikzlibrary in your preamble. Commented Nov 7, 2014 at 12:47
  • 1
    Move the usetikzlibrary out and place before \begin{document}
    – Jesse
    Commented Nov 7, 2014 at 12:47
  • @PaulGaborit This is what I found out. But do you have an explanation for why this problem only appears when I insert this uncover command?
    – Arne
    Commented Nov 8, 2014 at 10:49
  • This is almost a duplicate (but not really so reviewers please don't vote) to this one tex.stackexchange.com/questions/111146/…
    – percusse
    Commented Nov 9, 2014 at 13:59

1 Answer 1

4

What it boils down to in the very end is that you probably shouldn't try to use \usetikzlibrary in a group.

With a bit of paring down, the error already occurs in

\documentclass{article}
\usepackage{pgf,tikz}
\begin{document}

\begingroup
\usetikzlibrary{decorations.pathmorphing}
\endgroup

\tikzstyle{kringel}=[decoration={random steps}]
\begin{tikzpicture}
 \draw[black] (3,2.5) decorate [kringel] {-- (2,5)};
\end{tikzpicture}

\end{document}

As soon as you have more than one overlay in a frame, as by using a <2->, the whole frame is parsed several times, throwing away the stuff that is not applicable to the current overlay. Every iteration is done in a group, to limit side effects seeping out. It now appears (I've not gone down that rabbithole) that \usetikzlibrary is clever enough to not load anything twice. So your library is loaded for overlay <1>, not loaded for overlay <2>, but its definitions aren't there because they weren't global.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .