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

标签 r yaml knitr r-markdown pandoc

我正在使用 rmarkdown 生成 word (.docx) 报告。我想更改目录的标题。这似乎是可能的,因为 pandoc_args在 doc 文件 (1) 的情况下,可以作为 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

这产生:

document without change in toc_title

最佳答案

目录的标题是document metadata ,因此您可以使用 YAML 元数据块对其进行设置。

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

或者用 -M 传入命令行标志。
---
title: "yaml header"
author: "cedric"
output:  
  word_document:
    toc: true
    pandoc_args: [
      "-M", "toc-title=Table des matières"
    ]
---

关于r - 我们如何在 rmarkdown 中将 pandoc_args 传递给 yaml header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47290659/

相关文章:

documentation - 记录 yaml

r - 如何在 Markdown 中调整 R 输出表的大小?

r - GGplot,将填充图案叠加到填充颜色上

从数据框中删除具有相同值的列

r - 当所需变量的数量未知时如何使用 tidyr::separate

r - googleUser.getAuthResponse().id_token 不返回 Shiny 的 id_token

python - 为什么 PyYAML 花费这么多时间来解析 YAML 文件?

amazon-web-services - 通过 CloudFormation 的 IAM 角色原则错误

r - 并排对齐多个表格

r - 控制编织文档中各列的编织器输出宽度