Booktabs table, multicolumn header underline
Use the \cline
equivalent offered by booktabs
:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}%
\begin{tabular}{l*{4}{c}}
\toprule
& \multicolumn{2}{c}{Immigrants} & \multicolumn{2}{c}{Non-immigrants} \\
\cmidrule(lr){2-3}\cmidrule(lr){4-5}
& \multicolumn{1}{c}{Disability} & \multicolumn{1}{c}{Offspring survival rate} &
\multicolumn{1}{c}{Disability} & \multicolumn{1}{c}{Offspring survival rate} \\
\midrule
Low & -0.00190 & -0.00525 & 0.00185 & -0.00186 \\
& (-0.43) & (-0.40) & (0.83) & (-0.36) \\
\addlinespace
High & -0.00865 & 0.00429 & -0.00413 & -0.0207\sym{*} \\
& (-1.21) & (0.20) & (-1.01) & (-2.24) \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
The optional (lr)
argument for \cmidrule
trims the line on the l
eft and r
ight side so they're separated between columns three and four.
Add the \cline
command instead of the \midrule
or after the first table row (depending on what you actually want). For example
& \multicolumn{2}{c}{Immigrants} & & \multicolumn{2}{c}{Locals} \\ \cline{2-3} \cline{5-6}
The numbers i-j
in the \cline{i-j}
command specify the columns that should be "underlined", i.e. the line starts at column i
and ends at column j
.
Edit:
If you are using the booktabs
package, use the equivalent command \cmidrule
instead as suggested by @Werner. Note, however, that the booktabs
package modifies the default table appearance and some features of the original tables no longer produce satisfactory results (such as vertical table rules). That being said, using booktabs
is usually a better choice.
In addition to using some of the line-drawing macros of the booktabs
package to give the table an "open" look, you should also
make the table not exceed the width of the text block; this may be done by using a
tabularx
environment to insert a line break in the stringsOffspring survival rate
align the numerical data on their respective decimal markers and use proper
-
(minus) signs rather than dashes for the negative numbers; this can be done by loading thedcolumn
package and using theD
column types.
\documentclass{article}
\usepackage{booktabs,tabularx,dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand\mc[1]{\multicolumn{1}{C}{#1}} % shortcut macro
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{document}
\begin{table}
\caption{Health}
\begin{tabularx}{\textwidth}{ l *{4}{d{2.5}} }
\toprule
& \multicolumn{2}{c}{Immigrants} & \multicolumn{2}{c}{Non-immigrants} \\
\cmidrule(lr){2-3}\cmidrule(l){4-5}
& \mc{Disability} & \mc{Offspring survival rate}
& \mc{Disability} & \mc{Offspring survival rate} \\
\midrule
Low &-0.00190 & -0.00525 & 0.00185 & -0.00186 \\
& (-0.43) & (-0.40) & (0.83) & (-0.36) \\
\addlinespace
High & -0.00865 & 0.00429 & -0.00413 & -0.0207\sym{*} \\
& (-1.21) & (0.20) & (-1.01) & (-2.24) \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}