In my presentation, I want to successively highlight different parts of my image using the TikZ spy library. Due to size constraints, the actual highlight is outside of the included image. Therefore, I use beamers overprint environment with onslide. This works fine for \node, but I cannot get it to work for \spy.

Below is a minimal, not working, example. I described the problems in the comments.

\begin{tikzpicture}[spy using outlines={circle, blue, magnification=6, connect spies}]
% bluemarble from http://en.wikipedia.org/wiki/File:Apollo17WorldReversed.jpg
\node<1-> (image) at (0,0) {\includegraphics[width=6cm]{bluemarble}};
% this one compiles, but image jumps around
% \only<2->{\spy [size=3cm] on (1,1) in node at (4, 4);}
% this one fails to compile with: ! Extra }, or forgotten \endgroup.
% \onslide<2->\spy [size=3cm] on (1,1) in node at (4, 4);
% this one fails to compile with:
% Runaway argument?
% ]<2-> [size=3cm] on (1,1) in node at (4, 4); \end {tikzpicture} \end \ETC.
% ! Paragraph ended before \tikz@lib@spy@parse@opta was complete.
\spy<2-> [size=3cm] on (1,1) in node at (4, 4);
% these compile, but 'spy' is on every slide
% \onslide<2->{\spy [size=3cm] on (1,1) in node at (4, 4);}
% \uncover<2->{\spy [size=3cm] on (1,1) in node at (4, 4);}

The beamer user guide, section 6.3.1., Making Commands and Environments Overlay Specification-Aware, but I'm not sure how to apply this \renewcommand<> thing to \spy to make it overlay-specification aware, since \spy does not look like an "ordinary" command as I would create with (re)newcommand.

How can I use \spy without my image "jumping around", e.g. with a (preferably automatically calculated) bounding box remaining constant for the different slides?

  • I did find a workaround by adding an invisible node in an earlier slide, just to force the tikzpicture to have the same bounding box. But I'd like a more robust solution. – gerrit Dec 1 '11 at 16:24

You could try making the node an overlay: \only<2->{\spy [size=3cm] on (1,1) in node[overlay] at (4, 4);} Then you don't need the overprint environment at all. An overlay node means it is not added to the bounding box.

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.