2012-04-25 102 views
4

如何減少圖像的大小?如何減少圖像尺寸?

\documentclass[a4paper]{article} 

\title{Sweave Example 1} 
\author{Friedrich Leisch} 

\begin{document} 

\maketitle 

In this example we embed parts of the examples from the 
\texttt{kruskal.test} help page into a \LaTeX{} document: 

<<>>= 
data(airquality) 
library(ctest) 
kruskal.test(Ozone ~ Month, data = airquality) 
@ 
which shows that the location parameter of the Ozone 
distribution varies significantly from month to month. Finally we 
include a boxplot of the data: 

\begin{center} 
<<fig=TRUE,echo=FALSE>>= 
boxplot(Ozone ~ Month, data = airquality) ## reduce image size so that can fit in window. 
@ 
\end{center} 

\end{document} 

問候

+0

我建議你使用一個不同的例子 - '庫(CTEST)'不中的R 2.15支持了。我是否還建議您粘貼示例代碼,以便可以在不進行重大編輯/重新格式化的情況下使用它? - 可能像'<< fig = true,width = 6,height = 4 >> ='這樣的東西可以提供幫助(參見Ross Ihaka,「定製Sweave」) – vaettchen 2012-04-25 05:50:49

回答

4

嘗試knitr代替Sweave。見out.widthout.heightoptions

你的榜樣應該是這樣的:

\documentclass[a4paper]{article} 

\title{Sweave Example 1} 
\author{Friedrich Leisch} 

\begin{document} 

\maketitle 

In this example we embed parts of the examples from the 
\texttt{kruskal.test} help page into a \LaTeX{} document: 

<<>>= 
data(airquality) 
library(ctest) 
kruskal.test(Ozone ~ Month, data = airquality) 
@ 
which shows that the location parameter of the Ozone 
distribution varies significantly from month to month. Finally we 
include a boxplot of the data: 

<<plot,fig.align="center",out.width="0.8\\linewidth",echo=FALSE>>= 
boxplot(Ozone ~ Month, data = airquality) ## reduce image size so that can fit in window. 
@ 

\end{document}