Skip to content
Prev 25103 / 398502 Next

pdf() and pdflatex

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.