3

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>
. . .
[Loading MPS to PDF converter (version 2006.09.02).]
)
===== '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 08: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 08: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 09: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 09: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. – Andrew Stacey Mar 22 '11 at 09:29
  • (Didn't see your previous comment; sort out the quotation marks first and then try again!) – Andrew Stacey Mar 22 '11 at 09:30
  • Just a guess, but try to change "\image".ps "\image".dvi to "\image.ps" "\image.dvi". – Martin Scharrer Mar 22 '11 at 09:44
  • As per both your last comments, I changed the commands as Martin suggests -- it still fails.

    I then ran it from the command line without MikTaX, using the following command: pdflatex -enable-write18 -output-format=dvi. It now runs correctly, outputting a DVI file. How do I get it to output an EPS file? The only two valid -output-format values are PDF and DVI.

    – Moshe Rubin Mar 22 '11 at 09:59
  • @Moshe: The dvips command which is included should have converted it from DVI to EPS. You can run it manually if you want. Depending on what you want exactly you could also try the standalone class instead. – Martin Scharrer Mar 22 '11 at 10:58
  • I would try running the command 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" from the command line. The && is very unix-y and I don't know if it will work correctly in Windows. It does look as though now the first part of the command is working correctly but the second is not getting called, so that may be the culprit. – Andrew Stacey Mar 22 '11 at 13:10
  • Note also that when running pdflatex -enable-write18 on the command line, you should get extra files which are the image files. What format are they? The conversion to EPS only happens for the generated image files, not for the main file. – Andrew Stacey Mar 22 '11 at 13:11
  • @Martin: I got a PS (not EPS) format file. The journal I'm submitting my article to requires EPS, PSD, or TIFF. The ps2eps Perl script consistently failed because the input file to bbox.exe was not the expected ppm raw format.

    @Andrew: After many fruitless hours I decided to bite the bullet and go command-line, writing a batch/script file that runs pdflatex, dvips, and convert on a given PDF file outputted by TikZ.

    Now I can finally get an EPS or TIFF file, but the quality is very degraded relative to the PDF. How can I improve the quality via convert? (Can I post graphics here?)

    – Moshe Rubin Mar 23 '11 at 10:42
  • @Moshe: Only the first user mentioned with @ is notified. You should split this comments into two. The difference between PS and EPS should be minimal, i.e. setting the headers. Try to use Ghostscript to convert it. – Martin Scharrer Mar 23 '11 at 10:48
  • @Andrew: After many fruitless hours I decided to bite the bullet and go command-line, writing a batch/script file that runs pdflatex, dvips, and convert on a given PDF file outputted by TikZ. Now I can finally get an EPS or TIFF file, but the quality is very degraded relative to the PDF. How can I improve the quality via convert? (Can I post graphics here?) – Moshe Rubin Mar 23 '11 at 10:57
  • To simplify the entire process (which for me, primarily a Windows user, is somewhat frustrating ) I am trying to take the PDF produced by TikZ and convert it directly to a TIFF file using Image Magick's convert command. This works but results in a highly degraded image. The command I'm using is convert %1.pdf %1.tiff. There is a myriad of command line options. How does one convert a PDF to a TIFF (or any other format) preserving the clarity of the image? – Moshe Rubin Mar 23 '11 at 11:02
  • Moshe Rubin: Welcome again to TeX.sx! I merged your two accounts together (your question and your answer posts created two different, unregistered accounts) so you should now be able to edit the question again. I also moved your second post to end of the first. Please note that this is not a forum but an question&answer site which has its own format: 1 question + n answers, spiced with comments. – Martin Scharrer Jul 06 '11 at 16:43
  • A related question seems to be Externalize graphics when using pgfplots doesn't work (MiKTeX 2.9). There the user reinstalled MikTeX and fixed its problem. Maybe this helps you, too. – Martin Scharrer Jul 06 '11 at 16:45

1 Answers1

6

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.

Then, recompile your .tex file.

I am sure that you can find a similar option for your preferred TeX editor.

  • Hi Christian, Thank you very much for coming back to this issue. The TeX editor I use for compiling my TikZ script is TeXworks. Based on your encouragement, I found that I could add the -enable-write18 option to the texify.exe command via the Edit>Preferences>Typesetting tab. I highlighted the option I'm using (which is pdfLaTeX+MakeIndex+BibTeX), clicked the Edit button, and added "--tex-option=-enable-write18" to the texify.exe command line. This, unfortunately, does not solve the problem -- I get an error message (how can I insert the error text in this thread?). – Moshe Rubin Jul 06 '11 at 09:19
  • That's unfortunate, indeed. I think that you can edit your own question. If that is possible, you could probably insert the error message and, if possible, the involved .log files (or at least extracts)... – Christian Feuersänger Jul 06 '11 at 15:41
  • @Martin Why was my previous post deleted? – Moshe Rubin Jul 06 '11 at 17:24
  • I am using WinEdt, and having the same error. How ca i -enable-write18 in winEdt???. – Fadwa Jul 17 '14 at 12:57
  • I think you should ask a new question. This comment is mainly visible to those who have comments in this ticket, and I at least I am unfamiliar with winedt. – Christian Feuersänger Jul 18 '14 at 07:26