8

Haha... I have a wide table (not longtable) that is very wide in width (many columns),

a b c d e f g h i j k l m n
---------------------------
1 2 3 4 5 6 7 8 9 0 1 2 3 4

Now, I am looking for a smart way to let it automatically be broken into two+ tables (e.g., it could be broken at the vertical position(s) according to the \pagewidth or \linewidth)

a b c d e f g h i j
-------------------
1 2 3 4 5 6 7 8 9 0

k l m n
-------
1 2 3 4

Is this doable? :-)

Edit:

For convenience, here is a tex file showing the WIDE table:

% !TEX TS-program = latex

\documentclass{article}

\usepackage{booktabs, multicol, multirow}
\usepackage[top=1.5in, bottom=1.5in, left=0.1in, right=0.1in]{geometry}

\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Caption}
    \begin{tabular}{cccc|cccc|cccc|cccc|cccc|cccc|cc}
    \toprule
    AA & BB & CC & DD & EE & FF & GG & HH & II & JJ & KK & LL & MM & NN & OO & PP & QQ & RR & SS & TT & UU & VV & WW & XX & YY & ZZ \\
    \midrule
    01 & 02 & 03 & 04 & 05 & 06 & 07 & 08 & 09 & 10 & 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 & 20 & 21 & 22 & 23 & 24 & 25 & 26 \\
    \bottomrule
    \end{tabular}%
  \label{tab:label}%
\end{table}%

\end{document}
Troy
  • 13,741
Daniel
  • 1,816

1 Answers1

7

It's easy if you invert the input order and enter the data columnwise rather than row wise (and your data is fairly regular, large entries would mess up the alignment. I used c here but you could fix the column with with p{..}

enter image description here

\documentclass{article}

\newcommand\zcolumn[1]{%
\begin{tabular}[b]{c}#1\end{tabular}\linebreak[0]\ignorespaces}
\begin{document}

\begin{raggedright}\renewcommand\baselinestretch{2}
\zcolumn{ 1\\ \hline a}
\zcolumn{ 2\\ \hline b}
\zcolumn{ 3\\ \hline c}
\zcolumn{ 4\\ \hline d}
\zcolumn{ 5\\ \hline e}
\zcolumn{ 6\\ \hline f}
\zcolumn{ 7\\ \hline g}
\zcolumn{ 8\\ \hline h}
\zcolumn{ 9\\ \hline i}
\zcolumn{10\\ \hline j}
\zcolumn{11\\ \hline k}
\zcolumn{12\\ \hline l}
\zcolumn{13\\ \hline m}
\zcolumn{14\\ \hline n}
\zcolumn{15\\ \hline o}
\zcolumn{16\\ \hline p}
\zcolumn{17\\ \hline q}
\zcolumn{18\\ \hline r}
\zcolumn{19\\ \hline s}
\zcolumn{20\\ \hline t}
\zcolumn{21\\ \hline u}
\zcolumn{22\\ \hline v}
\zcolumn{23\\ \hline w}
\zcolumn{24\\ \hline x}
\zcolumn{25\\ \hline y}
\zcolumn{26\\ \hline z}\unpenalty
\end{raggedright}

\end{document}
David Carlisle
  • 757,742