Automatically include a sequence of images
Here is an option using multido
:
\documentclass{beamer}
\usepackage{multido}
\begin{document}
\multido{\i=1+1}{9}{%
\begin{frame}
\frametitle{Title: \i}
\framesubtitle{Subtitle: \i}
\centering
\includegraphics[width=.9\linewidth]{example-image-\i}
\end{frame}
}
\end{document}
The syntax is \multido{<var>=<start>+<inc>}{<times}{<stuff>}
which defines <var>
to be <start>
, incremented by <inc>
a total of <times>-1
times (since the first value counts as an iteration), and with each iteration it executes <stuff>
. The special \i
-notation means that <var>
will be an i
nteger.
The above example assumes minimal changes from one element to the next. If, for example, you have varied content for the frame title, subtitle and any additional comments on a per-photo basis, then using a list-like approach would be far better. For than, any of the techniques mentioned in How to iterate over a comma separated list? would be helpful.
I have a tex file that I wrote to produce a display of photos that does something like this. For me the goal is to arrange a changing collection of photos on a grid covering the page. I use tikz
to both loop over the photos, that are stored as a comma separated list of image filenames, and to place the photos.
As you are talking about generating the list of filenames via python you could easily populate a variable list like the one used below.
Here is a cut down version:
\documentclass{article}
\usepackage{mwe}
\usepackage{graphicx}
\usepackage{tikz}
\def\MyImages{example-image-a,example-image-b,example-image-c}% list of images
\begin{document}
\newdimen\X
\begin{tikzpicture}[overlay,
picture/.style={draw,rectangle,anchor=#1,inner sep=0pt,outer sep=0pt}
]
\X=0mm
\foreach \Image in \MyImages {
\node[picture=north west] at (\X,-101.5mm)
{\includegraphics[width=49.5mm,height=35mm]{\Image}};
\global\advance\X by 49.5mm
}
\end{tikzpicture}
\end{document}
This produces: