How to use pstool in pdfLatex?

Update: After I adding those --shell -escape commands, when I run the code as below, it still cannot work.

\documentclass[pdftex]{memoir}
\usepackage{color}
\usepackage{pstool}
\input macros.tex
\EndPreamble
\begin{document}

External macros: \a, \b, \c

\pstool{trial}{%
}

\psfragfig{subdir/trial2}{%
\psfrag{[Mp]}{$Z_\b$}%
}

\end{document}


Update: The question (described in the quotation as below) is solved by deleting the space between the name of my tex file.

But, I am still not clear of how to use the command of pstool combined with psfrag. Can anyone shed a light on this for me?

I tried to add the package at the very beginning of the document. But, there are some errors happened and the console said that /usr/local/texlive/2012/texmf-dist/tex/latex/ifplatform/ifplatform.sty:93: Pack age catchfile Error: File"my files".w18' not found.

When I removed the sentence of \usepackage{pstool}, the compiling runs well.

Any suggestions will be great appreciated. Thanks!!!

-
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. And which distribution on what OS are you using? –  Martin Schröder Jan 31 '13 at 7:34
Hi, @MartinSchröder! Thanks for your warmly reply. Unfortunately, I didn't know the basic usage of the \pstoolcommand. So, what I am asking is a simple example that use this command with the psfrag command. I tried to google it. But I didn't get a simple but useful one. –  datcn Jan 31 '13 at 8:13
As far as I understand it, your current question is requesting an example of using psfrag and pstool with pdflatex. If so, can you edit the question so that it focuses on that question (and not the solved issue of a space in the filename)? –  Matthew Leingang Jan 31 '13 at 13:25
why do you need psfrag? You can have the right font already in your image. –  Herbert Jan 31 '13 at 18:56
Hi, @MatthewLeingang. Many thx for your detailed reply. I tried the short example as your given. But I failed to generate a pdf output. The error information is as below. ./pstest.tex:10: Package pstool Error: No graphic "gandl.eps.eps" or "gandl.eps -psfrag.eps" found. Here, the gandl.eps is the name of my eps file. –  datcn Jan 31 '13 at 23:04

Here is a short example of psfrag and pstool in action. I took this from the package's example directory on CTAN:

\documentclass{article}
\usepackage{color}
\usepackage{pstool}
\def\a{A}
\EndPreamble
\begin{document}

\psfragfig*[mode=nonstop]{trial}{%
\color{red}
\tiny
\psfrag{[Mp]}{$M_\a$!}%
}

\end{document}


(The red mark is what's added with \psfrag.)

As egreg notes below, the -shell-escape option must be specified to pdflatex at run time.

-
To be run with the -shell-escape option. –  egreg Jan 31 '13 at 13:28
Hi, @egreg and @MatthewLeingang , I am using the TexShop v3.11, in which the -shell-escape option was removed. I don't know if this is the reason that why I cannot run this simple example in my TexShop. –  datcn Feb 4 '13 at 7:25
@datcn That's quite probable. –  egreg Feb 4 '13 at 9:48
@datcn: Go to TexShop Preferences and look at the Engine tab. Add --shell-escape to the lines with pdftex and pdflatex`. –  Matthew Leingang Feb 4 '13 at 19:01
@MatthewLeingang After I adding those commands, when I run the code as above, it still cannot work. –  datcn Feb 5 '13 at 0:23