2012-04-25 101 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}