# Showing step by step using images in single frame

I would like to show an series of images in a step-by-step manner (PowerPoint like) in Beamer. Currently, I just create a series of frames with one image for each:

\begin{frame}
\frametitle{Main Title}
\framesubtitle{Subtitle}
\centering
\includegraphics[width=.8\textwidth]{figures/image1.pdf} \\
\end{frame}
\begin{frame}
\frametitle{Title}
\framesubtitle{Subtitle}
\centering
\includegraphics[width=.8\textwidth]{figures/image2.pdf} \\
\end{frame}


I read that there is a way to layer text e.g. alert highlights by using \altert<2>{This is important!}. I tried to use this code to follow this example, without success:

\begin{frame}
\frametitle{Title}
\framesubtitle{Subtitle}
\centering
\includegraphics<1>[width=.8\textwidth]{figures/image1} \\
\includegraphics<2>[width=.8\textwidth]{figures/image2} \\
\end{frame}


Is there a better way? This can mean a lot less code with 5+ images in a sequence. This also has the advantage that the handout would only have the last one in and not the entire progress --- saving me a lot of slides that students would not need to print. Any ideas?

It's possible to loop over the images of course, for example, with \foreach from pgffor.

\documentclass[draft]{beamer}

\usepackage{pgffor}

\begin{document}

\begin{frame}
\frametitle{Title}
\framesubtitle{Subtitle}
\centering
\foreach \x in {1,...,5} {%
\includegraphics<\x>[scale=0.5]{a_\x.jpg}%
}
\end{frame}
\end{document}


• Great solution. I now found that my earlier complainted about <1> did actually work, but this is far better with more flexiblity... Tnx! – RalfB Sep 18 '15 at 9:25

It is intentionally copied from Christian Hupfer's answer but with a little bit modification. Community wiki is enabled to compensate the copyright issue.

\documentclass{beamer}
\usepackage{pgffor}
\begin{document}
\begin{frame}
\frametitle{Title}
\framesubtitle{Subtitle}
\centering
\foreach \x/\y in {1/a,2/b,3/c} {\includegraphics<\x>[scale=0.5]{example-image-\y}}
\end{frame}
\end{document}


• cool. I will put it in my collection of tips and tricks :) – RalfB Sep 18 '15 at 9:26