在 RMarkdown 文档的 R 包中包含 TeX 标头 [英] Include TeX header in R package for RMarkdown documents

查看:36
本文介绍了在 RMarkdown 文档的 R 包中包含 TeX 标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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)?

解决方案

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.

这篇关于在 RMarkdown 文档的 R 包中包含 TeX 标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆