[Tex/LaTex] TikZ+beamer, referencing node outside current picture, inside overprint environment

beamertikz-pgf

In beamer, when I try to reference a node outside the current picture but inside an overprint-environment, like this,

\documentclass[12pt]{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\begin{overprint}
\begin{tikzpicture}[remember picture]
 \node<1->[draw] (xxx) at (0,0) {Spam};
 \node<2->[draw] (yyy) at (1, 1) {Eggs};
\end{tikzpicture}
Some text, tra la la.
\tikz<2>[remember picture] \draw[overlay,->] (xxx.north) -- (yyy.south);
\end{overprint}
\end{frame}
\end{document}

and compiling with pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011), using beamer 2011/09/12 development version 3.12, tikz 2010/10/13 v2.10 (rcs-revision 1.76), I receive the following error message:

! Package pgf Error: No shape named yyy is known.

My questions:

  • Is it possible to refer to a node inside an overprint-environment?
  • If yes, how?
  • If no, is this a fundamental limitation, or a limitation to the current implementation?
  • Why is this?

Related but different questions:

Best Answer

The problem with your code is that the \tikz command itself is not overlay-aware. (I think that it would be quite difficult to make it so.) So the \tikz stuff is getting executed on every slide, but the yyy node doesn't exist until the second slide so it doesn't know what to do with it. If you shift the <2> to the \draw instead then it works.

\documentclass[12pt]{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}
\begin{overprint}
\begin{tikzpicture}[remember picture]
 \node<1->[draw] (xxx) at (0,0) {Spam};
 \node<2->[draw] (yyy) at (1, 1) {Eggs};
\end{tikzpicture}
Some text, tra la la.
\tikz[remember picture] \draw<2>[overlay,->] (xxx.north) -- (yyy.south);
\end{overprint}
\end{frame}
\end{document}