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)?
Yes, you can. Do something like
and the
my_header.tex
may be any (la)tex code, including package load and variable settings. You can also havebefore_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.