3.4 Word document
To create a Word document from R Markdown, you specify the word_document
output format in the YAML metadata of your document:
---
title: "Habits"
author: John Doe
date: March 22, 2005
output: word_document
---
The most notable feature of Word documents is the Word template, which is also known as the “style reference document”. You can specify a document to be used as a style reference in producing a *.docx
file (a Word document). This will allow you to customize things such as margins and other formatting characteristics. For best results, the reference document should be a modified version of a .docx
file produced using rmarkdown or Pandoc. The path of such a document can be passed to the reference_docx
argument of the word_document
format. Pass "default"
to use the default styles. For example:
---
title: "Habits"
output:
word_document:
reference_docx: my-styles.docx
---
For more on how to create and use a reference document, you may watch this short video: https://vimeo.com/110804387, or read this detailed article: https://rmarkdown.rstudio.com/articles_docx.html.
3.4.1 Other features
Refer to Section 3.1 for the documentation of most features of Word documents, including figure options (Section 3.1.5), data frame printing (Section 3.1.6), syntax highlighting (Section 3.1.4), keeping Markdown (Section 3.1.10.1), Markdown extensions (Section 3.1.10.4), Pandoc arguments (Section 3.1.10.5), and shared options (Section 3.1.11).