1

First of all my question is different from this question. The issue is that in my case I want to loop figures that are named with a monotonically increasing order from (1,2,\ldots,1000). I know how to use \psfrag for editing a single .eps file. But, what I don't know is how to do the same for multiple figures. As said earlier, in my case only the figure number changes (increases monotonically) and everything else remains the same.

Is it possible to loop this execution inside a loop? Since, I have never worked with loops in latex, at this moment I have no MWE.

Thanks for your suggestions.

  • 1
    Could you give feedback for the solution please? –  May 17 '17 at 10:03
  • 1
    @ChristianHupfer Yes, I will work this out tonight and will give you the feedback, because when I plan to work on the solution, I saw found the solution disappeared, and for some reason, I am seeing it today, So, I will work this out today, and will give the feedback. – Raaja_is_at_topanswers.xyz May 17 '17 at 10:16
  • I've had an error in my first version, deleted it and improved it. –  May 17 '17 at 10:46
  • @ChristianHupfer Thanks!1, Could you also tell me what is the upper bound on such iterations i.e., the maximum limit for the loops? – Raaja_is_at_topanswers.xyz May 17 '17 at 10:51
  • 1
    The upper bound should be limited by the maximum number of a counter value, i.e. 2^{31}-1, since I am pretty sure that the \foreach loop uses a count (register) internally –  May 17 '17 at 10:55
  • 1
    See https://tex.stackexchange.com/a/270536/31729 for example on the maximum counter value –  May 17 '17 at 10:56
  • @ChristianHupfer That's all I need :), now I can go and finish my presentation in a swift with this looping technique (hopefully). – Raaja_is_at_topanswers.xyz May 17 '17 at 10:57
  • 1
    I doubt that you would have about 2 billion slides then, so you're on the safe side ;-) Happy TeXing –  May 17 '17 at 10:58

1 Answers1

1

Here is the way with \foreach from pgffor package running a loop.

It uses the iterations from 1 to 20, applies the psfrag replacements and includes the relevant fooX.eps file. where X stands for any integer number between 1 and 20.

\documentclass{article}

\usepackage{graphicx}
\usepackage{psfrag}
\usepackage{pgffor}

\begin{document}

\foreach \x in {1,...,20} {%
  \psfrag{LATEX}{\bfseries \huge \LaTeX2e\  from file foo\x}
  \includegraphics[scale=0.6,angle=-90]{foo\x}

}

\end{document}

The foo.eps file is a simple .eps file generated with gnuplot. Here is a DropBox - Link to foo.eps (The other fooX.eps are just copies, for sake of simplicity)

enter image description here