Regulate how many PDF pages is to be displayed per page in when knitting to PDF in Rmarkdown?

Viewed 18

I have a rmarkdown document where I import a few PDFs, and I would like to display four PDF-import-pages per page in my knitted PDF.

---
title: "combinePages"
author: "xxx"
date: '2022-xx-xx'
output: 
  pdf_document:
    toc: true
header-includes:
  - \usepackage{pdfpages}
---
\includepdf[pages={-}]{pdfs/Lecture1.pdf}
\includepdf[pages={-}]{pdfs/Lecture2.pdf}

Can this be done in rmarkdown?

1 Answers

According to the manual of pdfpages,

nup => Puts multiple logical pages onto each sheet of paper. The syntax of this option is: nup=⟨xnup⟩x⟨ynup⟩. Where ⟨xnup⟩ and ⟨ynup⟩ specify the umber of logical pages in horizontal and vertical direction, which are arranged on each sheet of paper. (Default: nup=1x1)

So, four pdf pages from an imported pdf file can be knitted per page using nup=2x2 in the option of \includepdf.


---
title: "combinePages"
author: "xxx"
date: '2022-xx-xx'
output: 
  pdf_document:
    toc: true
header-includes:
  - \usepackage{pdfpages}
---

## Multiple Page

\includepdf[pages={1-}, nup=2x2]{lorem_ipsum.pdf}

\includepdf[pages={1-}, nup=2x2]{lorem_ipsum.pdf}


So A page of the rendered document looks like this,

four_page_in_one


Explore the manual for more options.

Related