Skip to content

pdf() and pdflatex

2 messages · Frank E Harrell Jr, Brian Ripley

#
I am having good success in using pdf() to produce pdf graphics files for inclusion in documents processed by pdflatex [I'm using R 1.6.0 on Linux].  I am having one small problem consistently though, which I believe I also had with S-Plus's pdf.graph(): wasted space at the top of the graph which causes pdflatex to put the graph on a later page, when the current page has plenty of space.

Here is how I typically call pdf( ):

pdf(filename, width=5.333, height=4,     pointsize=10,family='Helvetica',onefile=FALSE)
par(lwd = lwd, mgp = c(2.5, .6, 0),
    mar = c(3.5, 3.5, 1, 1) + 1.e-10, bty='l')
par(smo=0)
plot( . . .)
dev.off()

Here is how I include the graphics file in LaTeX:

\usepackage{graphics}
...
\begin{figure}[hb]\leavevmode\centerline{\includegraphics{mygraph.pdf}}
\caption{A caption}
\label{fig:mygraph}
\end{figure}

I need onefile=FALSE because some of the high-level graphics commands I use produce more than one page of output.  I am using pdflatex rather than including postscript files with latex so that I can use the hyperref style for pdflatex.

Has anyone had this problem or have a suggested solution?  Thanks in advance.
#
The pdf driver uses the MediaBox as the specified device size, just as the
postscript() driver uses the device size for the bounding box.

That appears to work correctly for me with pdflatex and graphicx.  Space
that would appear on the screen will also appear on the pdf file.
I've just run a test and latex/dvips with .eps and pdflatex with .pdf
seem to give identical page layouts.
On Fri, 8 Nov 2002, Frank E Harrell Jr wrote: