I would like to construct a table which looks like a booktabs
table (but
without using the package booktabs
). Instead of \cmidrule
, I used \cline
,
which comes pretty close (see below), but the lines drawn with \cline
are too
wide, so that they touch… and therefore it's difficult for the eye to
determine where the groups start/end. Is there a solution to this? (without
using additional packages).
\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}
Best Answer