I have a 100 images named Image-1.pdf to Image-100.pdf. Is there a way to include all of them in one slide each without having to type out each name in 100 slides and doing \includegraphics on each slide?
- 6,730
- 4
- 28
- 58
- 11
-
Is your problem solved? If yes, then accept an answer (the one that you like most). – Dr. Manuel Kuehner Apr 27 '17 at 20:30
3 Answers
There are many ways to implement loops in LaTeX. One possibility is the pgffor package (see section 83 "Repeating Things: The Foreach Statement" of the tikz documentation):
\documentclass{beamer}
\usepackage{pgffor}
\usepackage{graphicx}
\begin{document}
\begin{frame}
\foreach \i in {1,...,3}{
\includegraphics<+>[width=\linewidth]{img/image-\i}
}
\end{frame}
\end{document}
- 5,981
Beamer comes with a command, which does exactly this: \multiinclude
\documentclass{beamer}
\usepackage{xmpmulti}
\begin{document}
\begin{frame}
\multiinclude[<+->][format=pdf, graphics={width=\textwidth}, start=1]{Image}
\end{frame}
\end{document}
You can even animate the sequence using something like \transduration<0-100>{0.5}.
- 158,329
My way of doing this is a combined effort of the filecontents and csvsimple packages. Within the filecontents environment you just list the images to be used (this is helpful when you have no uniform image name pattern).
\documentclass{beamer}
\usepackage{filecontents,csvsimple}
\begin{document}
\graphicspath{{<insert/path/to/image/folder>}}
\begin{filecontents*}{imagelist.txt}
Image-1
Image-2
Image-3
\end{filecontents*}
\frame{\csvreader[no head]{imagelist.txt}{}{\centering\only<+>{\includegraphics{\csvcoli}}}}
\end{document}
Note below (and not part of the original question): if you need automatic portrait/landscape selection of the included images, you might want to look at Dedicated pages for figures featuring automatic fit-to-page scaling and automatic portrait/landscape selection
- 4,021
-
-
@samcarter Thank you, I wasn't aware of that. I've edited my answer accordingly. – Harry Apr 26 '17 at 15:54
-
You can simplify it even more if you use
\includegraphics<+>{\csvcoli}instead of the\onlycommand – samcarter_is_at_topanswers.xyz Apr 27 '17 at 16:23 -
