双表对齐和线条

双表对齐和线条

我有一个表格,它太大了,无法放入页面宽度,因此它被分成两个表格。事实上,我只使用一个表格,但在中间插入一个空行,以便列保持对齐。这是一个缩小尺寸的示例:

在此处输入图片描述

想法是删除第一行最后一列的双线,以及第二张表格中最后一列与空列之间的垂直线。这些线就是绿色省略号内的线。

图像的代码是:

\begin{table}[t]
\centering
\begin{tabular}{c | c | r | r | r | r | r}
\multicolumn{2}{}{} & \multicolumn{3}{|c}{NS} & \multicolumn{2}{|c}{PV} 
\\
Game Phase & Depth & \multicolumn{1}{|c}{TNC} & \multicolumn{1}{|c}{\# Cutoffs} & \multicolumn{1}{|c}{\# Re-searches} & \multicolumn{1}{|c}{TNC} & \multicolumn{1}{|c}{Gain}
\\\hline\hline
\multirow{2}{*}{Opening} & 8 & 336 & 10 568 & 1 231 & 336 & 0.00
\\
& 12 & 6 871 & 246 028 & 5 520 & 6 871 & 0.00
\\\hline
\multirow{2}{*}{Middle Game} & 8 & 1 605 & 71 728 & 5 532 & 1 605 & 0.00
\\
& 12 & 43 167 & 2 811 969 & 30 219 & 43 167 & 0.00
\\
\multicolumn{7}{}{}
\\
\multicolumn{2}{}{} & \multicolumn{4}{|c}{Two Bounds}
\\
Game Phase & Depth & \multicolumn{1}{|c}{TNC} & \multicolumn{1}{|c}{\# Cutoffs} & \multicolumn{1}{|c}{\# Re-searches} & \multicolumn{1}{|c}{Gain}
\\\hline\hline
\multirow{2}{*}{Opening} & 8 & 334 & 10 436 & 1 232 & 0.58
\\
& 12 & 6 844 & 244 147 & 5 524 & 0.39
\\\cline{1-6}
\multirow{2}{*}{Middle Game} & 8 & 1 599 & 71 490 & 5 519 & 0.38
\\
& 12 & 42 957 & 2 796 029 & 30 011 & 0.48
\end{tabular}
\caption{example}
\label{tab:example}
\end{table}

答案1

当然,制作表格的更好方法是书签希尼奇

\usepackage{siunitx,booktabs}
...
\begin{table}
\newcommand\?{\multicolumn{1}{S[table-format=2.0]}} % just a shortcut
\centering
\begin{tabular}{c c *{4}{S[table-format=7.0,group-minimum-digits=4]}
  S[table-format=1.2]}
\toprule
&& \multicolumn{3}{c}{NS} & \multicolumn{2}{c}{PV} \\
\cmidrule(lr){3-5} \cmidrule(lr){6-7}
Game Phase & Depth & \multicolumn{1}{c}{TNC} & \multicolumn{1}{c}{\# Cutoffs} & 
  \multicolumn{1}{c}{\# Re-searches} & \multicolumn{1}{c}{TNC} & \multicolumn{1}{c}{Gain} \\
\midrule
Opening & 8 & 336 & 10 568 & 1 231 & 336 & 0.00 \\
        & 12 & 6 871 & 246 028 & 5 520 & 6 871 & 0.00 \\
\midrule
Middle Game & 8 & 1 605 & 71 728 & 5 532 & 1 605 & 0.00 \\
            & 12 & 43 167 & 2 811 969 & 30 219 & 43 167 & 0.00 \\
\bottomrule
\addlinespace[2ex]
\toprule
&& \multicolumn{4}{c}{Two Bounds} \\
\cmidrule(lr){3-6}
Game Phase & Depth & \multicolumn{1}{c}{TNC} & \multicolumn{1}{c}{\# Cutoffs} &
  \multicolumn{1}{c}{\# Re-searches} & \multicolumn{1}{c}{\hidewidth Gain\hidewidth}\\
\midrule
Opening & 8 & 334 & 10 436 & 1 232 & \?{0.58} \\
        & 12 & 6 844 & 244 147 & 5 524 & \?{0.39} \\
\midrule
Middle Game & 8 & 1 599 & 71 490 & 5 519 & \?{0.38} \\
            & 12 & 42 957 & 2 796 029 & 30 011 & \?{0.48} \\
\bottomrule
\end{tabular}
\caption{An example}
\end{table}

在此处输入图片描述

答案2

另一种方法是这样的:

\begin{table}[t]
\centering
\begin{tabular}{c | c | r | r | r | r | r}
\multicolumn{2}{}{} & \multicolumn{3}{|c}{NS} & \multicolumn{2}{|c}{PV}
\\
Game Phase & Depth & \multicolumn{1}{|c}{TNC} & \multicolumn{1}{|c}{\# Cutoffs} & \multicolumn{1}{|c}{\# Re-searches} & \multicolumn{1}{|c}{TNC} & \multicolumn{1}{|c}{Gain}
\\\hline\hline
\multirow{2}{*}{Opening} & 8 & 336 & 10 568 & 1 231 & 336 & 0.00
\\
& 12 & 6 871 & 246 028 & 5 520 & 6 871 & 0.00
\\\hline
\multirow{2}{*}{Middle Game} & 8 & 1 605 & 71 728 & 5 532 & 1 605 & 0.00
\\
& 12 & 43 167 & 2 811 969 & 30 219 & 43 167 & 0.00
\\
\multicolumn{7}{}{}
\\
\multicolumn{2}{}{} & \multicolumn{4}{|c}{Two Bounds}
\\
Game Phase & Depth & \multicolumn{1}{|c}{TNC} & \multicolumn{1}{|c}{\# Cutoffs} & \multicolumn{1}{|c}{\# Re-searches} & \multicolumn{2}{|c}{Gain}
\\\hline\hline
\multirow{2}{*}{Opening} & 8 & 334 & 10 436 & 1 232 & \multicolumn{2}{|c}{0.58}
\\
& 12 & 6 844 & 244 147 & 5 524 & \multicolumn{2}{|c}{0.39}
\\\cline{1-7}
\multirow{2}{*}{Middle Game} & 8 & 1 599 & 71 490 & 5 519 & \multicolumn{2}{|c}{0.38}
\\
& 12 & 42 957 & 2 796 029 & 30 011 & \multicolumn{2}{|c}{0.48}
\end{tabular}
\caption{example}
\label{tab:example}
\end{table}

这里的区别是,第二个表的最后一列将具有与第一个表的最后两列相同的跨度。

在此处输入图片描述

答案3

您应该\hhline{<hline spec>}使用hhline包裹array。它允许在和tabular环境中使用非常广泛的水平线(并且控制更好)<hline spec>。它控制是否放置双/单水平线,以及垂直线是否应该切割/不切割水平双线。在您的例子中,我使用=双线 和:切割垂直线=。使用hhline是必要的,因为默认情况下多个\cline会叠印成一个\cline

\documentclass{article}
\usepackage{multirow}% http://ctan.org/pkg/multirow
\usepackage{hhline}% http://ctan.org/pkg/hhline
\begin{document}
\begin{table}[t]
\centering
\begin{tabular}{c | c | r | r | r | r | r}
\multicolumn{2}{}{} & \multicolumn{3}{|c}{NS} & \multicolumn{2}{|c}{PV} 
\\
Game Phase & Depth & \multicolumn{1}{|c}{TNC} & \multicolumn{1}{|c}{\# Cutoffs} & \multicolumn{1}{|c}{\# Re-searches} & \multicolumn{1}{|c}{TNC} & \multicolumn{1}{|c}{Gain}
\\\hhline{=:=:=:=:=:=:=}
\multirow{2}{*}{Opening} & 8 & 336 & 10 568 & 1 231 & 336 & 0.00
\\
& 12 & 6 871 & 246 028 & 5 520 & 6 871 & 0.00
\\\hline
\multirow{2}{*}{Middle Game} & 8 & 1 605 & 71 728 & 5 532 & 1 605 & 0.00
\\
& 12 & 43 167 & 2 811 969 & 30 219 & 43 167 & 0.00
\\
\multicolumn{7}{}{}
\\
\multicolumn{2}{}{} & \multicolumn{4}{|c}{Two Bounds}
\\
Game Phase & Depth & \multicolumn{1}{|c}{TNC} & \multicolumn{1}{|c}{\# Cutoffs} & \multicolumn{1}{|c}{\# Re-searches} & \multicolumn{1}{|c}{Gain}
\\\hhline{=:=:=:=:=:=~}
\multirow{2}{*}{Opening} & 8 & 334 & 10 436 & 1 232 & \multicolumn{1}{|c}{0.58}
\\
& 12 & 6 844 & 244 147 & 5 524 & \multicolumn{1}{|c}{0.39}
\\\cline{1-6}
\multirow{2}{*}{Middle Game} & 8 & 1 599 & 71 490 & 5 519 & \multicolumn{1}{|c}{0.38}
\\
& 12 & 42 957 & 2 796 029 & 30 011 & \multicolumn{1}{|c}{0.48}
\end{tabular}
\caption{example}
\label{tab:example}
\end{table}
\end{document}

表格被分成两个不同的列

另一个选择可能是将表格侧向放置,以便在纵向页面布局中留出更多空间。不过,这是个人喜好。

相关内容