To create an RTF document from R Markdown you specify the rtf_document
output format in the front-matter of your document:
---
title: "Habits"
author: John Doe
date: March 22, 2005
output: rtf_document
---
You can define the document export path by specifying path
option. For example:
---
title: "Habits"
output:
rtf_document:
path: /Exports/Habits.rtf
---
If path
is not defined, then document will be generated under the same directory.
You can add a table of contents using the toc
option and specify the depth of headers that it applies to using the toc_depth
option. For example:
---
title: "Habits"
output:
pdf_document:
toc: true
toc_depth: 2
---
If the table of contents depth isn’t explicitly specified then it defaults to 3 (meaning that all level 1, 2, and 3 headers will be included in the table of contents).
Attention: this TOC is different from the <!-- toc -->
generated by Markdown Preview Enhanced.
If there are pandoc features you want to use that lack equivalents in the YAML options described above you can still use them by passing custom pandoc_args
. For example:
---
title: "Habits"
output:
rtf_document:
pandoc_args: [
"--csl", "/var/csl/acs-nano.csl"
]
---
If you want to specify a set of default options to be shared by multiple documents within a directory you can include a file named _output.yaml
within the directory. Note that no YAML delimeters or enclosing output object are used in this file. For example:
_output.yaml
rtf_document:
toc: true
All documents located in the same directory as _output.yaml
will inherit it’s options. Options defined explicitly within documents will override those specified in the shared options file.