使用 knit('%.Rnw') 时,以下最小示例无法编译
\documentclass[]{article}
%opening
\title{STAT 520 Homework No. 1}
\author{Cheng Jia}
<<setup, include=FALSE, cache=FALSE>>=
library(knitr)
opts_chunk$set(dev='cairo_pdf', dev.args=list(family='Lekton'))
options(show.signif.stars=F)
@
\begin{document}
\maketitle
<<test,cache=TRUE,eval=TRUE,echo=FALSE>>=
a<-1
@
This is testing a=\Sexpr{a}.
\end{document}
错误消息如下:
Quitting from lines 18-19 (try.Rnw)
Error in pdf(NULL, width, height, ...) : unknown family 'Lekton'
Calls: knit ... chunk_device -> dev_new -> do.call -> <Anonymous> -> pdf
因此,knitr 似乎不再接受设备选项,因此它不使用 cairo_pdf 设备,而是使用默认的 pdf 设备。
知道发生了什么吗?
System:
Mac Os 10.9.4
R version: R version 3.1.1 (2014-07-10)
Knitr version: 1.6
The problem is solved by using the following setup:
System: Windows 7 SP1
R version: 3.1.0
Knitr version: 1.5
当我更新到最新的 Knit 和 R 时,似乎引入了一些不兼容性。
最佳答案
此问题是已知问题,已 fixed在 development version of knitr ,将在接下来的几周内在 CRAN 上发布 v1.7(如果需要,您可以从 Github 安装)。
关于r - knit 不接受 dev 的 opts_chunk 设置选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25634905/