3

I need to generate several frames which each contain an image. I was thinking of looping with \ foreach but it doesn't work

\foreach \nn in{1,2,...,5}{
\begin{frame}[fragile]{}
\includegraphics[width=0.8\textwidth]{cata-\nn.jpg}
\end{frame}
}
4

This works

\documentclass{beamer}
\usepackage{pgffor}
\begin{document}
\foreach \nn in{a,b,c,duck}{
\begin{frame}
\frametitle{Image \nn}
\centering
\includegraphics[width=0.8\textwidth]{example-image-\nn}
\end{frame}
}
\end{document}

enter image description here

2
  • Does not work with the fragile option... May 20 '20 at 6:16
  • @PaulGaborit Yes, that is correct. But one does not need fragile to "generate several frames which each contain an image".
    – user194703
    May 20 '20 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.