我们如何在 rmarkdown 中将 pandoc_args 传递给 yaml header?

How can we pass pandoc_args to yaml header in rmarkdown?

我正在使用 rmarkdown 生成 word (.docx) 报告。我想更改目录的 header。这似乎是可能的,因为在 doc 文件 (1) 的情况下,pandoc_args 可以作为 yaml header 中的选项传递。但我做的不对。谁能提供一个工作示例?

(1) pandoc.args 包含在 rmarkdown 可能的选项中,在 pandoc 手册中,有一个 toc-title 选项

---
title: "yaml header"
author: "cedric"
output:  
  word_document:
   toc: true
pandoc_args: toc-title="Table des matières"
---
# One section
# Another

这会产生:

内容table的标题是document metadata,可以用YAML元数据块设置。

---
title: "yaml header"
author: "cedric"
output:  
  word_document:
    toc: true
toc-title: "Table des matières"
---

或者通过 -M command-line 标志传入。

---
title: "yaml header"
author: "cedric"
output:  
  word_document:
    toc: true
    pandoc_args: [
      "-M", "toc-title=Table des matières"
    ]
---