Skip to content

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

3 messages · Dennis Fisher, Marc Schwartz, Brian Ripley

#
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?

Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-8864)
Fax: 1-415-564-2220
www.PLessThan.com
#
On Fri, 2004-12-17 at 06:45 -0800, Dennis Fisher wrote:
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.

HTH,

Marc Schwartz
#
On Fri, 17 Dec 2004, Dennis Fisher wrote:

            
It neither has an outer margin nor anything there, unless you added code 
to do this.  I guess your PDF viewer is adding this.
It's in the PDF file (part of the definition of PDF) and is tracked by the 
device driver.

See ?plot.new / ?grid.newpage: you could use hooks to do the counting.