自动垂直拆分宽表,而不是水平拆分

自动垂直拆分宽表,而不是水平拆分

哈哈...我有一个宽的表(不长桌)宽度非常宽(列数很多),

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

现在我正在寻找一个聪明的方法来让它自动地分成两个以上的表格(例如,可以根据 \pagewidth 或 \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

这可行吗?:-)

编辑:

为了方便起见,这里有一个显示 WIDE 表的 tex 文件:

% !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}

答案1

如果你反转输入顺序并按列而不是按行输入数据(并且你的数据相当规则,那么大条目会弄乱对齐,这很容易。我c在这里使用,但你可以用p{..}

在此处输入图片描述

\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}

相关内容