Dennis Fisher
2004-Dec-17 14:45 UTC
[R] Is the page number in a document created with "pdf()" accessible?
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
Marc Schwartz
2004-Dec-17 15:33 UTC
[R] Is the page number in a document created with "pdf()" accessible?
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. HTH, Marc Schwartz
Prof Brian Ripley
2004-Dec-17 17:24 UTC
[R] Is the page number in a document created with "pdf()" accessible?
On Fri, 17 Dec 2004, Dennis Fisher wrote:> When I create pdf documents in R using pdf(), each page has text in the outer > margin indicating the page number.It neither has an outer margin nor anything there, unless you added code to do this. I guess your PDF viewer is adding this.> 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?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. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595