[英]Enforce PDF package vignette with knitr
I have a vignette for my package which compiles to a nice PDF when compiled with Rscript -e 'rmarkdown::render("tmod.rmd")'
. 我有一个关于我的包的插图,当使用
Rscript -e 'rmarkdown::render("tmod.rmd")'
编译时,它编译成一个漂亮的PDF。 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. 但是,当我编译并安装软件包时,启动R并输入
vignette("mypackagename")
,浏览器窗口打开时带有难看的HTML,没有标题,没有目录和没有引用。
However, if I compile the vignette manually to pdf before creating the package, it shows up just fine. 但是,如果我在创建包之前手动将小插图编译为pdf,它会显示正常。
What went wrong? 什么地方出了错? Why is my PDF not generated automatically when I compile the package?
为什么编译包时我的PDF不会自动生成?
In the markdown file header, I have 在markdown文件标题中,我有
---
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
When I asked the same question on the knitr google group, Yihui Xie (author of knitr) replied: 当我在knitr google小组上问同样的问题时,谢毅辉(编织家的作者)回答说:
Use the vignette engine knitr::rmarkdown instead of knitr::knitr.
使用晕图引擎knitr :: rmarkdown而不是knitr :: knitr。
I'm not entirely sure I understand why, but it works. 我不完全确定我理解为什么,但它确实有效。 Here is a link to discussion on the knitr google group.
以下是针对knitr google群组的讨论链接 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.