[Tex/LaTex] Inserting a one-column multi-page table in a two-column document

longtabletwo-column

I am trying to insert a one-column multi-page table in a two-column document. I do not want the page to be flushed before and after the table with the switch between number of columns. Essentially, what I want is the look of table* but capable of spanning multiple pages. Below is an example drawing of what I'm looking for (it isn't important that the table be [h] as in this instance, only that it is embedded in the surrounding text).

enter image description here

Below is a minimal example which generates the "Actual" image:

\documentclass{article}
\usepackage{lipsum} %% To generate example text
\usepackage{array, booktabs,longtable}

\twocolumn
\begin{document}

\lipsum[1-6] %% To generate example text

%%% Begin table %%%
\onecolumn
\begin{longtable}[h]{>{\hangindent=1em}p{13cm}}
\toprule
\lipsum[1]\\ %% To generate example text
\lipsum[1]\\ %% To generate example text
\lipsum[1]\\ %% To generate example text
\lipsum[1]\\ %% To generate example text
\bottomrule
\end{longtable}
\twocolumn
%%% End table %%%

\lipsum[1-6] %% To generate example text

\end{document}

I have tried using the multicol package as an alternative to \onecolumn but this results in the text in the table extending beyond the page margins, instead of wrapping. I also tried using xltabular but must have gotten something wrong as this completely removed the table.

Update: The solution is roughly the one provided below by @Sveinung, but there are several caveats to keep in mind (all but the first apply to my specific case of using documentclass IEEEtran):

  1. All tables and figures which should only span one of the two columns will not work within multicol until you make them non-floating.
  2. Add the onecolumn option to the documentclass directive.
  3. Place the \begin{multicols}{2} after \maketitle and the Abstract (placing it before leads to the columns overwriting the Abstract and the title only spanning one column).
  4. Place \end{multicols} just before the end of the document
  5. Wrap the offending table in an end/begin multicols.
  6. using a local copy of IEEEtran.cls, switch the twocolumn/onecolumn treatment for \abstract and \IEEkeywords for the mode you emply (e.g., compsoc, transmag).

Best Answer

What you try to achieve, is probably not possible using twocolumn mode. When you change from twocolumn to onecolumn, LaTeX gives will have a new page, and lot of white space.

I suggest using the package multicol instead for twocolumn mode, and place your texts before and after the tables in multicolsenvironments.

multicol has some shortcomings regarding floats inside columns. If you have lots of floats, it may be not the way to go.

Example 1

enter image description here

\documentclass{article}
\usepackage{lipsum} %% To generate example text
\usepackage{array, booktabs,longtable}
\usepackage[latin]{babel}
\usepackage{multicol}


\begin{document}
\begin{multicols}{2}
\lipsum[1-6] %% To generate example text
\end{multicols}
%%% Begin table %%%

\begin{longtable}{>{\hangindent=1em}p{13cm}}
\toprule
\lipsum[1]\\ %% To generate example text
\lipsum[1]\\ %% To generate example text
\lipsum[1]\\ %% To generate example text
\lipsum[1]\\ %% To generate example text
\lipsum[1]\\ %% To generate example text
\bottomrule
\end{longtable}
%%% End table %%%
\begin{multicols}{2}

\lipsum[1-6] %% To generate example text
\end{multicols}

\end{document}

Example 2 - switch to onecolumn

You have to adjust the left and right margin of the longtable if the table shall be set flush to the margins. Since this will depend on your documents margin, I leave it to you.

enter image description here

\documentclass[twocolumn]{article}
\usepackage{lipsum} %% To generate example text
\usepackage{array, booktabs,longtable}
\usepackage[latin]{babel}
\usepackage{multicol}


\begin{document}
\onecolumn
\begin{multicols}{2}
\lipsum[1-7] %% To generate example text
\end{multicols}
%%% Begin table %%%

\begin{longtable}[c]{>{\hangindent=1em}p{13cm}}
\toprule
\lipsum[1]\\ %% To generate example text
\lipsum[1]\\ %% To generate example text
\lipsum[1]\\ %% To generate example text
\lipsum[1]\\ %% To generate example text
\lipsum[1]\\ %% To generate example text
\bottomrule
\end{longtable}
%%% End table %%%
\begin{multicols}{2}

\lipsum[1-6] %% To generate example text
\end{multicols}

\end{document}