Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Section 32 Externalization Library of the pgfmanual (v2.10) explains how to generate PDF figures and EPS figures. I successfully tried it with PDF output (there is an example with a full explanation in the manual), but failed with EPS (no example provided). Can anyone give me a minimal example?

share|improve this question

1 Answer 1

up vote 29 down vote accepted

The manual says that one way is to run pdftops -eps <pdf file> <eps file> after a compilation that produces a .pdf.

Alternatively, you can use the external/system call=... key as described on page 345 of the v2.10 manual. Unfortunately, the way to do it differs slightly between operating systems and TeX distributions. Here are descriptions for the three most common combinations:


Under unixy operating systems (Linux, Mac OS X) with TeX Live (or derivatives like MacTeX), the following should work:

\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;
ps2eps "\image.ps"}}
\tikzexternalize

\begin{document}
\begin{tikzpicture}
[some graphic]
\end{tikzpicture}
\end{document}

Then you run the file with latex --shell-escape (not pdflatex!).


If you run TeX Live under Windows, the ; in the system call definition has to be changed to && (that change should also work for at least some shells in other OSes).

\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 &&
ps2eps "\image.ps"}}
\tikzexternalize

\begin{document}
\begin{tikzpicture}
[some graphic]
\end{tikzpicture}
\end{document}

and you should compile it with latex --shell-escape (I haven't tested this myself, but I'm pretty sure that this will work).


If you use MikTeX on Windows, you need to further change --shell-escape to -enable-write18 and tell TikZ about the change:

\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 &&
ps2eps "\image.ps"}}
\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}

and run with latex -enable-write18 (not pdflatex!).


If you want to run pdflatex and create an .eps file from the image, replace the system call by

pdflatex \tikzexternalcheckshellescape -halt-on-error 
-interaction=batchmode -jobname "\image" "\texsource" && % or ;
pdftops -eps "\image".pdf
share|improve this answer
1  
Thanks. I figured out this, but it did not work. I use MikTeX 2.9 with updated packages. –  Ma Ming Jan 10 '11 at 19:07
    
@MaMing The above works on TeX Live, but I don't have a MikTeX install to test things. Maybe someone else can say why it doesn't work with MikTeX. –  Caramdir Jan 10 '11 at 22:18
3  
@MaMing: The problem was in the Windows shell. Apparently chaining commands with ; does not work under Windows. See the updated answer for a solution. –  Caramdir Jan 17 '11 at 6:09
    
Thanks for your detailed answer!!! It works for my MikTeX, you helped me too much, thanks again. –  Ma Ming Jan 21 '11 at 23:48
    
Hi when I try your example I'm getting tikz: Sorry, the system call 'latex -halt-on-error -interaction error. What seems to be the problem? I'm using MikTex 2.9 and texmakerx on Win 7 –  dingo_d May 12 '11 at 7:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.