5

Possible Duplicate:
How can I fix jumping TikZ pictures in beamer?

I am putting together a series of slides using beamer, and I'm using tike to do most of the figures. On one particular slide, I need to make nodes appear, then some more nodes, then edges between them. The code looks like this:

\begin{tikzpicture}[>=latex,text height=1.5ex,text depth=0.25ex]
    \draw[help lines] (0,0) grid (10.5,7.5);
    \tikzstyle{every node}=[draw,minimum size = .4cm,circle,draw=none,fill=red!30!white]    
    \tikzstyle{every path}=[solid,thick]
    %% First species
    \draw (3.7,2.2) node (a) {};
    \draw (9.6,1.4) node (b) {};
    \draw (6.6,6.6) node (c) {};
    %% Second species
    \draw <2-> (0.4,4.0) node [fill=blue!30!white] (d) {};
    \draw <2-> (4.4,3.6) node [fill=blue!30!white] (e) {};
    \draw <2-> (8.0,3.4) node [fill=blue!30!white] (f) {};
    %% Third species
    \draw <3-> (1.3,5.2) node [fill=green!30!white] (g) {};
    \draw <3-> (4.5,6.4) node [fill=green!30!white] (h) {};
    \draw <3-> (3.8,0.45) node [fill=green!30!white] (i) {};
    %% Arrows
    \path <4> [<->] (g) edge [bend right] (d);
    \path <4> [<->] (g) edge [bend left] (e);
    \path <4> [<->] (h) edge [bend left] (c);
    \path <4> [<->] (e) edge [bend left] (a);
    \path <4> [<->] (i) edge [bend left] (a);
    \path <4> [<->] (i) edge [bend right] (f);
    \path <4> [<->] (b) edge [bend right] (f);
    \path <4> [<->] (e) edge [bend left] (f);
    \path <4> [<->] (e) edge [bend right] (h);
    \path <4> [<->] (f) edge [bend right] (c);
\end{tikzpicture}

My problem is that, when I remove the help lines, the figure changes positions on the slide between each transition, which is really not what I expected. I found a quick-and-dirty way to fix the problem with draw=none for the help line, but if anyone here ran into the same problem, I'd like to know a way towards a solution.

1
  • Please make sure to post complete compilable examples, starting from \documentclass. That makes it easier for others to try out your code.
    – Jake
    Commented Jun 26, 2012 at 14:27

1 Answer 1

3

TikZ tries to find the minimum sized rectangle that covers the picture. Beamer in turn runs the TikZ picture at each slide to give the overlay effect. So when the nodes are not visible in the first picture tikz shrinks down the bounding box of the picture to the first 3 nodes. That's why you have such jumps.

The easiest fix is, as you have found out, not drawing the lines or adding a fixed bounding box with

\path[use as bounding box] (0,0) rectangle(10.5,7.5);

at the start such that tikz don't change the bounding box. Or use the solution given in How can I fix jumping TikZ pictures in beamer?

1
  • Thanks, works like a charm! And sorry for missing the duplicate. Commented Jun 26, 2012 at 16:16

Not the answer you're looking for? Browse other questions tagged .