[Tex/LaTex] Beamer: Positioning of images using framebreaks

animationsbeamerfloats

I have three pictures that build upon each other, much like a gif (and no I don't want a gif).

I have one frame where I want to show the three pictures one after the other using \framebreak. The idea is to build some simple animation. This requires that all images are positioned in exactly the same location across all three slides. However, when using framebreaks, the first image is positioned slightly lower than the other two. Here is my code:

\begin{frame}[allowframebreaks]
  \frametitle{Blah Blah}
  \begin{figure}
     \includegraphics[scale = 0.8]{Probability1.pdf}
  \end{figure}
  \framebreak
  \begin{figure}
     \includegraphics[scale = 0.8]{Probability2.pdf}
  \end{figure} 
  \framebreak
  \begin{figure}
     \includegraphics[scale = 0.8]{Probability3.pdf}
  \end{figure} 
\end{frame}

I've tried reducing the scale but the first picture is never exactly aligned with the other two. Any advice?

Best Answer

I regularly make step-revealed images using Beamer, and while I use a different method, it seems like you're attempting to do the same thing. First, let me clarify what I believe you're trying to do:

  • Create independent slides that can be progressed through one at a time.
  • Have an identical copy of everything except for the image, which changes on each slide.
  • Have each image taking up the exact same position and space on every slide.

Assuming the above is true, the first thing to point out is that Beamer accepts the optional overlay specification ("which slide to show this on") for graphics:

\includegraphics<n>{STUFF}

By using <n>, you can specify which slide number to show each of your images on. I commonly use code along the lines of

\begin{frame}
\frametitle{Hello, World}
Isn't this image below beautiful?
\center
\includegraphics<1>[width=0.9\textwidth]{Image1}
\includegraphics<2>[width=0.9\textwidth]{Image2}
\includegraphics<3>[width=0.9\textwidth]{Image3}
\flushleft \bigskip
\pause I know you thought that last one was beautiful, but check out this one!
\pause Wowza!
\end{frame}

Using this code would cause each image to appear on its own slide, occupying the same location (Caveat Below). This allows you to flip through the slides one at a time, explaining some sort of logical progression in the images.

(Caveat: While this works great, there will be some spacing issues if your images are not all sized the same. From what you said in your question, I don't think that's an issue, but it's very important to note that you must size all your images the same. [This is normally not an issue for me, since I'm creating a logical progression of images and I just use the same canvas size as I draw out each step when building the graphics.])

It's also useful to note that the \pause command is totally unnecessary in the above code. It can be smoothly integrated with the text to reveal an on-going commentary as you progress through images, but if you just write

\begin{frame}
\includegraphics<1>{Image1}
\includegraphics<2>{Image2}
\end{frame}

Beamer will produce two frames that have each image on their own in the same location (minus possible sizing issues).

You also might be interested in the various other overlay specification commands: \onslide, \only, \uncover, and others. You can find a full list in the Beamer documentation: Beamer User's Guide. In my experience, most "normal commands" will accept the optional overlay specification <n>, which can be very handy.

As for issues with spacing and alignment, I expect they will disappear if you use the above method. If they do not disappear, you might try specifying size in a different way than using [scale = xyz]. Try fixing it precisely with [width=xyz] or [height=xyz] (and make sure you use the same command and size for each image).

Finally, you might want to consider avoiding the \framebreak command entirely. To quote from the Beamer User's Guide: "The use of this option [is] evil." While there are a few circumstances you might need to use it in, you can probably figure out a way to avoid it entirely. Instead, use a combination of \pause and other overlay specifications.

Related Question