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

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

问题描述

我想创建一个包含乳胶头文件的R包,然后可以从RMarkdown文档中获得该文件,以通过TeX创建带有幻灯片的PDF.当我在RMarkdown文档的标题中包含对乳胶文件的引用时,可以创建幻灯片.但是我不知道如何打包.所以我的两个相关问题是:

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. 如何将LaTeX文件放在R包中以便以后可以访问?
  2. 在加载包(如模板)之后,如何在新的RMarkdown文档中包含LaTeX文件以创建幻灯片?

推荐答案

是的,可以.做类似的事情

Yes, you can. Do something like

---
output:
  beamer_presentation:
    includes: 
      in_header: my_header.tex
---

my_header.tex可以是任何(la)tex代码,包括程序包加载和变量设置.您还可以拥有before_body:等.

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.

如果您只想加载软件包,也可以通过yaml进行更简单的操作,但是由于使用上述机制更加频繁,所以我没有那么方便.

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.

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

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