Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Column names on each page with xtable in Sweave

I want to have column names on each page of the xtable.

\documentclass{article}
\usepackage{graphicx}   
\usepackage{longtable}

\begin{document}

<<>>=
x <- matrix(rnorm(1000), ncol = 10)
x.big <- xtable(x,label='tabbig',caption='Example of longtable spanning several pages')
@

<<label = tabSEM.S, echo = FALSE, results = tex >>=
print(x.big,tabular.environment='longtable',floating=FALSE)
@

\end{document}

Any help will be highly appreciated. Thanks

like image 618
MYaseen208 Avatar asked Jan 01 '12 00:01

MYaseen208


1 Answers

I think this is really a LaTeX question, which I simply Googled and ended up with a simple answer from tex.stackexchange.com here.

Try this (untested in LaTeX; will be curious if this compiles the way you want):

print(x.big,tabular.environment='longtable',
        floating=FALSE,
        hline.after = c(-1,nrow(x.big)),
        add.to.row = list(pos = list(0),command = "\\hline \\endhead "))
like image 153
joran Avatar answered Sep 19 '22 20:09

joran