【发布时间】:2013-03-04 15:39:18
【问题描述】:
我在 RStudio 中使用 knitr 和 XeLaTeX。我使用块缓存,这样每次编译文档时都不必重新运行某些代码。这个最小的例子表明,如果加载了 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 块进行了更改,并且代码再次运行,它将失败。例如编译成PDF一次后,把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包没有被加载,那么这个错误就不会发生。
我的问题是:这是一个错误,还是我的代码有问题?
我正在通过 RStudio (0.97.246)(通过浏览器通过 RStudio 服务器访问)在 R(R 开发中(不稳定)(2012-11-10 r61101))上使用 knitr(1.1)和 tikzDevice(0.6.3)它本身在 Ubuntu (12.04.2 LTS) 上运行。我的 LaTeX2e 的日期为 。
【问题讨论】:
标签: r latex knitr rstudio fontspec