我有一张包含 1000 行(可变,可以是任意)和 3 列(固定)的表格。每个单元格都有一个 10 位数字。
以单行连续流的方式显示它看起来不太好,并且没有最大限度地利用可用的打印空间。
我希望它从当前点显示到当前页面的末尾。其余行必须折叠并显示到页面底部,并且该过程应持续到页面中有足够的宽度。后续行应按照相同逻辑进入后续页面。最后一组行应从页面顶部均匀分布,以便最后一行包含与第一行相同的列数。
此外,列标题需要在每个列实例中重复。如果可能的话,行和列之间要显示线条。
提前致谢。Aravind
答案1
有以下可能性:
\documentclass{article}
\usepackage{multicol}
\usepackage{capt-of}
\usepackage{siunitx}
\usepackage{lipsum} % just for the example
\newcommand{\entry}[3]{%
\makebox[\columnwidth][s]{\num{#1}\hfil\num{#2}\hfil\num{#3}}\par
}
\newenvironment{pseudotabular}[1]% the argument is the caption
{\setlength\columnsep{1cm}%
\begin{multicols}{2}[\captionof{table}{#1}]
\footnotesize
\setlength\parindent{0pt}}
{\end{multicols}}
\begin{document}
You can see the result in table~\ref{long}.
\lipsum[2]
\begin{pseudotabular}{A long table\label{long}}
\entry{1010101010}{2121212121}{3232323232}
\entry{1010101010}{2121212121}{3232323232}
\entry{1010101010}{2121212121}{3232323232}
\entry{1010101010}{2121212121}{3232323232}
...
\end{pseudotabular}
\end{document}
另一种可能性是xtab
,但欺骗它自动获得平衡的列几乎是不可能的。
看使用新命令将 Supertabular 转换为 Multicols和http://www.guitex.org/home/en/forum/5-tex-e-latex/26889-supertabular-e-twocolumn-riempimento-parziale-altezza-testo
\documentclass{article}
\usepackage{multicol,capt-of}
\usepackage{xtab}
\usepackage{siunitx}
\usepackage{lipsum} % just for the example
\newcommand{\entry}[3]{%
\num{#1}&\num{#2}&\num{#3}\\\hline
}
\makeatletter
\def\mod@estimate@lineht{%
\ST@lineht=\arraystretch \baslineskp
% \ST@lineht=.95\ST@lineht
%\global\advance\ST@lineht by 1\p@
\ST@stretchht\ST@lineht\advance\ST@stretchht-\baslineskp
\ifdim\ST@stretchht<\z@\ST@stretchht\z@\fi
\ST@trace\tw@{Average line height: \the\ST@lineht}%
\ST@trace\tw@{Stretched line height: \the\ST@stretchht}%
}
\newenvironment{strictxtabular}
{\let\estimate@lineht\mod@estimate@lineht\xtabular}
{\endxtabular}
\newcommand{\TrickSupertabularIntoMulticols}{%
\let\mcnewpage=\newpage
\renewcommand\newpage{%
\if@firstcolumn
\hrule width\linewidth height0pt
\columnbreak
\else
\mcnewpage
\fi
}%
}
\makeatother
\begin{document}
You can see the result in table~\ref{long}.
\lipsum[2]
\begin{multicols}{2}[\captionof{table}{A table\label{long}}]
\footnotesize\setlength{\tabcolsep}{2pt}
\TrickSupertabularIntoMulticols
\tablehead{%
\multicolumn{1}{c}{\bfseries First} &
\multicolumn{1}{c}{\bfseries Second} &
\multicolumn{1}{c}{\bfseries Third} \\
}
\tabletail{\hline}
\begin{strictxtabular}{@{}|r|r|r|@{}}
\hline
\entry{1010101010}{2121212121}{3232323232}
\entry{1010101010}{2121212121}{3232323232}
\entry{1010101010}{2121212121}{3232323232}
\entry{1010101010}{2121212121}{3232323232}
\entry{1010101010}{2121212121}{3232323232}
\entry{1010101010}{2121212121}{3232323232}
\entry{1010101010}{2121212121}{3232323232}
\entry{1010101010}{2121212121}{3232323232}
\entry{1010101010}{2121212121}{3232323232}
\entry{1010101010}{2121212121}{3232323232}
...
\end{strictxtabular}
\end{multicols}
\end{document}