header on each page of big table of xtable?

好久不见. 提交于 2019-12-04 10:02:57

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!