R Studio change pandoc .tex template

2019-04-10 21:42发布

问题:

I want to use a different latex template for rendering R markdown version 2.

I found the following suggestions:

a) location of template

system.file("rmd/latex/default.tex", package="rmarkdown)

b) change of YAML front matter

---
...
output:
   pdf_document:
      template: mytemplate.tex
---

However, his does not seem to be the correct template location for R Studio/ Pandoc, as I get the following error message:

pandoc.exe: Could not find data file templates\mytemplate.tex

回答1:

Ok, I think I have the answer, the default directory for Pandoc can be found here:

system("pandoc -v")

If the folder does not exist, create it as well as a subfolder called templates and copy your tex template here.

You can see the original template here:

system("pandoc -D latex")


回答2:

Not sure if you figured it out or not but this may be a useful link. http://rmarkdown.rstudio.com/developer_document_templates.html I am finding myself in the same boat as you wanting to create a custom template to output to PDF.



回答3:

Just put the style.tex file in the same folder as the markdown file does now works for me.