2014-10-26 90 views
1

如果我寫含有例如像圖簡單RNW文件,knitr和Sweave PDF文件名編號爲

\documentclass[11pt]{article} 

%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
<<setup, include=FALSE, cache=FALSE>>= 
opts_chunk$set(dev = "pdf", comment = NA, fig.path = "figure/", fig.align='center', cache=FALSE, message=FALSE, background='white') 
options(replace.assign=TRUE,width=85, digits = 8) 
knit_hooks$set(fig=function(before, options, envir){if (before) par(mar=c(4,4,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3)}) 
@ 

<<prepare-data, include=FALSE>>= 
@ 
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
\begin{document} 

A simple plot 
\begin{figure} 
<< scat, echo = FALSE, fig.width = 4.5, fig.height=3>>= 
plot(runif(10), runif(10), pch = 20) 
@ 
\end{figure} 
\end{document} 

爲什麼現在knitr創建一個PDF文件figure/scat-1.pdf而不是figure/scat.pdf

回答

0

原因在v1.7 release notes中有解釋。在開發版本(版本爲v1.8)中,您可以使用fig_chunk()來獲取數字文件名(請參閱包NEWS)。另見相關討論here

+0

非常感謝你一回!我猜,但無法找到信息。 – 2014-10-28 08:58:48

相關問題