1

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.

2
  • Welcome to TeX.SX! Please help us to help you and 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}.
    – user31729
    Jun 13, 2014 at 13:55
  • I'm starting to think this is a pstool bug relating to the aux file "features" I added some time ago. Any way to reduce the problem to something that can be reproduced would be helpful… Jun 15, 2014 at 2:12

1 Answer 1

1

The pstool package uses the error flag of the compilation/typesetting stage to determine if the typesetting has succeeded or not, so if you're seeing that red box there must be an error somewhere in the chain.

To help track down such problems, load pstool with the following option:

\usepackage[mode=errorstop]{pstool}

and use -interaction=errorstopmode in texniccentre; this will show up all output as it comes scrolling through, and will pause when an error occurs.

In the event that the figure typesetting succeeds, this would indicate there's a subsequent problem converting the DVI to PS and then to PDF (and then maybe cropping it). Try and run those steps manually on the pics/figure1.dvi file (or whatever) that results in this case. Since you're using Windows, it's not impossible there's a ghostscript error or something along those lines in the way that pstool is attempting to convert the file.

4
  • Will do. I've been trying to set up a minimal example where the problem appears, but it is so strange that I cannot pinpoint it. Basically, in my text, including the figure works (as shown in my previous post), but after adding a few lines of text, including the same figure (or another) does not work anymore. It's as if there was a limit in the number of allowed characters before the figure.
    – Ced
    Jun 13, 2014 at 15:03
  • I think you should add this to your question; there's not much space here in the comments for additional detail. Jun 13, 2014 at 15:05
  • Added some details to my question
    – Ced
    Jun 14, 2014 at 13:42
  • @ Will Robertson, I came to the right stop ;-). I have a similar problem with exactly the same set up with matlabfrag. I have spent some hours before finding this thread. I added the errorstop option to the package, it is stopping at a line like this \includegraphics [] {test}, otherwise I get the mentioned red box, any ideas? I am using pstool on linux and compiling from inside emacs with auctex.
    – Umut Tabak
    Feb 26, 2017 at 16:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .