# Attempting to export tikz to eps

Attempt to export eps figures from TikZ fails

I am able to generate .dvi versions of my figures. However, I need .eps, and it seems that the question above only covers getting the externalize library to work. It does so now, with no errormessages. But there is no eps-output.

Reading the manual, it seems I have to add "pdftops -eps {pdf file} {eps file}" to the "system call option". Below is seen my attempt at doing so:

\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 pdftops -eps "\image".pdf "\image".eps}}
\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}


as you can see, having no idea what to put in place of {some file}, I just copied the form of what was already there. The above does not generate any errors, nor any .eps-files.

I am outputting to .ps format.

I hope someone can explain to me how to add the proper option =)

-
As a small note: LaTeXiT (on a mac) allows you to save your work in many formats, including eps. Its main purpose is to be able to include nice equations into other types of documents (Pages,Word,LibreOffice,etc.) but I use it to draw diagrams. – Frédéric Aug 12 '11 at 12:56
I have the same problem than Kaare. Did you find a solution? I run with Miktex... – user12949 Mar 25 '12 at 13:33

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.)

-
Actually, that's not quite right. That pdftops shouldn't be there ... – Loop Space Aug 12 '11 at 11:32
Okay, gotten rid of the pdftops and replaced it with ps2epsi instead. – Loop Space Aug 12 '11 at 11:41
The location of the " doesn't matter. The shell will remove them anyway before the program sees them. They are just there to escape any special characters in the filename. I updated tex.stackexchange.com/questions/8641/… to add the missing ps2eps. – Caramdir Aug 12 '11 at 16:34
Unfortunately I can not make this work. That is to say, copy-pasting the above code has exactly the same effect as the old code. – Kaare Aug 12 '11 at 17:22
@Kaare: What happens if you run the commands individually? – Loop Space Aug 12 '11 at 18:57

## Step 1

Create a batch file as follows:

rem batch.bat takes an input file name WITHOUT extension.

del %1.pdf
del %1.eps

pdflatex %1
pdftops -level3 -eps %1.pdf

del %1.aux
del %1.log


For simplicity, save it in the same directory in which your input file exists.

## Step 2

Create a test input file as follows.

% test.tex
\documentclass{article}
\usepackage{tikz}
\usepackage[active,tightpage]{preview}
\PreviewBorder=0pt
\PreviewEnvironment{tikzpicture}

\begin{document}
\begin{tikzpicture}
\draw[fill=blue] (0,0) circle (1cm);
\end{tikzpicture}
\end{document}


For simplicity, save it in the same directory in which batch.bat exists.

## Step 3

Open MS-DOS prompt by pressing Win+R, typing cmd and hitting ENTER. The MS-DOS prompt brings up and navigate to your input file directory. Afterwards, type

and hit ENTER. Done, you will get both PDF and EPS outputs.

-
If you are satisfied with this answer, don't forget to upvote and give a green check mark. Because I noticed you have not done it yet for your other question. :-) – xport Aug 12 '11 at 10:26
You don't need to pass -enable-write18 to pdflatex in batch.bat because pdftops is executed directly outside pdflatex. – xport Aug 12 '11 at 10:30
I get the following (after a lot of text describing the workings of MikTex): D:\projekt\Talks & such\DelA-defence>pdftops -level3 -eps tikzFigure1.pdf 'pdftops' is not recognized as an internal or external command, operable program or batch file. – Kaare Aug 12 '11 at 17:26
So, I guess the new question is where to get pdftops =) googling pdftops windows does not yield anything useful. – Kaare Aug 12 '11 at 17:31
@Kaare: I don't use MikTeX. In TeXLive, this tool exists. – xport Aug 13 '11 at 12:36