Vertically aligning images in beamer
Using floating environments (such as figure
or table
) in a frame does not work in the way it should. To accomplish your objective, turn on allowpagebreak
and T
. Adjust the graphics with height
option. See the code below for the remaining.
\documentclass{beamer}
\usepackage{graphicx}
\begin{document}
\frame[allowpagebreak,T]
{%
\only<1>
{%
\centering
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image-a}
\vfill
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image-a}
}%
\only<2>
{%
\centering
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image-b}
\vfill
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image-b}
}%
\only<3>
{%
\centering
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image-c}
\vfill
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image-c}
}%
\only<4>
{%
\centering
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image}
\vfill
\includegraphics[height=\dimexpr0.5\textheight-0.5in]{example-image}
}%
}
\end{document}
For creating GIF animation see my other answer here.
Instead of \vspace
, you can use \\
to force a line break.
\documentclass{beamer}
\begin{document}
\frame{
\begin{figure}[t!]
\includegraphics<1>[scale=.5]{img} \\
\includegraphics<1>[scale=.5]{img}
\includegraphics<2>[scale=.5]{img} \\
\includegraphics<2>[scale=.5]{img}
\includegraphics<3>[scale=.5]{img} \\
\includegraphics<3>[scale=.5]{img}
\includegraphics<4>[scale=.5]{img} \\
\includegraphics<4>[scale=.5]{img}
\end{figure}
}
\end{document}
If you only have one line break in total instead of one for every image pair, your problem should disappear. The point is that your \vspace{.1in}
commanded is not masked by the <1>
,<2>
,<3>
, or <4>
:
\documentclass{beamer}
\begin{document}
\frame{
\begin{figure}[t!]
\includegraphics<1>[scale=.5]{fig/imageA1}
\includegraphics<2>[scale=.5]{fig/imageA2}
\includegraphics<3>[scale=.5]{fig/imageA3}
\includegraphics<4>[scale=.5]{fig/imageA4}
\vspace{.1in}
\includegraphics<1>[scale=.5]{fig/imageB1}
\includegraphics<2>[scale=.5]{fig/imageB2}
\includegraphics<3>[scale=.5]{fig/imageB3}
\includegraphics<4>[scale=.5]{fig/imageB4}
\end{figure}
}
\end{document}