1

There have been many posts on this site either requesting simple examples illustrating the pstool package, or providing (often not-simple) ones. I've tried all of them and none of them compile for me. I've also tried to read pstools.sty, which came with my installation, but unfortunately it contained no simple examples. It seems that the following MWE is about as simple as one could possibly get.

\documentclass{article}
\usepackage{pstool}
\EndPreamble
\begin{document}
\psfragfig{trial}{%
  \psfrag{[Mp]}{$M_a$}%
}
\end{document}

Yet it throws all sorts of inexplicable errors, and fails to compile. I'm running the pdflatex that comes with texlive 2016, installed in the recommended way, on a Linux 64 bit machine, Ubuntu 16.04.

To compile I'm using the command

pdflatex -shell-escape

There's talk on the web about a file called pstool-statusfile.txt, which I don't understand, but I've touch'ed it, just in case, it's zero size before and after compilation. The file trial.eps was downloaded from

the CTAN example site for pstools

I'd love to hear if anybody can get this code to run, if so, how? if not, why not?

Here's the relevant portion of the .log file:

Preview: Fontsize 10pt
(.//trial.tex) <trial.eps>
! Missing { inserted.
<to be read again> 
                   \begingroup 
l.21  \includegraphics [] {trial}


LaTeX Warning: Command \b invalid in math mode on input line 21.

! Missing $ inserted.
<inserted text> 
                $
l.21  \includegraphics [] {trial}

! Missing $ inserted.
<inserted text> 
                $
l.21  \includegraphics [] {trial}

! Missing } inserted.
<inserted text> 
                }
l.21  \includegraphics [] {trial}

Preview: Tightpage -32891 -32891 32891 32891
[1] (.//trial-pstool.aux) )
(see the transcript file for additional information)
Output written on .//trial-pstool.dvi (1 page, 2232 bytes).
Transcript written on .//trial-pstool.log.

(./pstool-statusfile.txt)

Package pstool Warning: Execution failed during process:
  latex -shell-escape -output-format=dvi -output-directory="./" -interaction=no
nstopmode  "trial-pstool.tex"
This warning occurred on input line 9.


=== pstool: end processing ===

[1
Non-PDF special ignored!{/usr/local/texlive/2016/texmf-var/fonts/map/pdftex/upd
map/pdftex.map}] (./myExample.aux)
2

note that you need pdflatex --shell-escape to enable the psfrag processing.

When running your MWE the log complained of missing packages so I added tikz and its calc library then it worked as expected. trial.eps here is a copy of example-image.eps that is in tex distributions (if I left it as example-image ot ran without error but found the png file rather than eps so coukd not do the replacement

\documentclass{article}
\usepackage{pstool}
\usepackage{tikz}
\usetikzlibrary{calc}
\addtolength\textwidth{1in}
\addtolength\oddsidemargin{-.5in}
\EndPreamble
\begin{document}

\includegraphics{trial}

\psfragfig{trial}{%
  \psfrag{Image}{$M_a$}%
}
\end{document}

here I show the image included directly and with the psfrag replacement.

enter image description here

  • Thanks very much David. I ran your file as a test on my own eps file, with just one silly psfrag substitution. The result, remarkably, was that my silly change was ignored, but all of my actual psfrag substitutions (which were written in a .tex file with an unrelated name) were made to David.pdf. The only way this could have happened is if the psfragfig command looked thru all of the .tex files in my cwd, and found every psfrag command that related to the text strings in the .eps file named in David.tex. Amazing and scary. – Leo Simon Jan 1 '17 at 18:40
  • @LeoSimon whatever it did, it didn't do that:-) – David Carlisle Jan 1 '17 at 18:45
  • @DavidCarlisle, I have a similar problem with some matlabfrag exported eps figure. As a test, I have tested with some other graphics(tex and eps inputs for psfragfig) input and they seem to work. Only this figure and the related pstool files are creating problem, exactly the above explained problem. Adding also \usepackage{tikz} \usetikzlibrary{calc} did not help me. I have spent some time but could not find the reason, do you also have any idea what might be going wrong? – Umut Tabak Mar 2 '17 at 18:35
  • @DavidCarlisle, isn't it also very strange that the other files exported in the same manner are working fine and only this specific one is creating the problem – Umut Tabak Mar 2 '17 at 18:44
  • @UmutTabak there are lots of cases where psfrag can not "find" text in an eps file it all depends on the way text is encoded in the file (and if it is encoded as text at all rather than as stroked paths.) – David Carlisle Mar 2 '17 at 18:52

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.