Include TeX header in R package for RMarkdown documents

北城以北 提交于 2019-12-02 09:15:49

问题


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:

  1. How can I put a LaTeX-file in an R package so that it can be accessed later?
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!