# Beamer \pause with TikZ

Is there a way to introduce parts of a tikzpicture with \pause or similar in Beamer without resorting to incrementally redrawing the tikzpicture over multiple frames?

Intercalating TikZ draw commands with \pause commands creates new frames, but introduces (or in my case, using \setbeamercovered{highly dynamic}, fades in) the entire tikzpicture, which sort of makes sense, as the interior of a tikzpicture is not the normal environment for \pause commands.

-
Potentially relevant question: tex.stackexchange.com/questions/9094/… –  Aaron Mar 21 '11 at 6:34
Thankyou, John Kitzmiller's example was rather enlightening. –  Richard Terrett Mar 21 '11 at 10:09

The easiest way to do this that I have found is to provide overlay specifications to the elements of the picture. The basic commands, \path, \draw, \node and so forth are all overlay-aware. The one thing to be ware of is that the bounding box might jump around a bit as different parts of the drawing are put in or taken out. However, once you're aware of that then it's easy to fix. Either specify the bounding box at the start (using the \useasboundingbox) or litter your drawing with lots of \coordinates which are there all the time but only use them on specific slides.

Here's a fairly detailed example with the \useasboundingbox technique.

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}
\begin{center}
\begin{tikzpicture}
\useasboundingbox (-5.2,-3.1) rectangle (5.2,3.1);
\fill[gray!25] (-5.2,-3.1) rectangle (-0.2,3.1);
\draw[ultra thick,red] (-5,0) -- (-0.4,0);
\draw[ultra thick] (-2.7,-3) -- (-2.7,3);
\foreach \t in {-1.5,-1.4,...,1.5} {
\pgfmathsetmacro{\l}{abs(\t/1.5)}
\pgfmathsetmacro{\m}{1 - \l}
\definecolor{currentcolor}{rgb}{\l,0,\m}
\draw[color=currentcolor] (-5,\t) -- (-0.4,\t);
};
\foreach \t in {1.6,1.7,...,3} {
\pgfmathsetmacro{\l}{2-abs(\t/1.5)}
\pgfmathsetmacro{\m}{1 - \l}
\definecolor{currentcolor}{rgb}{\l,0,\m}
\draw<.(4)->[color=currentcolor] (-5,\t) -- (-0.4,\t);
\draw<.(4)->[color=currentcolor] (-5,-\t) -- (-0.4,-\t);
};
\fill<.(2)->[gray!25] (5.2,-3.1) rectangle (0.2,3.1);
\draw<.(2)->[ultra thick,red] (5,0) -- (0.4,0);
\draw<.(2)->[ultra thick] (2.7,-3) -- (2.7,3);
\foreach \t in {-2,-1.9,...,2} {
\pgfmathsetmacro{\l}{abs(\t/2)}
\pgfmathsetmacro{\m}{1 - \l}
\pgfmathsetmacro{\x}{2.3*cos(90*\t)};
\pgfmathsetmacro{\y}{2.3*sin(90*\t)};
\definecolor{currentcolor}{rgb}{\l,0,\m}
\draw<.(3)->[color=currentcolor] (2.7,0) -- +(\x,\y);
};

\end{tikzpicture}

\visible<2->{$$z \mapsto e^{z}$$}
\end{center}

\end{frame}
\end{document}


First frame:

Last frame:

(If there's a specific situation that you need help figuring out, either edit the question to include the code or ask a new question about it.)

-
My current method is essentially analogous to yours, except that I'm redrawing the tikzpicture with added material on new frames. I see that the reason why my pause was not working was because I was attempting to uncover an addplot, whereas it works perfectly well for my \draw elements as evinced by John Kitzmiller's example in the question Aaron linked. Anyhow, thanks for the example as \useasboundingbox is useful to me. –  Richard Terrett Mar 21 '11 at 10:08