问题
I want to create an R package containing a latex header file which would then be available from an RMarkdown document to create a PDF with slides via TeX. When I include a reference to the latex file in the header of the RMarkdown document, I can create my slides. But I do not know how to package it. So my two related questions are:
- How can I put a LaTeX-file in an R package so that it can be accessed later?
- How can I include the LaTeX file in a new RMarkdown document to create slides after loading the package (like a template)?
回答1:
Yes, you can. Do something like
---
output:
beamer_presentation:
includes:
in_header: my_header.tex
---
and the my_header.tex may be any (la)tex code, including package load and variable settings. You can also have before_body: and more.
If you just want packages loaded there is also a simpler way via yaml but I don't have that handy as I use the above mechanism more often.
来源:https://stackoverflow.com/questions/44941902/include-tex-header-in-r-package-for-rmarkdown-documents