How to solve longtable is not in 1-column mode error?

longtable doesn't work well with twocolumn. But you can use supertabular. Here is an example:

\documentclass[twocolumn]{article}
\usepackage{supertabular,booktabs}
\usepackage[textheight=10cm]{geometry}   %% just for this example.

\begin{document}

\tablefirsthead{\toprule First&\multicolumn{1}{c}{Name} \\ \midrule}
%
\tablehead{%
\multicolumn{2}{c}%
{{\bfseries  Continued from previous column}} \\
\toprule
First&\multicolumn{1}{c}{Name}\\ \midrule}
%
\tabletail{%
\midrule \multicolumn{2}{r}{{Continued on next column}} \\ \midrule}
\tablelasttail{%
\\\midrule
\multicolumn{2}{r}{{Concluded}} \\ \bottomrule}
\begin{supertabular}{ll}
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text comes\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text comes here too \\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text
\end{supertabular}%
\end{document}

enter image description here

As suggested by egreg, xtab is another choice. xtab is built on supertabular while avoiding its weaknesses.

\documentclass[twocolumn]{article}
\usepackage{xtab,booktabs}
\usepackage[textheight=10cm]{geometry}   %% just for this example.

\begin{document}
\topcaption{This is top caption}
\bottomcaption{This is bottom caption}
\tablecaption{this is table caption}
\tablefirsthead{\toprule First&\multicolumn{1}{c}{Name} \\ \midrule}
%
\tablehead{%
\multicolumn{2}{c}%
{{\bfseries  Continued from previous column}} \\
\toprule
First&\multicolumn{1}{c}{Name}\\ \midrule}
%
\tabletail{%
\midrule \multicolumn{2}{r}{{Continued on next column}} \\ \midrule}
\tablelasttail{%
\\\midrule
\multicolumn{2}{r}{{Concluded}} \\ \bottomrule}
\begin{xtabular}{ll}
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text comes\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text comes here too \\
    content & some text\\
    content & some text\\
    content & some text\\
    content & some text
\end{xtabular}%
\end{document}

If you still want to stick to longtable (e.g. because you are generating LaTeX through pandoc) you could redefine the \longtable command.

A possible solution is this one:

\makeatletter
\let\oldlt\longtable
\let\endoldlt\endlongtable
\def\longtable{\@ifnextchar[\longtable@i \longtable@ii}
\def\longtable@i[#1]{\begin{figure}[t]
\onecolumn
\begin{minipage}{0.5\textwidth}
\oldlt[#1]
}
\def\longtable@ii{\begin{figure}[t]
\onecolumn
\begin{minipage}{0.5\textwidth}
\oldlt
}
\def\endlongtable{\endoldlt
\end{minipage}
\twocolumn
\end{figure}}
\makeatother

NB: it works with two columns, which is what you'll find very often in journal article document classes.

To use this fragment with pandoc, you can e.g. use the -H switch which lets you include some additional code before your actual content. Just create a file called preamble.tex and insert the code above. You can then run pandoc -H preamble.tex and the code will automatically be included.


Another option, not covered in the previous answers, is to force single column mode along with a \clearpage before your longtable and then reset it to two column mode after. This would look like:

\clearpage
\onecolumn
\begin{longtable}
...
\end{longtable}
\clearpage
\twocolumn

This is potentially more useful than the previous examples as it doesn't require rebuilding much, and has the added bonus of working in platforms like arXiv.

Tags:

Longtable