Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}

enter image description here

share|improve this question

1 Answer 1

up vote 6 down vote accepted
  \begin{tabular}{@{\extracolsep{4pt}}rrrrrrrrr@{}}

enter image description here

share|improve this answer
    
... that's quite embarrassing I forgot that one :-) Thanks, David. –  Marius Hofert Mar 5 '13 at 14:29
    
Is there a way to assign \extracolsep without setting the horizontal space between columns (or in this case before the first and to preserve symmetry after the last) to zero? \begin{tabular}{@{\extracolsep{4pt}}@{\kern\tabcolsep}rrrrrrrrr}? –  Qrrbrbirlbel Mar 5 '13 at 14:45
    
@Qrrbrbirlbel yes you can use array package ! instead of @ it is the same except it doesn't remove the default space –  David Carlisle Mar 5 '13 at 15:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.