[Tex/LaTex] Why aren’t the psfrag substitutions occurring

psfrag

I can't get simple psfrag substations go happen, and wonder if I'm missing an option or preference somewhere that will make them work.

I'm using LyX to build by document, but I have the same problem in nearly every tool I try. The only way I've been able to get substitutions to happen is by choosing Typeset > TeX and DVI in TeXShop using a MWE. But that's not were I build my actual document, and I don't think I can (and probably don't want to) make the equivalent change in LyX, where I actually work.

Is there some way I can modify the code below to so that substitutions will occur, using pdflatex (if that's even relevant)?

\documentclass{scrartcl}  
\usepackage{pstool}
\usepackage{psfrag}
\usepackage{tikz}

\begin{document}

\psfragfig*{graphA}{
    \psfrag{X}{$\epsilon$}
} 

\psfragfig{graphA}{
    \psfrag{X}{$\pi$}
} 

\psfragfig!{graphA}{
    \psfrag{X}{Q}
} 

\psfrag{X}{Help}
\includegraphics{graphA}

\end{document} 

Best Answer

To get correct typeset psfrag (and pstricks) stuff when compiling tex-->pdf directly, you should use the package auto-pst-pdf, which in a first run creates a file \jobname-pics.pdf, which collects all eps files converted to pdf embedding pstricks stuff.

You only need \usepackage{auto-pst-pdf} in your preamble.
If this -pics.pdf is created an you don't change your pics any more, you may set the option [off] to the call of \usepackage[off]{auto-pst-pdf} to get faster compilation.

To give a working exmaple:

\documentclass{article}
\usepackage{auto-pst-pdf}
\usepackage{graphicx}
\usepackage{psfrag}

\begin{document}

Some text

{
\psfrag{P1}{$P_1$}\psfrag{a}{\alpha}
\includegraphics[width=0.5\textwidth]{TestEps}
}

{
\psfrag{P1}{$Q=P_1$}
\includegraphics[width=0.5\textwidth]{TestEps}
}

\end{document}
Related Question