1

似乎与新版本的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

编辑

我通过knitr在 github 上分叉 repo 来修改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
4

1 回答 1

0

我通过添加.Rprofile几行并更新tikzDevice到版本来解决这个问题tikzDevice_0.10-1

options(tikzMetricPackages = c("\\usepackage[utf8]{inputenc}",
                               "\\usepackage[T1]{fontenc}",
                               "\\usetikzlibrary{calc}",                   
                               "\\usepackage{amssymb}"
                              )
       )
于 2016-10-10T08:00:33.497 回答