【发布时间】:2012-11-20 18:23:03
【问题描述】:
我是 knitr 和 Latex 的新手。
我不断收到错误“!LaTeX 错误:找不到文件‘figure/unnamed-chunk-1’。”错误消息说:
>! LaTeX Error: File `figure/unnamed-chunk-1' not found.
> See the LaTeX manual or LaTeX Companion for explanation.
> Type H <return> for immediate help.
...
> l.77 ...[width=\textwidth]{figure/unnamed-chunk-1}
> I could not locate the file with any of these extensions:
> .png,.pdf,.jpg,.mps,.jpeg,.jbig2,.jb2,.PNG,.PDF,.JPG,.JPEG,.JBIG2,.JB2,.eps
我有一个简单的 tex 文件
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage[font={small}]{caption}
\author{My Name }
\title{knitr example}
\begin{document}
\maketitle
<<loading,echo=F>>=
library(ggplot2)
@
<< message=F,fig.width=9,fig.height=6,out.width='\\textwidth',cache= TRUE>>=
mydata <- data.frame(year = seq(1901: 1950), debt = rnorm(50))
plot(mydata$year, mydata$debt, main = "Debt")
@
\end{document}
我似乎找不到任何相关的内容。显然“figure/unnamed-chunk-1”应该出现在某处,但我在 knitr 选项文档中没有看到任何建议保存它的具体方法,到目前为止,我对 knitr 的了解还不够,无法弄清楚命名要导入的绘图的方法。
【问题讨论】:
-
我无法重现该问题。你可以在
library(knitr)之后粘贴sessionInfo()吗?所有软件包都是最新的吗?我能想到的唯一可能的原因是您之前运行过一次但后来删除了figure目录;由于此块已缓存,因此除非进行任何更改,否则不会重新生成绘图。去掉cache=TRUE这个选项还能用吗?