# Externalize graphics when using pgfplots doesn't work (MiKTeX 2.9)

I'm having problems exporting my pgfplots figures to separate files using the externalize command. I get an error, the central point of which seems to be "Please verify that you have enabled system calls.". I have followed the instructions in the pgfplots manual to do this, however. I'm using MiKTeX 2.9 and Windows 7.

(In a related thread, the poster has the same problem as me: Attempt to export eps figures from TikZ fails . However, in that case the poster is able to successfully export an image using the command "pdflatex -enable-write18 -output-format=dvi", I don't get that far. I have read that thread carefully but still can't figure out how to solve my problem).

My example is the following, taken from the pgfplots manual:

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\tikzexternalize[shell escape=-enable-write18] %needed for the MiKTeX compiler

\begin{document}

\begin{figure}
\begin{tikzpicture}
\begin{axis}
\end{axis}
\end{tikzpicture}
\caption{Our first external graphics example}
\end{figure}

\end{document}


I compile using the command:

pdflatex.exe -shell-escape


This gives the following error:

entering extended mode
===== 'mode=convert with system call': Invoking 'pdflatex -enable-write18 -halt
-on-/b/c9/cerror /b/c0/c-interaction=batchmode -jobname "externalizetest-figure0" "\def\tikze
xternalrealjob{externalizetest}\input{externalizetest}"' ========
! Package tikz /b/c9/cError:/b/c0/c Sorry, the system call 'pdflatex -enable-write18 -halt-on
-/b/c9/cerror /b/c0/c-interaction=batchmode -jobname "externalizetest-figure0" "\def\tikzexte
rnalrealjob{externalizetest}\input{externalizetest}"' did NOT result in a usabl
e output file 'externalizetest-figure0' (expected one of .epsi:.eps:.ps:). Plea
se verify that you have enabled system calls. For pdflatex, this is 'pdflatex -
shell-escape'. Sometimes it is also named 'write 18' or something like that. Or
maybe the command simply failed? /b/c9/cError /b/c0/cmessages can be found in 'externalizete
st-figure0.log'. If you continue now, I'll try to typeset the picture.
See the tikz package documentation for explanation.


As I understand it, the line

\tikzexternalize[shell escape=-enable-write18]


is supposed to replace the command -shell-escape to -enable-write18, which is needed for MiKTeX. Just to make sure that isn't the problem, I tried using the command

pdflatex.exe -enable-write18


\tikzexternalize


in the .tex file. But that doesn't work either.

I'd be very thankful for help on how to enable system calls with MiKTeX 2.9, or, if the problem lies somewhere else, for thoughts on what might be wrong.

/Andreas

-
You can always do it the other way around: Place you plot/diagram in an external file with a full preamble and use the standalone class to be able to compile it by itself. You can then use the standalone package to strip the preamble when you \input it, or include the resulting image directly. The next version of standalone will allow you to switch between both and even create the PDF automatically. –  Martin Scharrer Jul 5 '11 at 13:18
Thanks for the tip! I understand you are the author of standalone. Is the package also able to export eps images? –  andreasdr Jul 5 '11 at 15:26
If you compile the standalone files with normal latex then yes. –  Martin Scharrer Jul 5 '11 at 15:37
I see two possible reasons for the failure: the first is that the system did not allow the system call and the second is that the system call has been started, but failed. In general, if there exists a log file externalizetest-figure0.log, the system call has tried to start. If not, you can be sure that the system call did not even start. In that case, the main log file externalizetest.log might indicate a small hint of what went wrong. Perhaps it did not find the "pdflatex" command? –  Christian Feuersänger Jul 5 '11 at 16:14
Why do you want to export EPS when you use pdflatex? Both standalone nor export actually export anything, but use either latex or pdflatex (either automatic or manual) to create a DVI (which can be converted EPS) or PDF file. As said, place the tikzpicture in a own file, add a \documentclass{standalone} \usepackage{tikz,otherpackages}<libs..> preamble and compile it with latex. Then use dvips -E (IIRC) on the DVI file to get a EPS. –  Martin Scharrer Jul 5 '11 at 16:43