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? – user31729 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 May 17 '17 at 10:16
  • 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 – user31729 May 17 '17 at 10:55
  • 1
    See tex.stackexchange.com/a/270536/31729 for example on the maximum counter value – user31729 May 17 '17 at 10:56
  • 1
    I doubt that you would have about 2 billion slides then, so you're on the safe side ;-) Happy TeXing – user31729 May 17 '17 at 10:58

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.




\foreach \x in {1,...,20} {%
  \psfrag{LATEX}{\bfseries \huge \LaTeX2e\  from file foo\x}



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

|improve this answer|||||
  • Fantastic!! is the feedback, works like a charm!!!! – Raaja May 17 '17 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.