更新时间:2023-10-25 17:39:58
问题是output
字段中的参数只有rmarkdown能理解.Pandoc 不理解它们,因此您需要确保 rmarkdown 可以评估表达式.由于 rmarkdown 使用 yaml 包来读取 YAML 元数据,而 yaml 的 R 表达式语法是 !expr
,可以把R表达式放在!expr
之后,eg
The problem is that the parameters in the output
field is only understood by rmarkdown. Pandoc does not understand them, so you need to make sure rmarkdown can evaluate the expression. Since rmarkdown uses the yaml package to read the YAML metadata, and yaml's syntax for R expressions is !expr
, you can put the R expression after !expr
, e.g.
output:
word_document:
fig_caption: yes
fig_height: 4
fig_width: 7
reference_docx: !expr file.path(Sys.getenv('USERPROFILE'), 'Documents', 'template.docx')