[Tex/LaTex] multiple pages full-page-width table working with revtex

longtableltxgridrevtexsupertabularxtab

I am trying to figure out how to make a full page-width table, which continues over multiple pages in two column document. I got it working for the standard article, unfortunately the journal I want to publish in, requires revtex4-1. I've found some questions on that topic. Non of them, however, mentions revtex environment and not many answers are satisfying to be honest, when it comes to longtable* (probably not the way to go with two columns – document formatting crashes afterwards), xtabular* or supertabular*.

One more thing, can I get it working without page break afterwards?

My only working example without revtex unfortunately:

%\documentclass[twocolumn]{article}
\documentclass[aip, amsmath, amssymb, reprint]{revtex4-1}%
\usepackage{xtab,afterpage}
\usepackage{lipsum}

\begin{document}
\lipsum[1-5]

\afterpage{\onecolumn
\begin{xtabular*}{\textwidth}{l@{\extracolsep{\fill}}lllll}
\hline
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
\end{xtabular*}
\twocolumn
}
\lipsum[6-14] % more filler text
\end{document}

Best Answer

The underlying problem is that revtex4-1 loads the ltxgrid package, which makes a number of changes to the latex kernel. In particular, the handling of multicolumn material is changed. The latex commands \onecolumn and twocolumn are replaced by \onecolumngrid and \twocolumngrid. In addition, ltxgrid modifies the longtable macro.

The widetext environment of revtex4-1 packages the switch from two columns to one column so that single column material can be placed into an environment which begins and ends with leaders (or adornments). The adornments are intended to guide the reader across the column breaks. This environment is mainly aimed at wide equations or passages of text that need visual emphasis, but you can also put a table into it.

You can also just use onecolumngrid and twocolumngrid directly, which may be preferred if you don't want the adornments around the table.

First, I'll illustrate with your MWE and widetext. Then, I'll show a solution using longtable to continue the headers and footers across page breaks, without the adornments.

\documentclass[aip, amsmath, amssymb, reprint]{revtex4-1}%
\usepackage{xtab,afterpage}
\usepackage{lipsum}

\begin{document}
\lipsum[1-5]


\afterpage{\begin{widetext} %<===
\begin{xtabular*}{\textwidth}{l@{\extracolsep{\fill}}lllll}
\hline\hline\hline
\multicolumn{6}{c}{\textbf{Heading for a lengthy table}}\\
\hline
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
\hline\hline\hline
\end{xtabular*}
\end{widetext} %<===
}
\lipsum[6-14] % more filler text
\end{document}

The widetext environment adds the adornments automatically; and, because they are set as leaders, they will drop out at page breaks. So, we see an adornment at the end of this table and not at the starting page break.

enter image description here

For the longtable case, I'll switch to using \onecolumngrid and \twocolumngrid. We want longtable to reach the full width of the page, so we again include @{\extracolsep{\fill}}. Ordinary, we would also use

\setlength\LTleft{0pt}
\setlength\LTright{0pt}

to remove the default \fill on either side of the table (see longtable documentation, page 7). However, ltxgrid has rewritten part of the macro, overriding these manual selections. Instead, we can define another alignment option for longtable, analogous to the [c], [l], and [r] that are already defined. I'll call this option [e] (i.e., we have extracolsep):

\def\LT@LR@e{\LTleft\z@   \LTright\z@}%

(I had thought that I would also need to use xpatch as follows, but it seems unnecessary in this case:

\xpatchcmd{\LT@array@longtable}{\if l#1\LTleft\z@ \LTright\fill}{\if e#1\LTleft\z@ \LTright\z@ \else\if l#1\LTleft\z@ \LTright\fill}{}{}

I'm not sure why this patch isn't also needed).

Putting all this together, we have the following code:

\documentclass[aip, amsmath, amssymb, reprint]{revtex4-1}%
\usepackage{xtab,afterpage,longtable}
\usepackage{lipsum}

\makeatletter
\def\LT@LR@e{\LTleft\z@   \LTright\z@}%
\makeatother

\begin{document}
\lipsum[1-5]

\afterpage{\onecolumngrid
\renewcommand{\doublerulesep}{0pt}
\begin{longtable}[e]{@{\extracolsep{\fill}}llllll}
\hline\hline\hline
\multicolumn{6}{c}{\textbf{Heading for a table}}\\
\hline
\endfirsthead
\hline\hline\hline
\multicolumn{6}{c}{\textbf{Heading for a table}}\\
\hline
\endhead
\hline\hline
\multicolumn{6}{c}{\textit{Con't next page\ldots}}\\
\endfoot
\hline\hline
\endlastfoot
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
col1 & col2 & col3 & col4 & col5 & col6 \\
\end{longtable}
\twocolumngrid
}
\lipsum[6-14] % more filler text
\end{document}

enter image description here

Finally, it may be of interest that this particular table will fit into a two column format (under ltxgrid) with longtable if you comment out \onecolumngrid and \twocolumngrid.

Related Question