[pstricks] General question about loops

Herbert Voss Herbert.Voss at FU-Berlin.DE
Mon Nov 14 16:22:04 CET 2011


Am 14.11.2011 11:39, schrieb Toche, Patrick:
>
> I have a very general question about loops, it's not so much a PSTricks question, but since loops are commonly used by the PSTicks community I figure that this may be the right place to ask. I'm pretty sure some of you write loops like these all the time. If my question is out of place, please forgive me and ignore it.
>
> I want to include a list of figures located in a given directory.
>
> If the figures are named Name1, Name2, etc. the following loop, based on the pgffor package, will work:
>
> %%%%%%%%%%%%%%%%%%
> \documentclass{}% article/beamer
> \usepackage{graphicx}%
> \usepackage{pgffor}%
> \begin{document}%
> \foreach \index in {1, ..., 2}{%
>    \includegraphics[width=\textwidth]{Name\index.ps}\par%
> }%
> \end{document}

\PassOptionsToPackage{demo}{graphicx}
\documentclass{beamer}
\usepackage{pstricks}
\newcommand*\List{%
   OddName.ps,
   FunnyName.ps
}%

\newcommand\insertfigure[1]{%
    \includegraphics[width=\textwidth]{"Name#1"}}

\begin{document}
\psforeach{\name}{\List}{\insertfigure{\name}\endgraf}
\end{document}


Herbert


More information about the PSTricks mailing list