Logo OS Reviews

Reviewing Freedom.



Unifying PDF with PostScript for LaTeX

Hendrik Weimer


Print version

Slashdot me! Digg me! Stumble me! del.icio.us

When using the LaTeX typesetting system it is often necessary to post-process graphics in order to have a consistent layout, especially when mathematical expressions are involved. Typical examples are labeling the axis of a graph or creating a legend of a figure. Although some programs like Gnuplot offer direct LaTeX export, the result is often sub-optimal and subsequent editing is a pain. Therefore, the usual way is to create PostScript files and alter them using the PSfrag package. This works fine unless you want to create PDF files. While you can convert you PostScript file to PDF you will lose any advanced PDF feature like in-document navigation and the fonts will probably look awful. You cannot simply use pdflatex because it does not understand the PostScript replacements made by PSfrag. After ages of converting each individual figure, manual tweaking and writing complicated makefiles, pst-pdf offers an clean solution to this problem.

pst-pdf consists of a LaTeX package that needs to be included in your documents via \usepackage and a simple shell script named ps4pdf that controls the creation of the PDF file. Apart from using the package and ps4pdf you do not need to take any further steps.

When you call ps4pdf it first calls LaTeX, in order to create a DVI file containing only the PostScript figures. These are converted to a PDF file using dvips (which does all the nasty stuff like PSfrag replacements) and ps2pdf. After this the main document is created using pdflatex, which simultaneously includes the images mentioned above. The resulting PDF file is all you need.

However, there are a few caveats. You cannot use any PostScript-related package, e.g. epsfig does not work. Anything based on PSTricks should work, as well as the \includegraphics command. The error messages can be rather cryptic because they often pop up only when the PDF file with the images is included. But at least the line number should be correct, so you get a hint where something went wrong.

Nevertheless pst-pdf works quite well out of the box. If you ever want to include PostScript figures in a PDF file, you can use it before any of the worries start to haunt you.

Distributions: [?]□ Debian stable□ Debian unstable
□ Fedora□ Mandriva
□ Suse□ Ubuntu


  • Use almost any PostScript feature
  • No manual intervention
  • Difficult troubleshooting

Copyright 2006–2008 OS Reviews. This document is available under the terms of the GNU Free Documentation License. See the licensing terms for further details.