共享与输出无关的配置选项

mat*_*fee 5 r r-markdown

在rmarkdown中,您可以创建一个_output.yaml仅具有输出格式的通用选项的文件(参考)

html_document:
    toc: true
    pandoc_args: ['--base-header-level', 2]
pdf_document:
    toc: true
    pandoc_args: ['--base-header-level', 2]
Run Code Online (Sandbox Code Playgroud)

我的问题是,是否可以在_output.yaml中共享非输出选项?更接近标准rmarkdown中用作frontmatter的格式.

例如:

bibliography: ../library.bib
author: me
output:
    html_document:
        toc: true
        pandoc_args: ['--base-header-level', 2]
    pdf_document:
        toc: true
        pandoc_args: ['--base-header-level', 2]
Run Code Online (Sandbox Code Playgroud)

这样我render在该目录中的任何文件都会自动获得作者'我',指定的参考书目路径和输出选项?(目前如果我这样做,它会抱怨一个eval电话,基本上是试图评估我的第一个选项的价值."object '..' not found").

避免在单个文件中复制某些非输出格式特定的选项(例如作者,参考书目)会很方便.

我知道我可以通过(ab)使用来解决这个问题pandoc_args,因为它是特定于格式的,在放入时会起作用_output.yaml.例如,["--bibliography", "./library.bib", "--variable", "author:me"]在这种情况下会起作用,但可能并非在所有情况下都适用.

如果我可以将多个文档串在一起以连接成单个文档,这也可以解决; 这是做什么的pandoc.例如pandoc config.yaml chapter1.md chapter2.md有效,但render(c('config.yaml', 'chapter1.md', 'chapter2.md'))没有.

旁白:有没有办法为所有输出格式设置默认选项(例如,我想toc: true默认使用所有输出格式)而不必复制它?