# Novice's question: I don't want other objects' locations to move when I add a circle

TikZ novice, here. I want to create two slides (in Beamer), identical except for the addition of a circle in the second slide. I don't want the addition of the circle to shift about the placement of the other objects on the page, which is what currently happens. Suggestions?

\documentclass[xcolor=svgnames, professionalfonts,12pt]{beamer}
\usepackage{amsmath}
\usepackage{pgfpages}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds,arrows}
\usepackage{graphics}

\begin{document}

\frame{
\begin{figure}

\begin{tikzpicture}[scale=1]

\draw (8,1) circle [radius=1.081];

\draw[fill] (15.5,0) circle [radius=0.05];

\draw (8,-2) circle [radius=1.08];

\end{tikzpicture}
\end{figure}
}

\frame{
\begin{figure}

\begin{tikzpicture}[scale=1]

\draw (8,1) circle [radius=1.081];

\draw[fill] (15.5,0) circle [radius=0.05];

\draw (8,-2) circle [radius=1.08];

\draw[dashed] (15.5,0) circle [radius=7.515];

\end{tikzpicture}

\end{figure}
}

\end{document}


Another way is to draw the bigger circle in a scope with the option overlay. From the TikZ/PGF manual:

The effect of [overlay] is that everything within the current scope is not taken into consideration when the bounding box of the current picture is computed.

## Edit:

If the other contents of the two slides are the same, you can simplify your code by using the Beamer overlay specification (unfortunately, the Beamer overlay is different from the TikZ overlay): simply add a Beamer overlay specification <2-> to the \draw command of the bigger circle (this means that the bigger circle will only be shown from the second slide onwards)

One more note: it's not necessary to load the graphics package, because TikZ automatically loads graphicx

\documentclass[xcolor=svgnames, professionalfonts,12pt]{beamer}
\usepackage{amsmath}
\usepackage{pgfpages}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds,arrows}

\begin{document}

\frame{

\begin{tikzpicture}[scale=1]

\draw (8,1) circle [radius=1.081];

\draw[fill] (15.5,0) circle [radius=0.05];

\draw (8,-2) circle [radius=1.08];

\begin{scope}[overlay]
\draw<2->[dashed] (15.5,0) circle [radius=7.515];
\end{scope}

\end{tikzpicture}
}

\end{document}


• This is a more elegant solution than mine. – Alan Munn Apr 17 '13 at 16:30

The problem is that tikz automatically adjusts the bounding box of each picture to the coordinates used in that picture. When you add the large circle, you change the bounding box for that picture. But you can use any particular \draw command as the bounding box, so you should add that to use the smaller circles to define the bounding box for both images.

I removed the figure environment from your code on the assumption that it is inappropriate to use in beamer generally, since it is a floating environment, and you don't want material to float in a presentation. However, as Gonzalo notes in the comments, it is actually ok to leave such floating environments in a presentation especially if you are also using the same beamer code to produce an article version of your presentation. It will also allow you to use captions. Beamer deactivates the floating property in presentation mode. If that's not your intention, however, there's really no need to use floats in a presentation.

Please note that I consider KevinC's answer the more appropriate answer in this particular situation, since it uses beamer methods, and is independent of the code inside the tikzpicture.

\documentclass[xcolor=svgnames, professionalfonts,12pt]{beamer}
\usepackage{amsmath}
\usepackage{pgfpages}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds,arrows}
\usepackage{graphics}

\begin{document}
\frame{
\begin{tikzpicture}[scale=1]

\draw[use as bounding box](8,1) circle [radius=1.081];
\draw[fill] (15.5,0) circle [radius=0.05];
\draw[] (8,-2) circle [radius=1.08];

\end{tikzpicture}
}
\frame{
\begin{tikzpicture}
\draw[use as bounding box] (8,1) circle [radius=1.081];
\draw[fill] (15.5,0) circle [radius=0.05];
\draw[] (8,-2) circle [radius=1.08];

\draw[dashed] (15.5,0) circle [radius=7.515];
\end{tikzpicture}
}
\end{document}


• Thank you both @AlanMunn and Kevin C. These are both very helpful! – Thomas Apr 17 '13 at 16:20
• Is it necessary to load graphics too? I think TikZ automatically loads graphicx – Herr K. Apr 17 '13 at 16:23
• @KevinC No, you're right, it's not necessary (although harmless, since graphicx loads graphics itself). – Alan Munn Apr 17 '13 at 16:29
• @GonzaloMedina Clearly my beamer knowledge is deficient. :) I see that the use of figure in a presentation is also useful for including true floats in article mode. – Alan Munn Apr 17 '13 at 17:10
• @AlanMunn yes, that's perhaps the most useful feature of allowing figure and table in presentations. – Gonzalo Medina Apr 17 '13 at 17:12