6

When using a supertabular in a multicols env. starting somewhere on a page following e.g. a section and spanning several pages the 1st page columns are filled but all subsequent page columns are only filled partially. The MWE shows this when adding a large amount of rows in the supertabular environment. A subsequent use of multicols with supertabular works ok. It seems supertabular "remembers" the left over page space when it initially starts. I had a look at the supertabular/multicols code, thinking about changing the \TrickSupertabularIntoMulticols trick code (e.g. resetting page size at \mcnewpage), but without success. It is far beyond my limited latex programming capabilities. Any ideas on how to resolve this? MWE below.

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8
\documentclass[a4paper, 12pt, twoside, openright]{book}

\usepackage[left=2cm,right=2cm,top=2cm,bottom=3cm]{geometry}
\usepackage{multicol,showframe,supertabular,ifthen}

\makeatletter
\let\mcnewpage=\newpage
\newcommand{\TrickSupertabularIntoMulticols}{%
\renewcommand\newpage{%
    \if@firstcolumn%
        \hrule width\linewidth height0pt%
            \columnbreak%
        \else%
          \mcnewpage%
        \fi%
}%
}
\makeatother

\begin{document}
\chapter{A}
\section{a1}
\section{a2}
\section{a3}
\section{a4}

\begin{multicols*}{2}
\TrickSupertabularIntoMulticols
\begin{supertabular}{lll}
Aaaa & 0010 & text \tabularnewline
Aaaa & 0010 & text \tabularnewline
\end{supertabular}
\end{multicols*}
\end{document}

1 Answers1

4

If suptertabular fails, there's always longtable:

enter image description here

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8
\documentclass[a4paper, 12pt, twoside, openright]{book}

\usepackage[left=2cm,right=2cm,top=2cm,bottom=3cm]{geometry}
\usepackage{multicol,showframe,supertabular,ifthen,longtable}

\makeatletter
\let\mcnewpage=\newpage
\newcommand{\TrickSupertabularIntoMulticols}{%
\renewcommand\newpage{%
    \if@firstcolumn%
        \hrule width\linewidth height0pt%
            \columnbreak%
        \else%
          \mcnewpage%
        \fi%
}%
}
\makeatother

\begin{document}
\chapter{A}
\section{a1}
\section{a2}
\section{a3}
\section{a4}

\def\r{Aaaa & 0010\stepcounter{enumi}\theenumi & text \tabularnewline}
\def\rr{\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r}
\newbox\myb
\setbox\myb\vbox{\hsize=\dimexpr(\textwidth-\columnsep)/2\relax
\makeatletter
\chardef\LT@end@pen\z@
\makeatother
\begin{longtable}{lll}
\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr
\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr
\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr
\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr
\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr
\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr\rr
\end{longtable}}

\begin{multicols*}{2}
\unvbox\myb
\end{multicols*}
\end{document}
David Carlisle
  • 757,742
  • Thanks David. Obviously I did some research as well, and dismissed longtable as I was led to believe it was not supported in a multicols env. – user2263306 Feb 28 '15 at 17:59
  • @user2263306 that's what its documentation says, but you shouldn't believe everything you read:-) – David Carlisle Feb 28 '15 at 18:00
  • I did some more work on this and tried to add \endhead. It only appears on the very 1st column. I concluded from http://tex.stackexchange.com/questions/45980/balancing-long-table-inside-multicol-in-latex this is not possible. m I correct? – user2263306 Mar 01 '15 at 05:26
  • @user2263306 anything is possible but it would be a major re-write of longtable. – David Carlisle Mar 01 '15 at 10:09
  • Great solution - but, works just as well for me without the text at the top \makeatletter ... \makeatother...? Is that doing something here? – Metamorphic Sep 11 '18 at 13:58