Wednesday, 9 June 2010

Fixing output from gnuplot's epslatex terminal

I noticed today that my thesis' pdf title was strange. I later realised this was because the title was that of the last figure that was included in my latex source. So with help from the guys in #latex on freenode I tracked down the problem to the .eps files produced by gnuplot.

This problem does not occur if you are using pdflatex, but if, like me, you are using latex followed by dvipdf or dvips, you'll need to fix the .eps files to prevent them overriding the global document settings (which you may have set using the hyperref package).

The issue was discussed on a mailing list in 2007 and I've created a bug report about it in the gnuplot bug tracker. As a quick fix I've written a small shell script which will remove a line to set the docinfo and prevent the problem occuring, which you can see below.


for epsFile in "$@"
sed '/\/DOCINFO pdfmark/d ' ${epsFile} > ${epsFile}.tmp
mv ${epsFile}.tmp ${epsFile}