10

I have a problem with image converting for scientific manuscript. I have been using gnuplot to make graphs, using TikZ terminal, and finally generating the figure as a PDF with LaTeX. It results in a nice vector graphic image, in PDF file format (PDFLaTeX). The problem is that publishers ask for images in EPS format. When I try to convert my PDF with Imagemagick or pdf2ps, I get a low resolution rasterized image. But as far as I know eps is also a vector graphic format. I tried to set the resolution for conversion, but I get the same low resolution image. Is there a way to convert my vector graphic PDF to vector graphic EPS? Or anyone knows a way to export in eps from gnuplot with LaTeX typesetting/fonts?

Thanks,

  • 1
    I thought, the TikZ terminal should also allow to compile to eps, but that doesn't work for me. Otherwise you can use the epslatex and the cairolatex eps terminal to generate eps output graphics with LaTeX text. – Christoph Sep 22 '13 at 17:15
  • 4
    Use pdftops rather than convert (from ImageMagick). – kiss my armpit Sep 22 '13 at 17:17
6

Use pdftops rather than convert (from ImageMagick). The command is

pdftops -f <first-page> -l <last-page> -eps <input.pdf> <output.eps>

For example,

pdftops -f 4 -l 4 -eps input.pdf output.pdf

Simulator

Try the following to diagnose your problem.

% simulator.tex
\documentclass[preview,border=12pt]{standalone}
\usepackage{filecontents}

\begin{filecontents*}{input.tex}
\documentclass[preview,border=12pt]{standalone}
\usepackage{tikz}
\begin{document}
This is a TikZ output.
\begin{tikzpicture}
    \draw (0,0) circle (2);
\end{tikzpicture}
\tikz\fill[red] (0,0) ellipse (3pt and 5pt); is an ellipse. 
\end{document}
\end{filecontents*}

\immediate\write18{pdflatex input}
\immediate\write18{pdftops -f 1 -l 1 -eps input.pdf output.eps}

\usepackage{graphicx}
\begin{document}
I am importing EPS image.\\
\includegraphics{output}
\end{document}

enter image description here

Compile the code above with

latex -shell-escape simulator
dvips simulator
ps2pdf -dAutoRotatePages=/None simulator.ps

As ps2pdf sometimes rotates the output automatically, please use -dAutoRotatePages=/None to prevent it from doing such an unwanted rotation.

If you are using Windows, use # instead of = in -dAutoRotatePages=/None because = has a special meaning for batch files in Windows.

Very important notes

If you use opacity in your TikZ code (PSTricks code as well), for example,

\documentclass[preview,border=12pt]{standalone}
\usepackage{tikz}
\begin{document}
This is a TikZ output.
\begin{tikzpicture}
    \draw (0,0) circle (2);
\end{tikzpicture}
\tikz\fill[red,fill opacity=.5] (0,0) ellipse (3pt and 5pt); is an ellipse. 
\end{document}

then you will get a rasterized output as follows.

enter image description here

  • 1
    I have the same problem with pdftops or pdf2ps as with convert. – Balazs Sep 22 '13 at 17:29
  • 1
    Ok, it works. pdftops is the solution. Thank you very much. I thought pdftops is not working because I only looked at the eps in an image viewer. When I included it in a latex file and generated the pdf with pdflatex, I got perfect result. Thanks again! – Balazs Sep 22 '13 at 18:05
  • For those coming to this answer unaware of the provenance of pdftops, it belongs to the xpdf package. macOS users can install it using homebrew: brew install xpdf – chb Feb 24 at 8:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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