pgfplotstable
can do this sort of arrangement.
The purpose of pgfplotstable
is to load (large) data files and to process them. Its typical use case is to postprocess and pretty-print numerical tables.
However, it is also capable of breaking huge columns into two (or three or whatever); and it can also process non-numerical data. It accepts CSV files or files delimited with &
and \\
. However, it is NOT tabular: it expects "raw data" and generates a suitable tabular.
While it can easily handle the task to dynamically balance multiple columns, the cost for you is to learn how to reinsert your "old" formatting instructions like \hline
s or \multicolumn
s. You will also have to learn how to assign column display names, how to add any vertical lines or so. It can do all these things, its just different because the tool has a different use-case (it assumes that there is no tabular, only a data file).
Here is your example. I took the freedom to add sample answers to some of the questions raised in the last paragraph:
\documentclass{standalone}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\begin{document}
\pgfplotstabletypeset[
every head row/.style={before row=\toprule,after row=\midrule},
every last row/.style={after row=\bottomrule},
col sep=ampersand,
row sep=\\,
%
columns={thing,mapsto,thing,mapsto},
display columns/0/.style={
% first part of 2 of `thing':
select equal part entry of={0}{2},
string type,
% column display name:
column name={thing (1/2)},
column type={r}, % ... and type
},
display columns/1/.style={
% first part of 2 of `mapsto':
select equal part entry of={0}{2},
string type,
column name={thing (2/2)},
column type={l|},
},
display columns/2/.style={select equal part entry of={1}{2},string type},% second part of 2 of `thing'
display columns/3/.style={select equal part entry of={1}{2},string type},% second part of 2 of `maps'
]{
thing & mapsto \\
foo 0 & bar 2 \\
foo 1 & bar 3 \\
foo 2 & bar 4 \\
foo 3 & bar 5 \\
foo 4 & bar 6 \\
foo 5 & bar 7 \\
foo 6 & bar 8 \\
foo 7 & bar 9 \\
foo 8 & bar 10 \\
foo 9 & bar 11 \\
foo 10 & bar 12 \\
foo 11 & bar 13 \\
foo 12 & bar 14 \\
foo 13 & bar 15 \\
foo 14 & bar 16 \\
foo 15 & bar 17 \\
foo 16 & bar 18 \\
foo 17 & bar 19 \\
foo 18 & bar 20 \\
foo 19 & bar 21 \\
}
\end{document}
See http://pgfplots.sourceforge.net/pgfplotstable.pdf
Best Answer
Suppress the
\vspace{0pt}
commands and use the optional argument to control the position of thetabular
s: