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).
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):
- All tables and figures which should only span one of the two columns will not work within multicol until you make them non-floating.
- Add the onecolumn option to the documentclass directive.
- 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).
- Place \end{multicols} just before the end of the document
- Wrap the offending table in an end/begin multicols.
- 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).
longtable
does not float. It will start where the environment starts.