Hey!
I am wondering if there's a way to use \includegraphics[]{} within a for loop. Is there actually a thing like a for loop in latex? I have quite a lot of images in a folder called 01.eps, 02.eps and so on, and want the "script" to put the images on paper.
here's a little scratch of what I mean:
\for i=1 to 10
\includegraphic[scale=0.5]{'\folder\'+int2str(i)+'eps'}
\end
is there a way to do this. I am not sure if latex can handle string manipulation.
thanks for help!!
cheers!
Stevo
Graphics, Figures & Tables ⇒ loading images in a for loop
NEW: TikZ book now 40% off at Amazon.com for a short time.

Re: loading images in a for loop
Try something like the following... I've shown pdf as the file extension. The 0 in front of argument #1 is to differentiate '01.pdf' from '1.pdf'.
Dirk
\documentclass{article}
\usepackage{ifthen}
\usepackage{graphicx}
\newcommand\addfigure[1]{\includegraphics[scale=0.5]{0#1.pdf}\\}
\begin{document}
\newcounter{count}\setcounter{count}{1}
\whiledo{\value{count}<11}{\addfigure{\thecount}\addtocounter{count}{1}}
\end{document}
Dirk
\documentclass{article}
\usepackage{ifthen}
\usepackage{graphicx}
\newcommand\addfigure[1]{\includegraphics[scale=0.5]{0#1.pdf}\\}
\begin{document}
\newcounter{count}\setcounter{count}{1}
\whiledo{\value{count}<11}{\addfigure{\thecount}\addtocounter{count}{1}}
\end{document}
Re: loading images in a for loop
Hey!
Thanks a lot for this! The loop seems to work, but Latex has problems with finding the pictures, somehow.. it also puts figures of files that do not exist.. well I guess I can use if-then-else for this.. do you know how to handle error massages?
Do I ask too much from Latex? Is there a way to write a C or Python script that handles all the programming stuff and let Latex do what's made for - format my pdfs..?
Cheers!
Stevo
Thanks a lot for this! The loop seems to work, but Latex has problems with finding the pictures, somehow.. it also puts figures of files that do not exist.. well I guess I can use if-then-else for this.. do you know how to handle error massages?
Do I ask too much from Latex? Is there a way to write a C or Python script that handles all the programming stuff and let Latex do what's made for - format my pdfs..?
Cheers!
Stevo