Skip to content

xtable and sweave: caption placement problem

2 messages · Renger van Nieuwkoop, Brian Diggs

#
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: renger at vannieuwkoop.ch
blog.modelworks.ch
4 days later
#
On 11/18/2011 1:22 AM, renger at vannieuwkoop.ch wrote:
caption.placement is an argument to print.xtable, not xtable.

print(xtable(summary(lm(y~x)),
              align="rcccc",
              caption="Summary  statistics  for  the  regression  model",
              label="tab:summary",
              digits=2),
       caption.placement="top")