[R] adding "Page X of XX" to PDFs
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Sat Dec 2 21:51:48 CET 2023
On 02/12/2023 2:07 p.m., Ben Bolker wrote:
> Sorry, jumped into the thread too late. (On the other hand, once the
> document gets complicated enough, it may be worth it in the long run to
> convert to something that actually has a document-generating back-end,
> rather than reinventing everything from scratch ...)
>
I agree with that comment. However, if one is stuck with a multipage
PDF file, and wants to add page numbering, you could use the LaTeX
pdfpages package.
For example, this R Markdown document includes all 10 plots from
Rplots.pdf on pages with "x of y" page numbering.
---
title: "Numbered"
output:
pdf_document:
extra_dependencies: ["pdfpages", "fancyhdr", "lastpage"]
---
\cfoot{Page \thepage\ of \pageref{LastPage}}
\addtocounter{page}{-1}
\includepdf[pages={1-10},pagecommand={\thispagestyle{fancy}}]{Rplots.pdf}
It would make more sense to do this in a LaTeX document, but I'm not
sure if Dennis knows LaTeX...
Duncan Murdoch
More information about the R-help
mailing list