knitr - ! LaTeX错误:找不到文件`figure / unnamed-chunk-1'

时间:2022-12-29 06:13:57

I'm new to knitr and to Latex.

我是knitr和Latex的新手。

I keep getting the error "! LaTeX Error: File `figure/unnamed-chunk-1' not found." The error message says:

我一直收到错误“!LaTeX Error:找不到文件`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

I have a simple tex file

我有一个简单的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}  

I cannot seem to locate anything that seems relevant. Clearly "figure/unnamed-chunk-1" should be showing up somewhere but I don't see anything in the knitr options document to suggest a specific way to save it and so far I don't understand enough about knitr to figure out a way to name a plot to be imported.

我似乎无法找到任何看似相关的东西。很明显,“figure / unnamed-chunk-1”应该出现在某个地方,但是我没有在knitr选项文档中看到任何建议用于保存它的具体方法,到目前为止我还没有完全了解knitr找出一个命名要导入的绘图的方法。

1 个解决方案

#1


1  

It has been solved in the knitr mailing list. The problem was due to use of absolute paths in the output argument in knit(), so figures and tex output were not in the same directory. It is not recommended to use absolute paths in general; see more discussion in the mailing list.

它已在knitr邮件列表中得到解决。问题是由于在knit()的输出参数中使用绝对路径,因此数字和tex输出不在同一目录中。一般不建议使用绝对路径;在邮件列表中查看更多讨论。

#1


1  

It has been solved in the knitr mailing list. The problem was due to use of absolute paths in the output argument in knit(), so figures and tex output were not in the same directory. It is not recommended to use absolute paths in general; see more discussion in the mailing list.

它已在knitr邮件列表中得到解决。问题是由于在knit()的输出参数中使用绝对路径,因此数字和tex输出不在同一目录中。一般不建议使用绝对路径;在邮件列表中查看更多讨论。