How can we pass pandoc_args to yaml header in rmarkdown?

允我心安 提交于 2019-12-18 12:29:19

问题


I'm using rmarkdown to produce a word (.docx) report. I would like to change the header of the toc. This seems possible as pandoc_args can be passed as options in the yaml header in the case of a doc file (1). But I'm not doing it right. Could anyone provide a working example ?

(1) pandoc.args is included in the rmarkdown possible options and in the pandoc manual, there is a toc-title option

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

This produces :


回答1:


The title of the table of contents is document metadata, so you can set it with YAML metadata block.

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

Or passed it in with the -M command-line flag.

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


来源:https://stackoverflow.com/questions/47290659/how-can-we-pass-pandoc-args-to-yaml-header-in-rmarkdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!