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

Ced*_*ric 9 yaml r pandoc knitr r-markdown

我正在使用rmarkdown生成一个单词(.docx)报告.我想改变toc的标题.这似乎是可能的,pandoc_args因为在doc文件(1)的情况下可以作为yaml头中的选项传递.但我做得不对.有人能提供一个有效的例子吗?

(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
Run Code Online (Sandbox Code Playgroud)

这会产生:

文档没有改变toc_title

TJ *_*ahr 19

目录的标题是文档元数据,因此您可以使用YAML元数据块进行设置.

---
title: "yaml header"
author: "cedric"
output:  
  word_document:
    toc: true
toc-title: "Table des matières"
---
Run Code Online (Sandbox Code Playgroud)

或者使用-M命令行标志传递它.

---
title: "yaml header"
author: "cedric"
output:  
  word_document:
    toc: true
    pandoc_args: [
      "-M", "toc-title=Table des matières"
    ]
---
Run Code Online (Sandbox Code Playgroud)