Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change paper size and orientation in an rmarkdown pdf

I'd like to create a PDF using rmarkdown that is A3 (or 11x17, ideally) and in landscape orientation. I can get it to do one or the other by specifying options in the YAML header, but not both at the same time. Here's my best attempt - the classoption values each work individually, but not together:

---
title: "Test"
output: 
  pdf_document:
    toc: true
    number_sections: true
documentclass: article
classoption: 
  landscape
  a3paper
---

This question is related, but doesn't have the answer in this case. Thanks in advance for any help you can provide!

like image 482
Chris Newton Avatar asked Nov 08 '17 04:11

Chris Newton


People also ask

How do I change a document in R Markdown?

To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.

How do you markdown a PDF in R?

Having saved your R Markdown file, it's time to process it and generate a PDF file. You can do this by clicking the Knit PDF button above the text. Your PDF file will be generated and opened as shown below.

How do you knit a PDF in R Markdown?

When you press “Knit to PDF” in RStudio, it converts your R Markdown document into LaTeX. Download MiKTeX from here: https://miktex.org/download • Run the installer, and restart your computer. Open an R Markdown file in RStudio, and try knitting to PDF. You may be prompted to install some packages.

What are the three types of sections in an R Markdown document select three options?

The following sections dive into the three components of an R Markdown document in more details: the markdown text, the code chunks, and the YAML header.


1 Answers

It doesn't seem to be documented, but you can include more than one classoption by separating the options with commas or by using a bulleted list with hyphens. Either of the following will work:

---
title: "Test"
output: 
  pdf_document:
    toc: true
    number_sections: true
documentclass: article
classoption: 
  - landscape
  - a3paper
---


---
title: "Test"
output: 
  pdf_document:
    toc: true
    number_sections: true
documentclass: article
classoption: landscape, a3paper
---
like image 65
eipi10 Avatar answered Oct 29 '22 16:10

eipi10