Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
911 views
in Technique[技术] by (71.8m points)

r - 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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
---

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...