YAML header

reference_docx

The argument reference_docx (see ?rmarkdown::word_document) lets you to use styles and settings from a template which is a Word document (*.docx).

The R Markdown documentation on this topic is available via:
https://bookdown.org/yihui/rmarkdown/word-document.html

Taking full advantage of the package’s capabilities requires the use of document templates in which various styles and formatting parameters are stored.

You can create or re-use a Microsoft Word document that will be used as template (ex: “template.docx”); it will contain the lists definitions, the table styles, the title and paragraph styles, default fonts and many other settings.

Usage

This template will be used as a reference document for the customization of your list style with R Markdown. To use this feature, specify the reference_docx option in YAML.

By default, your YAML header looks like this:

---
date: "2020-06-29"
author: "superman"
title: "Document title"
output: 
  officedown::rdocx_document
---

Add reference_docx argument to the YAML:

---
date: "2020-06-29"
author: "superman"
title: "Document title"
output: 
  officedown::rdocx_document:
     reference_docx: template.docx
---

When using bookdown, it should be:

---
date: "2020-06-29"
author: "superman"
title: "Document title"
output: 
  bookdown::markdown_document:
    base_format: "officedown::rdocx_document"
    reference_docx: template.docx
---

Settings and default values

There is a mechanism to overwrite the defaults with the specified values. This makes it possible not to fill in all the arguments. Thus, a header like the following one is valid:

# officedown yaml header
output: 
  officedown::rdocx_document:
    tables:
      caption:
        pre: 'tab. '

Default settings

The package is using global settings, used for customization of tables, lists, plots and captions.

Default values are presented below in their YAML format.

# full default yaml header
output: 
  officedown::rdocx_document:
    tables:
      style: Table
      layout: autofit
      width: 1.0
      caption:
        style: Table Caption
        pre: 'Table '
        sep: ': '
      conditional:
        first_row: true
        first_column: false
        last_row: false
        last_column: false
        no_hband: false
        no_vband: true
    plots:
      style: Normal
      align: center
      caption:
        style: Image Caption
        pre: 'Figure '
        sep: ': '
    lists:
      ol.style: null
      ul.style: null

Default values are detailled in the help page of rdocx_document, see details with command:

?officedown::rdocx_document