Enforce PDF package vignette with knitr

假装没事ソ 提交于 2019-12-01 16:06:09

问题


I have a vignette for my package which compiles to a nice PDF when compiled with Rscript -e 'rmarkdown::render("tmod.rmd")'. However, when I compile and install the package, start R and type vignette("mypackagename"), a browser window opens with ugly looking HTML, without a title, without a table of contents and without references.

However, if I compile the vignette manually to pdf before creating the package, it shows up just fine.

What went wrong? Why is my PDF not generated automatically when I compile the package?

In the markdown file header, I have

---
title: "foo foo foo"
author: "Foofooary Finer"
date: "`r Sys.Date()`"
output:
  pdf_document:
vignette: >
  %\VignetteIndexEntry{FooFoo}
  %\VignetteKeyword{foo}
  %\VignetteEngine{knitr::knitr}
  %\SweaveUTF8
  \usepackage[utf8](inputenc)
abstract: |
  foo foo foo foo foo
toc: yes
bibliography: bibliography.bib
---

In the package DESCRIPTION file, I have

VignetteBuilder: knitr
Suggests: knitr

回答1:


When I asked the same question on the knitr google group, Yihui Xie (author of knitr) replied:

Use the vignette engine knitr::rmarkdown instead of knitr::knitr.

I'm not entirely sure I understand why, but it works. Here is a link to discussion on the knitr google group.



来源:https://stackoverflow.com/questions/30936969/enforce-pdf-package-vignette-with-knitr

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