How to change the paper size in a rmarkdown word_document?

Viewed 575

I have some wide result tables I need to share in a (sad) word document. I noticed they fit well in A3 format. Many answers (How can I change paper size when using Knit PDF in RStudio?, Change paper size and orientation in an rmarkdown pdf, How to specify a customized paper size in r markdown, Change paper size and orientation in an rmarkdown pdf) explain how to change the paper size for output:pdf_document. Is is possible to change the paper size for output:word_document, more specifically output: bookdown::word_document2?

Reproducible example where I place papersize: a3 in the rmarkdown yaml front header:

---
title: "test A3 paper"
papersize: a3
output:
    word_document
---

# Title

generate this document with:

    rmarkdown::render("a3.Rmd")

The output word document is still in the default US letter format, not in A3.

1 Answers

I would prefer another answer if it's possible to avoid creating a reference document.

Edit the word document that was generated by rmarkdown::render and change the format to A3. Save it under a new name, for example "a3_template.docx". Then modify the yaml front matter to call a reference document:

---
title: "test A3 paper"
output:
  word_document:
    reference_docx: a3_template.docx
---
Related