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.

2 Answers 2

Reset to default

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

40

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

2
  • 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... Jun 16, 2017 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.
    – eipi10
    Nov 8, 2017 at 4:49
12

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

---
output: pdf_document
papersize: a4
---

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.