6

How could I make a table wide (like using table*) in a twocolumn-mode document, that can break a page?

Below the expected result (made in any ordinary text editor).

Page 1 Expected long table exhibition- Page 1

Page 2 Expected long table exhibition- Page 2

UPDATE

By following a suggestion of using multicols and longtable, this is the achieved output. In the first page it seems ok, but after break, the multicol environment is not followed accordingly.

\documentclass[final,5p,times,twocolumn]{article}

\usepackage{longtable}
\usepackage{multicol}
\usepackage{lipsum}

\newcount\n
\n=0
\def\tablebody{}
\makeatletter
\loop\ifnum\n<50
    \advance\n by1
    \protected@edef\tablebody{\tablebody
            \textbf{\number\n.}& shortText & longlonglonglonglong text
            longlonglonglonglong text
            \tabularnewline
    }
\repeat
\makeatother

\begin{document}

    \lipsum[1-10]

    \begin{multicols}{2}
    \end{multicols}

    \begin{longtable}{|l|l|l|}
    \caption[Triple columns]{Triple columns.}\\
    \hline 
        \multicolumn{1}{|c|}{\textbf{Time (s)}} & \multicolumn{1}{c|}{\textbf{Triple chosen}} & \multicolumn{1}{c|}{\textbf{Other feasible triples}} \\ 
    \hline
    \endfirsthead

        \multicolumn{3}{c}%
        {{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
    \hline 
        \multicolumn{1}{|c|}{\textbf{Time (s)}} & \multicolumn{1}{c|}{\textbf{Triple chosen}} & \multicolumn{1}{c|}{\textbf{Other feasible triples}} \\ 
    \hline 
    \endhead

    \hline 
        \multicolumn{3}{|r|}{{Continued on next page}} \\ 
    \hline
    \endfoot

    \hline \hline
    \endlastfoot

    \tablebody

    \end{longtable}

\end{document}

Page 1 Page 1- update

Page 2 Page 2- update

Page 3 Page 3- update

  • 2
    \begin{multicols}{2}.....\end{multicols} \begin{longtable}{ccc}.... – David Carlisle Oct 30 '13 at 21:36
  • What @David suggests is very likely the only way to go. But, wouldn't \begin{table*}[t]YOUR WIDE TABLE\end{table*} be enough, given you drop the requirement to split it over pages? – yo' Oct 30 '13 at 21:55
  • 1
    David's suggestion is not working fine (check out the UPDATE above). I guess table* environment doesn't work properly with multiple pages. – Ivan Machado Oct 30 '13 at 22:10
  • 1
    You have not put the two column material inside the multicols so it is unlikely to work! You should use multicols instead of [twocolumn] – David Carlisle Oct 30 '13 at 22:34
4

enter image description here

\documentclass[]{article}

\usepackage{longtable}
\usepackage{multicol}
\usepackage{lipsum}

\newcount\n
\n=0
\def\tablebody{}
\makeatletter
\loop\ifnum\n<50
    \advance\n by1
    \protected@edef\tablebody{\tablebody
            \textbf{\number\n.}& shortText & longlonglonglonglong text
            longlonglonglonglong text
            \tabularnewline
n    }
\repeat
\makeatother

\begin{document}

    \begin{multicols}{2}
    \lipsum[1-7]
    \end{multicols}

\footnotesize
    \begin{longtable}{|l|l|l|}
    \caption[Triple columns]{Triple columns.}\\    
    \hline 
        \multicolumn{1}{|c|}{\textbf{Time (s)}} & \multicolumn{1}{c|}{\textbf{Triple chosen}} & \multicolumn{1}{c|}{\textbf{Other feasible triples}} \\ 
    \hline
    \endfirsthead

        \multicolumn{3}{c}%
        {{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
    \hline 
        \multicolumn{1}{|c|}{\textbf{Time (s)}} & \multicolumn{1}{c|}{\textbf{Triple chosen}} & \multicolumn{1}{c|}{\textbf{Other feasible triples}} \\ 
    \hline 
    \endhead

    \hline 
        \multicolumn{3}{|r|}{{Continued on next page}} \\ 
    \hline
    \endfoot

    \hline \hline
    \endlastfoot

    \tablebody

    \end{longtable}

\normalsize
    \begin{multicols}{2}
    \lipsum[1-10]
    \end{multicols}

\end{document}
  • This is almost ok. The twocolumn-mode should be stated as a document class option, instead of within the \begin{multicols}...\end{multicols} tags. – Ivan Machado Oct 30 '13 at 23:21
  • 1
    @IvanMachado No that's the point. If you use twocolumn you can only switch between one and two column by using \onecolumn and \twocolumn which force a page break. multicols uses a different mechanism specifically to allow what you show, changing the number of columns mid page. – David Carlisle Oct 30 '13 at 23:24
  • So, let me state my point... what I need/want is an impossible thing to handle without this multicols, isn't it? My text is too long, and I have to strictly follow the journal latex class (we must use a single latex file, instead of "modularizing" things in separate files). There is only a single table I'm facing this problem, and I'm not a 100% sure I can change the global class option to onecolumn without loss of, e.g., text alignment, like the column width, etc. – Ivan Machado Oct 30 '13 at 23:42
  • 1
    @IvanMachado so you need to use \onecolumn\begin{longtable}....\end{lontable}\twocolumn but the table will start on a new page in that case. Or split it by hand and use two table* environments. – David Carlisle Oct 30 '13 at 23:45
  • Yep. I've just tried doing this other way, but I noticed the forced page break. Anyway, I guess I'm going to use split the table by hand, with table* env. Thanks for your support! – Ivan Machado Oct 30 '13 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.