似乎与knitr和/或tikzDevice和/或R的新版本存在冲突。无论如何,我不能再让它起作用了。
这是一个MWE:
\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{tikz}
<<setup, include=FALSE, cache=FALSE>>=
library(knitr)
opts_chunk$set(fig.path='figure/graphics-',
cache.path='cache/graphics-',
fig.align='center',
dev='tikz'
)
@
\begin{document}
blop
<<>>=
plot(1:10)
@
\end{document}这将返回错误:
Quitting from lines 21-22 (testTikz.Rnw) Error in
tikzDevice::tikz(..., packages = c("\n\\nonstopmode\n", packages, :
unused argument (verbose = FALSE) Calls: knit ... chunk_device ->
dev_new -> do.call -> <Anonymous> -> <Anonymous>
Execution halted我使用的是R版本3.3.1,knitr_1.14和tikzDevice_0.8.1
编辑
我对github上的knitr回购进行了分叉,以修改tikz_dev函数以删除verbose参数。我现在得到以下错误:
Error in (function (file = ifelse(onefile, "./Rplots.tex", "./Rplot%03d.tex"), :
Graphics API version mismatch
Calls: knit ... do.call -> <Anonymous> -> do.call -> <Anonymous> -> .External发布于 2016-10-10 08:00:33
我在.Rprofile中添加了几行代码,并将tikzDevice更新为tikzDevice_0.10-1版本,从而获得了这个修复。
options(tikzMetricPackages = c("\\usepackage[utf8]{inputenc}",
"\\usepackage[T1]{fontenc}",
"\\usetikzlibrary{calc}",
"\\usepackage{amssymb}"
)
)https://stackoverflow.com/questions/39893919
复制相似问题