# Attempt to export EPS figures from TikZ fails

I'm attempting to output EPS figures when using MikTeX 2.8 under Windows XP, and am following Export eps figures from TikZ. My problem is that I can't get the bare example given there to run.

The code I'm using was copied from that thread verbatim:

\documentclass{article}
\usepackage{tikz}

% set up externalization
\usetikzlibrary{external}
\tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error
-interaction=batchmode -jobname "\image" "\texsource" &&
dvips -o "\image".ps "\image".dvi}}
\tikzexternalize[shell escape=-enable-write18] % MikTeX uses a -enable-write18 instead of --shell-escape.

\begin{document}
\begin{tikzpicture}
\draw (0,0) circle (1cm);
\end{tikzpicture}
\end{document}


When running I get the following error message:

This is pdfTeX, Version 3.1415926-1.40.10 (MiKTeX 2.8)
entering extended mode
(C:/junk/untitled-2.tex
LaTeX2e <2009/09/24>
. . .
)
===== 'mode=convert with system call': Invoking 'latex -halt-on-error -interaction=batchmode -jobname "untitled-2-figure0" "\def\tikzexternalrealjob{untitled-2}\input{untitled-2}" && dvips -o "untitled-2-figure0".ps "untitled-2-figure0".dvi' ========

! Package tikz Error: Sorry, the system call 'latex -halt-on-error -interaction=batchmode -jobname "untitled-2-figure0" "\def\tikzexternalrealjob{untitled-2}\input{untitled-2}" && dvips -o "untitled-2-figure0".ps "untitled-2-figure0".dvi' did NOT result in a usable output file 'untitled-2-figure0' (expected one of .pdf:.jpg:.jpeg:.png:). Please 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? Error messages can be found in 'untitled-2-figure0.log'. If you continue now, I'll try to typeset the picture.
See the tikz package documentation for explanation.
Type  H <return>  for immediate help.
...

l.14 \end{tikzpicture}

?


Can someone help me over this hurdle?

My previous post was written on my Windows XP system using Chrome, where the answer box limited me to about 600 characters and did not accept markup or newlines :-(. I'm writing this on my Windows 7 system with Chrome, and the answer box has all markup bells and whistles I need -- very strange.

Following is the compilation output:

This is pdfTeX, Version 3.1415926-1.40.10 (MiKTeX 2.8) entering extended mode ("C:/Documents and Settings/Moshe/My Documents/test.tex" LaTeX2e <2009/09/24> . . .

===== 'mode=convert with system call': Invoking 'latex -enable-write18 -halt-on
-error -interaction=batchmode -jobname "test-figure0" "\def\tikzexternalrealjob {test}\input{test}" && dvips -o "test-figure0".ps "test-figure0".dvi' ========

! Package tikz Error: Sorry, the system call 'latex -enable-write18 -halt-on-er ror -interaction=batchmode -jobname "test-figure0" "\def\tikzexternalrealjob{te st}\input{test}" && dvips -o "test-figure0".ps "test-figure0".dvi' did NOT resu lt in a usable output file 'test-figure0' (expected one of .pdf:.jpg:.jpeg:.png :). Please verify that you have enabled system calls. For pdflatex, this is 'pd flatex -shell-escape'. Sometimes it is also named 'write 18' or something like  that. Or maybe the command simply failed? Error messages can be found in 'test- figure0.log'. If you continue now, I'll try to typeset the picture.

See the tikz package documentation for explanation. Type  H <return>  for immediate help.  ...


l.14 \end{tikzpicture}

I hope this is easier to read than my previous post :-)

-
You are compiling it with the -enable-write18 command line option, do you? It is required for this to work. – Martin Scharrer Mar 22 '11 at 8:38
Thank you for your prompt reply! Do I need to do anything other than include the line "\tikzexternalize[shell escape=-enable-write18]" in the script? I'm running the GUI version of MikTeX. Should I be setting some configuration option for -enable-write18? I did enable the "Allow scripts to running system commands" configuration option, but received the same error message. – Moshe Rubin Mar 22 '11 at 8:46
I'm not using MikTeX by myself much, so I can't tell you the exact way on Windows. Anyway, the -enable-write18 option must be passed to latex. The \tikzexternalize setting is AFAIK only for sub-calls of latex. Try to move this line before \tikzset and have a lock at the untitled-2-figure0.log file mentioned in the error message. It might contain more information. – Martin Scharrer Mar 22 '11 at 9:03
Thanks for pointing me to the log file (duh!). It seems to indicate a quotation error: runsystem(latex -halt-on-error -interaction=batchmode -jobname "untitled-2-figure0" "\def\tikzexternalrealjob{untitled-2}\input{untitled-2}" && dvips -o "untitled-2-figure0".ps "untitled-2-figure0".dvi)...quotation error in system command. – Moshe Rubin Mar 22 '11 at 9:26
My first instinct is also that the main latex process is not being allowed to run system commands. From the MiKTeX manual I read "The \write18 feature is only partially enabled by default to avoid security problems: only well known commands are allowed. You fully enable the feature by specifying --enable-write18 on the TeX command-line." So you could try doing a commandline compilation with pdflatex --enable-write18 and see if that works. – Loop Space Mar 22 '11 at 9:29

I tried to reproduce your example on my MikTeX 2.9 installation and found the same error message. Interestingly, the main .log file contains the hint "quotation error in system call". When I dropped all quotation marks, I got "forbidden, restricted" or something like that. Seems as if MikTeX has strange error checking here.

Anyway, as soon as I reconfigured TeXnicCenter to add the -enable-write18 switch, it worked - and it no longer complaint about 'quotation errors'.

So, I agree with the suggestions shown in comments above: I am pretty sure that you "only" need to figure out, how to add the -enable-write18 switch to your TeX Editor. If you tell us which editor you use, we may be able to assist you.

For TeXnicCenter, it works as follows: go to "Output >> Define output profiles (Alt+F7)". There, you should see the different output profiles on the left and on the right, you see the involved programs like "Path to LaTeX Compiler", "BibTeX", "MakeIndex". Select the profile LaTeX=>PS, then add -enable-write18 to the "Path to LaTeX Compiler". The "Path To LaTeX Compiler" should be something like C:Program Files\MikTeX 2.9\miktex\bin\latex.exe -enable-write18 afterwards.

I am using WinEdt, and having the same error. How ca i -enable-write18 in winEdt???. – Misaki Jul 17 '14 at 12:57