1

I have a folder containing files fig-0.png, fig-1.png, ... and so on. Since there are many files, to make things convenient is is possible to write some kind of a "for" loop such that beamer makes one image per-slide?

1 Answers1

3

Sure. This will work with your pictures as well, but the other users on this site won't have your pics so I use an example that loads pics that are part of the standard installations.

\documentclass{beamer}
\usepackage{pgffor}
\begin{document}
\foreach \X in {a,...,c,duck}
{\begin{frame}[t]
\frametitle{image \X}
\includegraphics[width=0.95\textwidth]{example-image-\X}
\end{frame}}
\end{document}

enter image description here

  • I just want to add that if the filenames in the list among brackets contain special characters (for instance my_file.png), they should be escaped (my\_file.png) to avoid a mess in the frame title. Fortunately, includegraphics will recognize them without problems. – gibbone Nov 17 '22 at 10:49