29

By default the PDF documents created by the Knit PDF are US Letter size. Instead I would like to create A4 size documents. I have a feeling this should simple to change, either in the RStudio GUI or by adding an option to the metadata at the top of the Rmd file. Unfortunately I can't find any instructions how to do this. Is there a way to specify paper size, preferably within the Rmd file itself? I am still using RStudio version 0.98.953 but can upgrade if it would help.

I'd be grateful if someone could point me in the right direction.

hrbrmstr
  • 77,368
  • 11
  • 139
  • 205
Nicholas
  • 1,416
  • 1
  • 15
  • 15

2 Answers2

41

OK, so I figured it out. In the .Rmd file's header, options documentclass and classoption get written into the preamble of the resulting .tex file. The article document class accepts a number of paper size options including a4paper. The header in the .Rmd file will then look something like this:

---
title: "Title"
author: "Name"
date: "Date"
output:
  pdf_document
documentclass: article
classoption: a4paper
---

For more information see: http://rmarkdown.rstudio.com/pdf_document_format.html

Nicholas
  • 1,416
  • 1
  • 15
  • 15
  • How would you add a4paper and landscape? Documentclass can be repeated, according to your link, but when I do this R throws an error? Happy to open a new question if appropriate... – user2716568 Jun 16 '17 at 10:10
  • You can have more than one `classoption` by separating multiple options with commas or by using a bulleted list, as discussed in [this SO answer](https://stackoverflow.com/a/47171650/496488). – eipi10 Nov 08 '17 at 04:49
13

At least in newer versions of the rmarkdown R package (and Pandoc) you can just set:

---
output: pdf_document
papersize: a4
---
Salim B
  • 2,409
  • 21
  • 32