It works if you separate the print command and put the caption placement in the print command , see below:
\documentclass[11pt,a4paper]{article} \usepackage{Sweave} \begin{document} <<>>= x = runif(100, 1, 10) y = 2 + 3 * x + rnorm(100) @ <<echo=FALSE,results=tex>>= library(xtable) p <- (xtable(summary(lm(y~x)),align="rcccc", caption="Summary statistics for the regression model", label="tab:summary", digits=2)) print( p, caption.placement="top" ) @ \end{document} Rgds, Rainer On Friday 18 November 2011 09:33:07 ren...@vannieuwkoop.ch wrote: > Dear All > > I am running Sweave with xtable and want to put the caption placement > on top. But this does not work. Any idea what is going wrong? > > Here is an example that runs properly with the exception of the > caption placement in the pdf-file. > > \documentclass[11pt,a4paper]{article} > \usepackage{Sweave} > \begin{document} > <<>>= > x = runif(100, 1, 10) > y = 2 + 3 * x + rnorm(100) > @ > > <<echo=FALSE,results=tex>>= > library(xtable) > print(xtable(summary(lm(y~x)), > align="rcccc", > caption="Summary statistics for the regression model", > caption.placement="top", label="tab:summary", > digits=2)) > > @ > > \end{document} > > > Renger > > > _________________________________________ > Renger van Nieuwkoop > Centre for Energy Policy and Economics, ETH Zürichbergstrasse 18 (ZUE) > CH - 8032 Zürich > +41 44 632 02 63 > mailto: ren...@vannieuwkoop.ch > blog.modelworks.ch > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html and provide commented, > minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.