I am generating an eps and a tex file using matlabfrag, and am trying to include these graphics using pstools as
\begin{figure}[ht]
\centering
\psfragfig*[width=0.55\textwidth]{pics/figure1}{}
\caption{my caption}
\end{figure}
or inside a minipage as
\begin{minipage}{0.55\textwidth}
\centering
\psfragfig*[width=0.55\textwidth]{pics/figure1}{}
\captionof{figure}{my caption}
\end{minipage}
On rare occasions it works just fine (after compiling 100 times), but most of the time I end up with a red frame in the PDF saying "An error occured processing graphic [...] check the log file for compilation errors". However, Texniccenter is not giving me any compilation errors, nor can I find any in the log-file of the graphic.
I am using Texniccenter with Miktex 2.9. I am passing the following line to the compiler:
-max-print-line=120 -synctex=1 -interaction=nonstopmode --shell-escape "%wm"
Been stuck on this for days now, any help greatly appreciated!
EDIT: Results from debugging with mode=errorstop as pstool option
There seems to be some problem in the .aux files created. If I delete all .aux files before compiling, the figures are displayed correctly, and there is no error. I can then set \usepackage[process=none]{pstool} and everything is fine. Compiling the report a second time with [process=all] however triggers errors.
The errors vary depending on where the figures are and how many there are, and how the figures are included, but most of the errors contain a "latex: Bad file descriptor" at some point. Here is a small selection:
latex: file ended while scanning use of @writefile
! File ended while scanning us of \@newl@bel
Can't use spacefactor in vertical mode
It looks like the problem arises as soon as I have more than 5 figures spread out in the document. Having more, but all in one place, works fine, so does having e.g. 2 in one place and 3 in the other. I wish I could be more specific, but the errors seem to appear so randomly it's hard to pinpoint anything.
\documentclass{...}
and ending with\end{document}
.