[Tex/LaTex] Page break with a longtable in multicolumn

longtablemulticolpage-breakingtables

I am trying to reproduce a book which contains many tables printed on two columns to save some vertical space. The text before & after the tables is not concerned by this multi-column style.

I could typeset the tables in a “two small tables side to side in a bigger one” way, but that would not really separate content and design.

This answer solves the first part of the problem, displaying the (long) table on two columns.

The tables are not meant to float like in this case and that seems to bring the same problem of page breaking back: the text after the table does not break, nor the table if it is too long.

Here is an example:

\documentclass[10pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{multicol}
   \setlength{\columnseprule}{.4pt}
\usepackage{longtable}
\usepackage{lipsum}
%\usepackage{showframe}

\begin{document}

\lipsum[1-4]

\begin{multicols}{2}

\newsavebox\ltmcbox
\setbox\ltmcbox\vbox{
\makeatletter\col@number\@ne\makeatother
\begin{longtable}{lll}
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3
\end{longtable}
\unskip
\unpenalty
\unpenalty}
\unvbox\ltmcbox

\end{multicols}

\lipsum[1]

\end{document}

Thank you for your help.

Best Answer

It seems to work better if one set the longtable outside the multicols environment

\documentclass[10pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{multicol}
   \setlength{\columnseprule}{.4pt}
\usepackage{longtable}
\usepackage{lipsum}
%\usepackage{showframe}

\begin{document}

\lipsum[1-4]

\newsavebox\ltmcbox
\setbox\ltmcbox\vbox{\hsize=\dimexpr0.5\textwidth-0.5\columnsep
\makeatletter\col@number\@ne\makeatother
\begin{longtable}{lll}
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3 \\
col 1 & col 2 & col 3
\end{longtable}
\unskip
\unpenalty
\unpenalty}

\begin{multicols}{2}


\unvbox\ltmcbox

\end{multicols}

\lipsum[1]

\end{document}

enter image description here

(David's answer in Balancing long table inside multicol in LaTeX has the same problem if one add enough text before the multicols.)

Related Question