# How to save a figure produced by tikz save/export as EPS file

I use MiKTeX 2.9 and tikz package and use TeXworks to make simple figures, these are saved in pdf file by pdfLaTeX. I wish to have them as EPS file. I read here: Export eps figures from TikZ I use a simple example

\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 get the following error:

===== 'mode=convert with system call': Invoking 'latex -halt-on-error -interact
ion=batchmode -jobname "untitled-1-figure0" "\def\tikzexternalrealjob{untitled-
1}\input{untitled-1}" && dvips -o "untitled-1-figure0".ps "untitled-1-figure0".
dvi && ps2eps "untitled-1-figure0.ps"' ========

! Package tikz Error: Sorry, the system call 'latex -halt-on-error -interaction
=batchmode -jobname "untitled-1-figure0" "\def\tikzexternalrealjob{untitled-1}\
input{untitled-1}" && dvips -o "untitled-1-figure0".ps "untitled-1-figure0".dvi
&& ps2eps "untitled-1-figure0.ps"' did NOT result in a usable output file 'unt
itled-1-figure0' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that yo
u have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'. So
metimes it is also named 'write 18' or something like that. Or maybe the comman
d simply failed? Error messages can be found in 'untitled-1-figure0.log'. If yo
u continue now, I'll try to typeset the picture.

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

l.15 \end{tikzpicture}

I see many have got the same error. I do not know what to do. Can somebody please help?

-
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  doncherry Jan 11 '13 at 5:42
You can do something like pdftops --eps filename.pdf for each PDF generated by the TikZ external library, but I recommend you to use the PDF images. –  leo Jan 11 '13 at 5:56
@user24203 if i may ask what is your objective of generating .eps figure ? IMHO these days .pdf is requested –  texenthusiast Jan 11 '13 at 6:12

Here are two routes for MiKTeX users. The first is similar to this post, but with additional notes.

## using pdflatex + pdftops with TeXworks

1. Download pdftops from foolabs.com (a PDF to PS/EPS converter). You'll find the 32-bit and 64-bit binaries for Windows in xpdfbin-win-3.03.zip. To install it, extract pdftops.exe from this file and copy it to the installation directory C:\Program Files\Xpdf\bin. Remember to add C:\Program Files\Xpdf\bin to the system variable Path (Start Menu -> right-click on Computer -> Properties -> Advanced System Settings -> Environment Variables under the Advanced tab -> look for the system variable Path and edit its value).

2. In TeXworks, go to Preferences -> Typesetting tab, and add --shell escape to the list of arguments passed to the pdflatex compiler as shown below.

Now run pdflatex on

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{external} % set up externalization

\tikzexternalize[shell escape=-enable-write18] % activate externalisation

\tikzset{external/system call={pdflatex \tikzexternalcheckshellescape -halt-on-error
-interaction=batchmode -jobname "\image" "\texsource" &&
pdftops -eps "\image.pdf"}}

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

in TeXworks and you will obtain graphics in the EPS format.

## using latex + ps2eps with TeXnicCenter

2. You'll also need Ghostscript and a Perl interpreter (one option is the free ActivePerl "Community Edition", available from activestate.com/activeperl).

(The ps2eps script assumes you have the 32-bit Windows install of Ghostscript. If you install the 64-bit version the file ps2eps.pl must be changed as described at the end of this answer.)

3. In TeXnicCenter, add -enable-write18 to the list of arguments passed to the latex compiler (go to Build, then click on Define Output Profiles), as illustrated below.

Now you can run latex on

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{external} % set up externalization

\tikzexternalize[shell escape=-enable-write18] % activate externalisation

\tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error
-interaction=batchmode -jobname "\image" "\texsource" &&
dvips -o "\image".ps "\image".dvi &&
ps2eps -l "\image.ps"}}

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

in TeXnicCenter and you will obtain graphics in the EPS format.

If you installed the 64-bit version of Ghostscript, you'll need to open ps2eps.pl with a text editor and replace the two occurrences of gswin32c with gswin64c.

-
OP uses TeXworks as mentioned in Question. TeXnicCenter also is a good choice –  texenthusiast Jan 11 '13 at 6:23
Texworks can be configured for latex->dvips->ps2pdf –  texenthusiast Jan 11 '13 at 6:37
This is perfect NUNO. I managed to get *.PS format. How can I make it to save as .EPS? –  user24203 Jan 11 '13 at 18:49
@user24203 to send a comment to NUNO use @NunoNunes like i did. at command line ps2eps FileName.ps gives FileName.eps file. For more ps2eps –  texenthusiast Jan 12 '13 at 0:26

Sometimes, it seems easier to manually type the useful commands in a command window instead of going through the endless configuration steps of your LaTeX-ready text editor. Consider the following myfile.tex:

\documentclass[11pt]{book}
\usepackage{tikz}
\pgfrealjobname{myfile}
\begin{document}
\beginpgfgraphicnamed{myfile-f1}%
\begin{tikzpicture}
\fill(0,0) rectangle (4,4);
\end{tikzpicture}
\endpgfgraphicnamed
\end{document}

Open such a command window in the working folder where your file myfile.tex is located and compile as follows:

latex --jobname=myfile-f1 myfile.tex

then

dvips myfile-f1.dvi

and you will obtain the desired properly cropped myfile-f1.eps file.

-
I followed your answer but obtained myfile-f1.ps. Not sure if relevant, but I'm on a MiKTeX distribution. –  nnunes Jan 14 '13 at 9:57
same for me. It is not .eps but .ps. It does not seem to be a big problem. You just rename the file with an .eps extension. –  pluton Jan 14 '13 at 14:01
Why does it generate a two-page dvi to me? The first page is blank with a page number only and the second page has the picture and a page number. –  user58955 Oct 3 '13 at 22:08