# Beamer vs. TikZ: uncover nodes step-by-step

I'm trying to uncover a TikZ image piece-by-piece like so:

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{frame}{Linearity}
\begin{center}
\begin{tikzpicture}
\node (Ctx) {\visible<2->{$\Gamma$}};
\node[below right=0.5cm and 0.1cm of Ctx] (E) {$E$};
\node[below right=0.5cm and 0.1cm of E] (psi1) {\visible<3->{$\Psi_1$}};
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}


However, this gives the following error message:

! Package tikz Error: Giving up on this path. Did you forget a semicolon?.

See the tikz package documentation for explanation.
Type  H <return>  for immediate help.
...

l.16 \end{frame}


If I use \only instead of \visible, pdflatex runs OK but the output jumps around when going from slide to slide, since the invisible nodes don't take up space and thus the E node's position changes. So \visible is what I need.

-
I don't know why (which is why I'm leaving this as a comment rather than an answer), but adding another layer of grouping fixes it for me, namely {{\visible<2->{$\Gamma$}}} (and similarly for the other node). (An alternative strategy is to lay out coordinates to get the positioning right then to "hang" the nodes on the relevant spots afterwards; these nodes can safely be switched on and off via \node<2-> etc since they no longer play a part in the positioning.) –  Loop Space Jan 16 '11 at 21:54

In the one case I overlayed TikZ I was using \uncover<n-m>{ELEMENT} in order to show ELEMENT in slides n to m.

-
Just remember to put the semicolon for ELEMENT inside the curly braces when using TikZ. That was a frustrating 2 minutes... –  qubyte Dec 19 '11 at 6:57

Here is another solution using \setbeamercovered{invisible} and \pause

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{frame}{Linearity}
\setbeamercovered{invisible}
\begin{center}
\begin{tikzpicture}
\node(Ctx){$E$};\pause
\node[above left=0.5cm and 0.1cm of Ctx] (gamma) {$\Gamma$};\pause
\node[below right=0.5cm and 0.1cm of Ctx] (psi1){$\Psi_1$};\pause
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}


This can also be contained in \columns where one can have tables, minipages or other nodes to explain what is going on in a diagram using \onslide<n->. I use this frequently to simultaneously expose a geometric diagram and a two-column proof. Hope it is of interest.

-

It works if you place the \visible command and its arguments into a { } group:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{frame}{Linearity}
\begin{center}
\begin{tikzpicture}
\node (Ctx) {{\visible<2->{$\Gamma$}}};
\node[below right=0.5cm and 0.1cm of Ctx] (E) {$E$};
\node[below right=0.5cm and 0.1cm of E] (psi1) {{\visible<3->{$\Psi_1$}}};
\end{tikzpicture}
\end{center}
\end{frame}
\end{document}


It seems that the scanning code from \visible removes the ; or otherwise interferes with the \node code. Note that \node doesn't read its content as argument but as box content to allow verbatim inside. The \visible macro might do the same and therefore such errors can happen.

-
Welcome to tex.sx! A tip: you can use backticks ` to mark your code as I did in my edit. –  Hendrik Vogt Jan 17 '11 at 17:54