[pstricks] General question about loops
Herbert Voss
Herbert.Voss at FU-Berlin.DE
Sun Nov 20 18:14:16 CET 2011
Am 20.11.2011 18:01, schrieb Toche, Patrick:
> #1. Writing a loop to include images with names like Name1.ps, Name2.ps, yes I can do that (see my original post). Below are two examples, one based on the pgffor package, the other based on multido. Both work with the article and beamer class. Both work with latex/ps2pdf and pdflatex.
>
> using pgffor
that is a completely different package, for help you should ask on
the pgf mailing list
> \documentclass{article}%
> %\usepackage{grffile}%
> \usepackage{graphicx}%
> \usepackage{pstricks}%
>
> \newcommand*\List{%
> Name1.ps,
> Name2.ps
> }%
>
> \newcommand\insertfigure[1]{%
> % \includegraphics[width=\textwidth]{"#1"}%
> \includegraphics[width=\textwidth]{#1}%
> }%
>
> \begin{document}%
>
> \psforeach{\name}{\List}{\insertfigure{\name}\endgraf}%
That cannot work, the syntax of \psforeach is
\psforeach{\name}{<list of numbers>}{ command }
this should work:
\newcommand\insertfigure[1]{%
\includegraphics[width=\textwidth]{#1}%
}%
\begin{document}%
\psforeach{\name}{1,2}{\insertfigure{Name\name}\endgraf}%
You do nit need to specify the extension if you do not have files with
the the same base name and different extensions. TeX already takes the
right one.
Herbert
More information about the PSTricks
mailing list