[R] Is the page number in a document created with "pdf()" accessible?

Marc Schwartz MSchwartz at MedAnalytics.com
Fri Dec 17 16:33:14 CET 2004

On Fri, 2004-12-17 at 06:45 -0800, Dennis Fisher wrote:
> When I create pdf documents in R using pdf(), each page has text in the 
> outer margin indicating the page number.  I track page numbers in a 
> cumbersome manner.  Is the page number in a multi-page document tracked 
> internally by par() or some other function?

I am confused. Is the behavior of pdf() on Macs (I presume you are using
a Mac from your e-mail headers) different than on Linux?

If I create a single pdf() or postscript() document that contains
multiple plots using "onefile = TRUE", I do not get automatically
generated page numbers on each plot.

Are you embedding or reading the R generated PDF file in some other
application that reads the PDF file page sequence and then appends the
page number?

FWIW, a scan of the code in .../src/main/devPS.c, which I believe is
shared by the PDF device, indicates that the page counter variable
'pageno' is hard coded to start at 0 and increment by one for each new
page. Thus, it is not affected by other 'options' or 'pars'.

Unless I am missing something or the pdf() function behaves differently
on a Mac, I am not sure what and how you are seeing what you do.

In a vacuum, I would recommend that you create only one R plot per PDF
file, which would then enable you to control the page numbering in your
other application or to perhaps use pdflatex for greater control.


Marc Schwartz

More information about the R-help mailing list