How can I change paper size when using Knit PDF in RStudio?

流过昼夜 提交于 2019-12-03 06:47:44

问题


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.


回答1:


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:


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

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


来源:https://stackoverflow.com/questions/25866788/how-can-i-change-paper-size-when-using-knit-pdf-in-rstudio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!