如何将 tex 模板传递给 Rmarkdown?

How do I pass a tex template to Rmarkdown?

我想 rmarkdown/knitr 使用自定义 tex 模板创建 pdf 输出。

可以通过以下方式覆盖 pandoc 默认值:

output: 
  pdf_document:
    pandoc_args: '--pdf-engine=xelatex'
---

但是当我添加更多命令时它不起作用:

'--pdf-engine=xelatex --template template.tex'

错误:

Unknown option --template template.tex .

更简单的解决方案:

mainfont: Minion Pro
output: 
  pdf_document:
    latex_engine: xelatex
---