22

I'm trying to copy this table into TeX:

Table

I have problems with the horizontal lines under "Gaussian" etc. When I specify three \cmidrule's, they are not separated but are combined into one big \midrule or \cline.

It would be great if someone could show me how to narrow down such a \cmidrule. Thanks in advance!

Here's the (spaghetti) code I use:

\documentclass[bibtotoc,liststotoc,BCOR5mm,DIV12]{scrbook} 
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{colortbl,array} % für farbige cells
\usepackage{multirow,bigdelim}
\usepackage{booktabs}

\begin{document}

\begin{table}[htb]
\resizebox{\textwidth}{!}{
\begin{tabular}{lr rrrrrr rrrrrr rrrr}
\toprule
$f$ & $n$ & \multicolumn{6}{l}{Gaussian} &  \multicolumn{6}{l}{Binomial Logit} & \multicolumn{4}{l}{Survival} \\ \cmidrule{3-8} \cmidrule{9-14} \cmidrule{15-18}
 & & \multicolumn{2}{l}{FP}  & \multicolumn{2}{l}{GCV} & \multicolumn{2}{l}{REML} & \multicolumn{2}{l}{FP} & \multicolumn{2}{l}{GCV} & \multicolumn{2}{l}{REML} & \multicolumn{2}{l}{FP} & AIC & REML \\ 
 &  & \makebox[1cm][l]{FP2}
 & \makebox[1cm][l]{FP4} & \makebox[1cm][l]{LRSS} & \makebox[1cm][l]{PS} & \makebox[1cm][l]{LRSS} & \makebox[1cm][l]{PS} & \makebox[1cm][l]{FP2} & \makebox[1cm][l]{FP4} & \makebox[1cm][l]{LRSS} & \makebox[1cm][l]{PS} & \makebox[1cm][l]{LRSS}
 & \makebox[1cm][l]{PS} & \makebox[1cm][l]{FP2} & \makebox[1cm][l]{FP4} & \makebox[1cm][l]{PS} & \makebox[1cm][l]{PS} \\ \midrule
 & 100 & \cellcolor[gray]{0.8} 0.012 & \cellcolor[gray]{0.8} 0.012 & 0.021 & 0.025 & 0.018 & 0.018 & 0.043 & \cellcolor[gray]{0.8} 0.042 & 0.146 & 0.194 & 0.074 & 0.076 & \cellcolor[gray]{0.8} 0.015 & 0.016 & 0.427 & 0.019 \\ 
$f_1$ & 500 & 0.004 & \cellcolor[gray]{0.8} 0.002 & 0.006 & 0.006 & 0.004 & 0.004 & 0.014 & \cellcolor[gray]{0.8} 0.011 & 0.030 & 0.034 & 0.028 & 0.028 & 0.020 & 0.007 & 0.024 & \cellcolor[gray]{0.8} 0.005

\end{tabular}
}
\end{table}

\end{document}
45

The \cmidrule command of booktabs allows for an optional argument using parentheses ( ) to specify on which side it should be reduced:

\cmidrule(r){3-8} \cmidrule(r){9-14} \cmidrule{15-18}

would shorten the right end of the first two rules. You can also add an amount in braces, i.e. (r{10pt}) and select both sides (lr), (l{5pt}r{10pt}). See the description of \cmidrule in the booktabs manual on page 4 for more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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