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).
Best Answer
What you try to achieve, is probably not possible using
twocolumn
mode. When you change fromtwocolumn
toonecolumn
, 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 inmulticols
environments.multicol has some shortcomings regarding floats inside columns. If you have lots of floats, it may be not the way to go.
Example 1
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.