简体   繁体   English

Knitr:添加 PDF 作为 vi.nette

[英]Knitr: adding a PDF as a vignette

My package has a PDF file which I'd like to include as a vi.nette.我的 package 有一个 PDF 文件,我想将其包含为 vi.nette。 There are guides on the inte.net for doing that with Sweave and R.rsp , but I'd like to use knitr as the vi.nette engine because we are writing another vi.nette in Rmd. inte.net 上有使用SweaveR.rsp执行此操作的指南,但我想使用knitr 作为 vi.nette 引擎,因为我们正在 Rmd 中编写另一个 vi.nette。

My latest attempt has file.pdf and file.pdf.asis inside the vi.nettes/ folder, with the latter containing these two lines:我最近的尝试在vi.nettes/文件夹中有file.pdffile.pdf.asis ,后者包含这两行:

%\VignetteIndexEntry{title}
%\VignetteEngine{knitr::asis_output}

FWIW, if I use R.rsp as an engine, the second line above can simply contain %\Vi.netteEngine{R.rsp::asis} and that vi.nette builds fine, so one suspicion I have is that I am simply using the wrong knitr equivalent. FWIW,如果我使用 R.rsp 作为引擎,上面的第二行可以简单地包含%\Vi.netteEngine{R.rsp::asis}并且 vi.nette 构建良好,所以我怀疑我只是使用错误的 knitr 等价物。

I've also tried some monstrosities involving a mix of a YAML header and LaTeX inclusion of the PDF, which didn't work either:我还尝试了一些涉及 YAML header 和 LaTeX 混合的 PDF 的怪兽,这也不起作用:

---
title: "title"
author: "yes"
output: pdf_document
vignette: >
  %\VignetteIndexEntry{title}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

\includepdf{file.pdf}

Thanks to the power of open-source software, I was able to run browseVi.nettes() , go through my installed packages containing a mix of HTML and PDF vi.nettes, and eventually check out the source code for the jsonlite package. This led me to a simple solution I thought about but immediately dismissed because I thought it wasn't possible: declare both knitr and R.rsp as vi.nette engines.感谢开源软件的强大功能,我能够通过包含 HTML 和 PDF vi.nettes 的安装包运行browseVi.nettes() 、go,并最终查看jsonlite package 的源代码。这引导我想到一个简单的解决方案,但我认为这是不可能的,所以立即被驳回:knitrR.rsp声明为 vi.nette 引擎。

So my package's DESCRIPTION now includes:所以我的包裹的DESCRIPTION现在包括:

VignetteBuilder: R.rsp, knitr

and I have an Rmd vi.nette containing %\Vi.netteEngine{knitr::rmarkdown} on its YAML header and a file.pdf.asis containing %\Vi.netteEngine{R.rsp::asis} .我有一个 Rmd vi.nette 包含%\Vi.netteEngine{knitr::rmarkdown}在它的 YAML header 和一个file.pdf.asis包含%\Vi.netteEngine{R.rsp::asis}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM