# Long table that spans two columns using xtab

I want a page-wide table in my document, which is two column - but the table is also going to be longer than one page.

I tried longtable initially but I later learned that longtable doesn't work in a two column document.

I found a similar answer and solution here, which gives an example of how to do this using the xtab package:

\documentclass[twocolumn]{article}
\usepackage{xtab,afterpage}
\usepackage{lipsum}  % for filler text

\begin{document}
\lipsum[1-5]  % filler text

--- here's the call to start an xtabular* environment.
Execution is deferred until the start of the next page ---

\afterpage{\onecolumn
\begin{xtabular*}{\textwidth}{l@{\extracolsep{\fill}}lllll}
\hline
column1 &column2    &column3    &column4    &column5    &column6\\
%....
column1 &column2    &column3    &column4    &column5    &column6\\
\hline
\end{xtabular*}
\twocolumn
} % end of scope of "\afterpage" directive

\lipsum[6-10] % more filler text
\end{document}


I can get this example working okay. But instead of using:

\documentclass[twocolumn]{article}


I need to use:

\documentclass{emulateapj}


When I do this, I get the following error message:

l.74   \noalign{\global\let\\=\@savcr}}}


All I want is a page-wide table that can span the two columns of the emulateapj class and be longer than one page.

Help would be appreciated!

## 1 Answer

There are several issues.

First, emulateapj defines \tablehead, which is also defined in xtabs and generates an error.

Second, emulateapj uses revtex4-1.cls internally, which undefines \onecolumn and \twocolumn. Instead it uses \onecolumngrid and \twocolumngrid.

You said that you tried longtable, and it doesn't work in a two column mode. However, it seems to work OK if we change to one column before and then back to two column afterwards.

Consider this example:

\documentclass{emulateapj}
\usepackage{lipsum}
\begin{document}
\lipsum[1-9]

\onecolumngrid
\begin{longtable}{llllll}
\tablecaption{A long table}
\tablehead{column1 & column2 & column3 & column4 & column5 & column6}
column1 & column2 & column3 & column4 & column5 & column6 \\
column1 & column2 & column3 & column4 & column5 & column6 \\
column1 & column2 & column3 & column4 & column5 & column6 \\
column1 & column2 & column3 & column4 & column5 & column6 \\
column1 & column2 & column3 & column4 & column5 & column6 \\
\hline
\end{longtable}
\twocolumngrid

\lipsum[10-12]
\end{document}