24

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.

1
  • 3
    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.) – Andrew Stacey Jan 16 '11 at 21:54
23

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

3
  • 9
    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
  • 1
    How can that be marked as a solution and even have so many votes?? This is not an answer, it is barely correct English. If this sequence of words is somehow answering the problem, can please somebody, based on that, give an actual answer that solves the problem? At the moment it hardly qualifies as such, I'd say. – Prof.Chaos Feb 4 at 0:20
  • As stated above and below. This here is not the solution. The actual solution is given below consisting of adding an additional pair of curled brackets to resolve the compilation error. – Prof.Chaos Feb 4 at 0:28
27

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.

1
  • 1
    This here is actually the solution to the problem, not the one above. To emphasize, because for some reason this was not explicitly stated here: The solution consists of adding an additional pair or curled parentheses into the node. Only then the compilation error is resolved and visible/uncover/onslide can be used as intended. – Prof.Chaos Feb 4 at 0:27
19

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.