【问题标题】:How can we pass pandoc_args to yaml header in rmarkdown?我们如何将 pandoc_args 传递给 rmarkdown 中的 yaml 标头?
【发布时间】:2018-04-27 16:32:49
【问题描述】:

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

这会产生:

【问题讨论】:

    标签: r yaml knitr r-markdown pandoc


    【解决方案1】:

    目录的标题是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"
        ]
    ---
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-20
      • 2016-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-07
      • 1970-01-01
      • 2014-11-04
      相关资源
      最近更新 更多