# supertabular in a twocolumn env

I write a document which represents a catalog of stuff. Most of the content is a long table with heders in two balanced columns. xelatex is used to build pdf.

I planned to use longtabu from tabu package but seems it's incompatible with multicols and with Balancing long table inside multicol in LaTeX solution headers are not supported.

So currently I use supertabular with Trick Supertabular into Multicols in new command. It works almost good but first page looks incorrect. First column is not fully filled:

Also if remove headers then it doesn't fill both columns on all pages:

Why it happens and how to fix?

\documentclass[10pt,twoside,a4paper]{book}
\usepackage{polyglossia}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{supertabular}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{fancyhdr}
\usepackage{lipsum}
\usepackage[table]{xcolor}
\usepackage[
top=29mm,
left=20mm,
right=10mm,
bottom=13mm,
twoside,
a4paper]
{geometry}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% page style
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\definecolor{FooterBg}{HTML}{D9DCEB}

\newcommand{\hd}{%
\begin{tabular}{@{}c@{}}
\end{tabular}
}

\newcommand{\fd}[1]{%
\begin{tabular}{@{}p{10mm}@{}}
\centering\rule{0mm}{8mm}\cellcolor{FooterBg}\raisebox{1em}{#1} \\
\end{tabular}
}

\fancypagestyle{codetable}{%
\fancyhf{}
\fancyfoot[C]{\fd{\thepage}}
\renewcommand{\footrulewidth}{0pt}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% table stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% https://tex.stackexchange.com/questions/105717/trick-supertabular-into-multicols-in-new-command
%% BEGIN
\newcount\n
\n=0
\def\tablebody{}
\makeatletter
\loop\ifnum\n<100
\protected@edef\tablebody{\tablebody
\textbf{\number\n.}& shortText
\tabularnewline
}
\repeat

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

\definecolor{CellBg}{HTML}{CCD1E4}

\rowcolor{CellBg}
\multicolumn{2}{c}{\rule{0pt}{10mm}\rule{20mm}{0pt}} &&\\
\rowcolor{CellBg}
\rule{15mm}{0pt} & \rule{15mm}{0pt}%
& \multirow{-2}{*}[7mm]{\rule{0pt}{15mm}\rule{20mm}{0pt}}
& \multirow{-2}{*}[7mm]{\rule{0pt}{15mm}\rule{22mm}{0pt}} \\
\arrayrulecolor{white}
\hline
\arrayrulecolor{black}
}

\setlength{\columnsep}{1mm}

%% http://xpt.sourceforge.net/techdocs/language/latex/latex22-Controlling/ar01s03.html
\def\nlines#1{\expandafter\nlineii\romannumeral\number\number #1 000\relax}
\def\nlineii#1{\if#1m\expandafter\theline\expandafter\nlineii\fi}
\def\theline{\cellcolor{CellBg}{\textbf{one}} & two & \cellcolor{CellBg}{three} & four \\ \hline}

\begin{document}
\pagestyle{codetable}

\begin{multicols}{2}
\TrickSupertabularIntoMulticols

\begin{supertabular}{clll}
\nlines{500}
\end{supertabular}

\end{multicols}
\end{document}


I'm not familiar with TeX lang so it's hard to understand even why that two column trick works.

I had tried longtable, xtab, tabu and supertabular. And only supertabular fits better than others for this task.

If the problem is not solvable with supertabular then maybe there are other table packages which supports headers, page breaks and multicolumn env (basically two cols)?

Thanks!

• supertabular (and xtab which is based on it) overestimates the height of rows. I tried a trick that works with single column, but with your table fails miserably. :( – egreg Dec 3 '14 at 22:47
• No way to fix? Maybe there is a method to force or control height before first break or per page height or smth? Would be sad to use table with predefined rows per page instead of delegate to latex. – skozlovf Dec 6 '14 at 16:54
• – Alan Munn Oct 1 '16 at 18:01