在rmarkdown中,您可以创建一个文件_output.yaml
,该文件只有输出格式的常用选项(reference)
html_document:
toc: true
pandoc_args: ['--base-header-level', 2]
pdf_document:
toc: true
pandoc_args: ['--base-header-level', 2]
我的问题是,是否可以在_output.yaml中共享非输出选项?更接近标准rmarkdown中用作frontmatter的格式。
e.g:
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]
这样我在该目录中的任何文档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
没有。
除此之外:有没有办法为所有输出格式设置默认选项(例如,我希望默认情况下对所有输出格式使用{{1}})而不必复制它?