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?
TikZ-PGF External – How to Export EPS Figures from TikZ
tikz-externaltikz-pgf
Related Solutions
You were missing an &&
before the pdftoeps
, your quotation marks were in the wrong place (you had "\image".ps
instead of "image.ps"
), and pdftoeps
is the wrong command to use to convert a postscript file to an encapsulated postscript file. On my system, I have a command called ps2epsi
which works. I also tried it with ps2eps
which also works (don't know the difference!). Admittedly, I'm testing this on Linux so can't be absolutely sure that this will work for you with MikTeX, but give this a go and see if it works:
\documentclass{article}
%\url{http://tex.stackexchange.com/q/25524/86}
\usepackage{tikz}
% set up externalization
\usetikzlibrary{external}
\tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error
-interaction=batchmode -jobname "\image" "\texsource" &&
dvips "\image.dvi" && ps2epsi "\image.ps"}}
\tikzexternalize[shell escape=-enable-write18] % MikTeX uses a -enable-write18 instead of --shell-escape.
\begin{document}
\begin{tikzpicture}
\draw[fill=blue] (0,0) circle (1cm);
\end{tikzpicture}
\end{document}
(NB: Anyone testing this on Linux should comment out the optional argument to \tikzexternalize
.)
This approach is not working quite correctly either. For some reason I do get an error message in some pictures. In these cases the
\end{tikzpiture}
seems to be overlooked. However I do get a readable .eps file.
It appears that the code in the question is nearly right. It will produce both a *.ps as well as a *.eps file. Neither of them will however behave as expected.
The following code will create the desired *.eps files (all changes in \tikzset{...}
):
\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".eps "\image".dvi}}
\tikzexternalize % activate!
\begin{document}
\begin{tikzpicture}
\node {root}
child {node {left}}
child {node {right}
child {node {child}}
child {node {child}}
};
\end{tikzpicture}
A simple image is \tikz \fill (0,0) circle(5pt);.
\end{document}
Best Answer
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:
Then you run the file with
latex --shell-escape
(notpdflatex
!).If you run TeX Live under Windows, the
;
in thesystem call
definition has to be changed to&&
(that change should also work for at least some shells in other OSes).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:and run with
latex -enable-write18
(notpdflatex
!).If you want to run
pdflatex
and create an .eps file from the image, replace thesystem call
by