我在RStudio中使用针织品和RStudio。我使用块缓存,这样我就不必每次编译文档时都重新运行某些代码。这个最小的示例显示,如果加载了fontspec包,缓存就会中断。
\documentclass{article}
\usepackage{fontspec} % Appears to somehow conflict with caching.
\begin{document}
<<pre_load, cache=TRUE>>=
library(tikzDevice)
options(tikzDefaultEngine="xetex")
@
\section{Test}
<<test_block, dev='tikz', dependson='pre_load'>>=
plot(1:10,main='Test')
@
\end{document}当这个文档第一次被编译成PDF时,它会工作,因为没有使用缓存。但是,如果对test_block块进行了更改,并且第二次运行代码,那么它将失败。例如,编译一次后,将test_block块更改为:
<<test_block, dev='tikz', dependson='pre_load'>>=
plot(1:10,main='Test Modified')
@现在,编译为PDF失败了,有以下错误:
!
********************************************
* XeTeX is required to compile this document.
* Sorry!
********************************************.
\RequireXeTeX ...********************************}
\endgroup \fi
l.18 \RequireXeTeX此错误表示尚未设置options(tikzDefaultEngine="xetex")。有趣的是,如果没有加载fontspec包,则不会发生此错误。
我的问题是:这是一个bug,还是我的代码有什么问题?
我使用tikzDevice (0.6.3)通过RStudio (0.97.246) (通过浏览器通过RStudio服务器访问)对R (R正在开发(不稳定) (2012-11-10 r61101))使用,后者本身运行在Ubuntu (12.04.2LTS)上。我的LaTeX2e的日期是<2009/09/24>。
发布于 2013-03-04 20:38:39
不要将options(tikzDefaultEngine="xetex")放入缓存的块中,因为它具有无法缓存的副作用,因此在第二次编译文档时,将跳过此选项。阅读缓存页中的重要注释网站上的knitr一节。
注意,您也不需要library(tikzDevice);当您设置dev='tikz'时,这个包将自动加载。
在大多数情况下,您应该缓存绘图块,因为创建TikZ图形的速度很慢。
\documentclass{article}
\usepackage{fontspec} % Appears to somehow conflict with caching.
\begin{document}
<<pre_load>>=
options(tikzDefaultEngine="xetex")
@
\section{Test}
<<test_block, dev='tikz'>>=
plot(1:10,main='Test')
@
\end{document}https://stackoverflow.com/questions/15205263
复制相似问题