Cannot include figures via R/Sweave/LaTeX

I am trying to create a pdf vs R/Sweave/LaTeX that will include a plot. Here is the relevant snippet from my .Rnw file:

begin{figure}
begin{center}
<<fig=TRUE,echo=FALSE>>=
makeMyPlot()
@
end{center}
label{fig:one}
end{figure}

When I run Sweave it generates a .pdf file named "analysis report-005.pdf" and a .tex file including the following line:

includegraphics{analysis report-005.pdf}

So far, so good. But when I run

tools::texi2pdf('analysis report.tex')

I get this error

Error: running 'texi2dvi' on 'analysis report.tex' failed

LaTeX errors:
:218: LaTeX Error: File `analysis report-005' not found.

It looks like texi2pdf is failing to find the file because the extension, ".pdf", is not stated in the .tex file output. When I add ".pdf" directly to the relevant line of the .tex file, the error goes away. However, I shouldn't need to do this manually. I'm not sure if this is a problem with Sweave or texi2pdf; I suspect the latter. How can I fix it?

链接地址: http://www.djcxy.com/p/26918.html

上一篇: 在for中插入多个图像

下一篇: 不能通过R / Sweave / LaTeX包含数字