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
  • It's a limitation of supertabular that usually overestimates the row heights.
    – egreg
    Commented Feb 28, 2015 at 17:51

1 Answer 1

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}
5
  • 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. Commented Feb 28, 2015 at 17:59
  • @user2263306 that's what its documentation says, but you shouldn't believe everything you read:-) Commented Feb 28, 2015 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 tex.stackexchange.com/questions/45980/… this is not possible. m I correct? Commented Mar 1, 2015 at 5:26
  • @user2263306 anything is possible but it would be a major re-write of longtable. Commented Mar 1, 2015 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? Commented Sep 11, 2018 at 13:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .