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?
1 Answers
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
- 89,023
- 26
- 255
- 291
;does not work under Windows. See the updated answer for a solution. – Caramdir Jan 17 '11 at 06:09tikz: Sorry, the system call 'latex -halt-on-error -interactionerror.What seems to be the problem? I'm using MikTex 2.9 and texmakerx on Win 7
– dingo_d May 12 '11 at 07:46&&instead of;anyway, because with;commands will continue to execute even if the previous one failed. – Andrey Vihrov Feb 15 '12 at 19:11.psfile, i don't see any.epsfile – scmg Jun 30 '15 at 13:12ps2epsmakes it done or not, since i usedGSviewto convert.psto.eps– scmg Jul 20 '16 at 14:04