如何减少sweave中的图像大小?

时间:2012-04-25 03:28:19

标签: sweave

如何减少sweave中的图像尺寸?

\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}

此致

1 个答案:

答案 0 :(得分:4)

尝试knitr而不是Sweave。请参阅out.widthout.height options

您的示例如下所示:

\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}