To use psfrag
with pdflatex I use the pstool
package. Using TeXShop 3.25 I can compile the two minimal working examples given in this and this answer when I use the regular LaTeX typesetter.
The MWE from the first answer looks as follows:
% compiled by `pdflatex --shell-escape` enabled
\documentclass{book}
\listfiles % to show the list of packages loaded in .log file
\usepackage[crop=pdfcrop,process=all,cleanup={.tex,.dvi,.ps,.pdf,.log}]{pstool}
% Good options for pstool package
\EndPreamble % Will help to pick the right preamble in pstool auxillary process
\usepackage{color}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=0.8\linewidth]{trial.eps}
\caption{Tagged eps image}
\end{figure}
\begin{figure}
\centering
\psfragfig[width=0.8\linewidth]{trial}{\color{red}
\psfrag{[Mp]}{$M_A$}%
\psfrag{[hb]}{$H_B$}}
\caption{Replacing tags with real labels with psfrag}
\end{figure}
\end{document}
And the MWE from the second answer is:
\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}
When I use the pdflatexmk
script - which I have modified according to this answer to include the shell escape option required by pstool
- the compilation of both the aforementioned examples always ends in this error message:
Latexmk: Maximum runs of pdflatex reached without getting stable files
Latexmk: Did not finish processing file 'trialctan2.tex':
'pdflatex' needed too many passes
Latexmk: Use the -f option to force complete processing,
unless error was exceeding maximum runs of latex/pdflatex.
Latexmk: applying rule 'pdflatex'...
Latexmk: All targets (trialctan2.pdf) are up-to-date
Why is this error happening and how can I get rid of it?
I tried adding the -f
option to the pdflatexmk
script as follows:
"${LTMKBIN}"/latexmk -pdf -r "${LTMKEDIT}/latexmkrcedit" -r "${TSBIN}/pdflatexmkrc" -f -pdflatex="pdflatex --shell-escape %O %S" "$1"
But the same error persists.
Update 1:
Digging around I found that the culprit is the process=all
option. In the second MWE it is locally enabled by the asterisk after psfragfig
.
With this option the pdf file for each eps figure is recreated on every run. I suspect that the pdflatexmk
script notices this and decides it needs to run again as something has changed, triggering a new eps to pdf conversion, noticing it again, etc...
I think I need to find out how to restrict the process=all
option to the first run only.
-f
flag to thelatexmk
program; you added it to thepdflatex
program, which does not recognize it. You should put it right before the-pdflatex=
flag if you want it.-f
flag correctly now, but the error remains. As for the MWE's, the links in the first paragraph to two answers contain the MWE's that I try to compile. I have now added them in my question explicitly.