我想构建一个看起来像booktabs
表格的表格(但不使用包booktabs
)。\cmidrule
我没有使用\cline
,而是使用了,它非常接近(见下文),但用绘制的线条\cline
太宽,以至于它们相接……因此眼睛很难确定组的开始/结束位置。有解决方案吗?(不使用其他包)。
\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[american]{babel}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage[table]{xcolor}
\begin{document}
% my trial with \cline
\begin{table}[htbp]
\centering
\begin{tabular}{rrrrrrrrr}
\hline
Sex & \multicolumn{4}{c}{Male} & \multicolumn{4}{c}{Female} \\
\cline{2-5} \cline{6-9}
Age & \multicolumn{2}{c}{Child} & \multicolumn{2}{c}{Adult} & \multicolumn{2}{c}{Child} & \multicolumn{2}{c}{Adult} \\
\cline{2-3} \cline{4-5} \cline{6-7} \cline{8-9}
{Class \ Survived} & {No} & {Yes} & {No} & {Yes} & {No} & {Yes} & {No} & {Yes} \\
\hline
1st & 0 & 5 & 118 & 57 & 0 & 1 & 4 & 140 \\
2nd & 0 & 11 & 154 & 14 & 0 & 13 & 13 & 80 \\
3rd & 35 & 13 & 387 & 75 & 17 & 14 & 89 & 76 \\
Crew & 0 & 0 & 670 & 192 & 0 & 0 & 3 & 20 \\
\hline
\end{tabular}
\end{table}
% with booktabs
\begin{table}[htbp]
\centering
\begin{tabular}{rrrrrrrrr}
\toprule
Sex & \multicolumn{4}{c}{Male} & \multicolumn{4}{c}{Female} \\
\cmidrule(lr){2-5} \cmidrule(lr){6-9}
Age & \multicolumn{2}{c}{Child} & \multicolumn{2}{c}{Adult} & \multicolumn{2}{c}{Child} & \multicolumn{2}{c}{Adult} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7} \cmidrule(lr){8-9}
{Class \ Survived} & {No} & {Yes} & {No} & {Yes} & {No} & {Yes} & {No} & {Yes} \\
\midrule
1st & 0 & 5 & 118 & 57 & 0 & 1 & 4 & 140 \\
2nd & 0 & 11 & 154 & 14 & 0 & 13 & 13 & 80 \\
3rd & 35 & 13 & 387 & 75 & 17 & 14 & 89 & 76 \\
Crew & 0 & 0 & 670 & 192 & 0 & 0 & 3 & 20 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
\begin{tabular}{@{\extracolsep{4pt}}rrrrrrrrr@{}}