I'm trying to include a lot of images to document and decided to use a counter to generate the filenames. A minimal (not working) example would look something like this:
\documentclass{article}
\usepackage{graphicx}
\usepackage{fmtcount}
\newcounter{imgnr}
\begin{document}
% image names are img000.png, img001.png, ..., img999.png
\setcounter{imgnr}{1}
\includegraphics[width=0.5\linewidth]{./images/img\padzeroes[3]\decimal{imgnr}.png}
\setcounter{imgnr}{2}
\includegraphics[width=0.5\linewidth]{./images/img\padzeroes[3]\decimal{imgnr}.png}
\setcounter{imgnr}{10}
\includegraphics[width=0.5\linewidth]{./images/img\padzeroes[3]\decimal{imgnr}.png}
\end{document}
This example gives the error TeX capacity exceeded, sorry [input stack size=5000]. Any idea on how to fix this? Or is this the wrong way to go?
In the real example, the counter is incremented and then a template with title, some text and tables and the image is included for each image. So thats the reason why im using a counter. I can nicely select the data for a given image.
Bonus: Display a box with Image 'imgxxx.png' is missing if a image is not found.
\decimalmight not be expandable: https://groups.google.com/d/msg/comp.text.tex/86la9mMQVXI/kgW0vrArcTUJ – jrast Jun 15 '15 at 09:13