[Tikzdevice-bugs] TikzDevice and non-pdf output

Charlie Sharpsteen source at sharpsteen.net
Mon Jan 31 21:36:05 CET 2011


On Mon, Jan 31, 2011 at 2:34 AM, Lorenzo Isella <lorenzo.isella at gmail.com>wrote:

> Dear All,
> I normally produce my plots with ggplot2+tikzDevice and I am pretty happy
> with this. My output is usually a pdf, however, there are journal asking you
> to submit the artwork as a tiff or an eps file.
> How can they be produced with tikzDevice? In particular, I refer to eps
> files.
> My goal is to produce them on the fly, rather than convert a pdf into
> another format (the cure may be worse than the disease...).
> Any suggestion is appreciated and I can produce a small example (leading to
> a pdf) if needed for the discussion.
> Best Regards
>
> Lorenzo
>

Hi Lorenzo,

There are many command-line utilities available for converting between file
formats.  The TikZ manual suggests using `pdftops` which is a utility
included with XPDF and Poppler.   These could be used programmatically from
R:

     require(tikzDevice)
     require(tools)

     tikz('test.tex', standAlone = TRUE)
     plot(1)
     dev.off()

     texi2dvi('test.tex', pdf = TRUE)
     system('pdftops -eps test.pdf test.eps')


In general, there is also the `convert` utility from ImageMagick or
GraphicsMagick which can convert between pretty much anything.  When
converting PDF files, set the `-density` option to 300 pixels per inch or
higher to get nice crisp output:

    system('convert -density 300 test.pdf test.tiff')
    system('convert -density 300 test.pdf test.eps')


Hope this helps!

-Charlie


More information about the Tikzdevice-bugs mailing list