开发者

header on each page of big table of xtable?

How do you put on a big table of xtable the table header on each page?开发者_如何学C, So that is easier to read the table the table between pages.

I use the following in Sweave:

test.big<- xtable(test,label="table",caption='test')
align(test.big) <- "|c|c|c|c|l|c|c|c|"
print(test.big,tabular.environment='longtable',include.colnames = TRUE,floating=FALSE)

Thanks for your answers


I think a better answer for this question is provided here: Column names on each page with xtable in Sweave

What if you want to edit your table in R? The solution above edits the output, so you won't need to add those lines in your longtable code manually. Thus this works better:

print(test.big, tabular.environment='longtable', include.colnames = TRUE,
floating=FALSE, add.to.row = list(pos = list(0), command = "\\hline \\endhead "))

Note that you can add several arguments in your add.to.row list:

print(test.big, tabular.environment='longtable', include.colnames = TRUE,
floating=FALSE, list(pos = list(seq(1,nrow(get(groups[i])), by = 2), 0),
command = c("\\rowcolor[gray]{.95} ","\\hline \\endhead ")))

You'll have to add this to your Sweave file:

\usepackage{colortbl}

This produces gray filling on every second row & header for each page.


The longtable (LaTeX) package specification can be found at that URL. The section of code in the examples whose output appears on pages 2 and 3 is in section 8 and I have reproduced bit of it below:

\caption[]{(continued)}\\ 
\hline\hline 
\multicolumn{2}{@{*}c@{*}}% 
{This part appears at the top of every other page}\\ 
\textbf{First}&\textbf{Second}\\ 
\hline\hline 
\endhead 

When they say on "every other page", they mean every page other than the first, which had a different header. If the xtable call is not working out of the box without any editing, then you should first check that you have the longtable package specified in your LaTeX preamble:

\usepackage{longtable}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜