假设我有两个彼此相邻的表格,它们的行数不同,并且正文单元格的高度也不同,如下所示:
\documentclass{article}
\begin{document}
\begin{table}
\begin{tabular}[t]{c c}
\hline
hello & world\\
\hline
a \\
b \\
c \\
d \\
\hline
\end{tabular}
\begin{tabular}[t]{c c}
\hline
lorem & ipsum\\
\hline
$A_{\left(1\right)}^2$ \\
$B_{\left(2\right)}^2$ \\
$C_{\left(3\right)}^2$ \\
\hline
\end{tabular}
\end{table}
\end{document}
现在,我想让右侧表格主体中的线条散开,以便两个表格的底线完美对齐,同时仍保持第一行的顶线和底线对齐。
我曾尝试过玩\arraystretch
和其他东西,但当然,我永远无法同时拥有两者。
如有任何关于如何以这种方式对表格间距进行 monkeypatch 的建议,我们将不胜感激!
答案1
您可以使用tabularht
允许您指定所需表格高度并在行之间添加额外空间的包:
\documentclass{article}
\usepackage{tabularht}
\begin{document}
\begin{table}
\begin{tabularht}{1in}{cc}
\hline
hello & world\\
\hline
\interrowfill
a \\
\interrowfill
b \\
\interrowfill
c \\
\interrowfill
d \\
\interrowfill
\hline
\end{tabularht}
\begin{tabularht}{1in}{cc}
\hline
lorem & ipsum\\
\hline
\interrowfill
$A_{\left(1\right)}^2$ \\
\interrowfill
\
$B_{\left(2\right)}^2$ \\
\interrowfill
$C_{\left(3\right)}^2$ \\
\interrowfill
\hline
\end{tabularht}
\end{table}
\end{document}
答案2
显然,你可以计算物体的高度(在这里找到:https://stackoverflow.com/questions/2939450/get-height-on-a-block-of-latex-output)这样,您就可以计算表格的高度,然后将余数除到较小表格的行上:
\documentclass{article}
\begin{document}
\section{Table measurements}
\newdimen\height
\setbox0=\vbox{
\begin{tabular}{c}
\hline
a \\
\hline
b \\
c \\
d \\
\hline
\end{tabular}
}
\height=\ht0 \advance\height by \dp0
The height is: \the\height
\newdimen\height
\setbox0=\vbox{
\begin{tabular}{c}
\hline
A \\
\hline
B \\
C \\
\end{tabular}
}
\height=\ht0 \advance\height by \dp0
The height is: \the\height
\section{The Tables}
\begin{tabular}{c}
\hline
a \\
\hline
b \\
c \\
d \\
\hline
\end{tabular}
\begin{tabular}{c}
\hline
A \\
\hline
B \\
C \\
\hline
\end{tabular}
\section{Corrected table}
\begin{tabular}{c}
\hline
a \\
\hline
b \\
c \\
d \\
\hline
\end{tabular}
\begin{tabular}{c}
\hline
A \vspace{4pt} \\
\hline
B \vspace{4pt} \\
C \vspace{4pt} \\
\hline
\end{tabular}
\end{document}
您必须计算较短的表中的行数并进行划分,但至少您不必摆弄每一行。