0

My package has a PDF file which I'd like to include as a vignette. There are guides on the internet for doing that with Sweave and R.rsp, but I'd like to use knitr as the vignette engine because we are writing another vignette in Rmd.

My latest attempt has file.pdf and file.pdf.asis inside the vignettes/ folder, with the latter containing these two lines:

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

FWIW, if I use R.rsp as an engine, the second line above can simply contain %\VignetteEngine{R.rsp::asis} and that vignette builds fine, so one suspicion I have is that I am simply using the wrong knitr equivalent.

I've also tried some monstrosities involving a mix of a YAML header and LaTeX inclusion of the PDF, which didn't work either:

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

\includepdf{file.pdf}
Waldir Leoncio
  • 10,853
  • 19
  • 77
  • 107

1 Answers1

1

Thanks to the power of open-source software, I was able to run browseVignettes(), go through my installed packages containing a mix of HTML and PDF vignettes, 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 vignette engines.

So my package's DESCRIPTION now includes:

VignetteBuilder: R.rsp, knitr

and I have an Rmd vignette containing %\VignetteEngine{knitr::rmarkdown} on its YAML header and a file.pdf.asis containing %\VignetteEngine{R.rsp::asis}.

Waldir Leoncio
  • 10,853
  • 19
  • 77
  • 107