[Tex/LaTex] LaTeX table header with split horizontal lines

tables

I've seen the following table in paper and would like to reproduce it in LaTeX. The one thing that I'm struggling with is the broken horizontal lines between the two different "Dep. Var." columns (gap between model "(5)" and "(6)". What is a good way to achieve a similar effect in LaTeX? I can thing only of adding a narrow, empty "dummy" column. Any other ideas?

enter image description here

Best Answer

Here is one way following your idea of inserting a narrow, empty "dummy" column @{}p{...}@{}:

enter image description here

\documentclass{article}
\usepackage[margin=.5in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\begin{document}
\noindent\small
\begin{tabularx}{\linewidth}{
    >{\raggedleft\arraybackslash}X% column 1
    *{5}{>{\centering\arraybackslash}p{.08\linewidth}}% columns 2-6
    @{}p{1em}@{}% column 7
    *{3}{>{\centering\arraybackslash}p{.08\linewidth}}}% columns 8-10
  \toprule
  Dependent Variable: & 
    \multicolumn{5}{c}{Dep.\ Var.\ =\ \textit{HoursWorked}} &&
    \multicolumn{3}{c}{Dep.\ Var.\ =\ \textit{NumCommunications}} \\
  \cmidrule{2-6}\cmidrule{8-10}
  Model: &
    (1) & (2) & (3) & (4) & (5) &&
    (6) & (7) & (8) \\
  \cmidrule{2-6}\cmidrule{8-10}
  &&&&&&&&& \\
  \bottomrule
\end{tabularx}

\end{document}

Here is another where you specify the column separation as a gap @{...}, and cut horizontal line a bit short:

enter image description here

\documentclass{article}
\usepackage[margin=.5in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\begin{document}
\noindent\small
\begin{tabularx}{\linewidth}{
    >{\raggedleft\arraybackslash}X% column 1
    *{5}{>{\centering\arraybackslash}p{.08\linewidth}}% columns 2-6
    @{\hspace{1em}}% column 6-7 gap
    *{3}{>{\centering\arraybackslash}p{.08\linewidth}}}% columns 7-9
  \toprule
  Dependent Variable: & 
    \multicolumn{5}{c}{Dep.\ Var.\ =\ \textit{HoursWorked}} &
    \multicolumn{3}{c}{Dep.\ Var.\ =\ \textit{NumCommunications}} \\
  \cmidrule(r{1em}){2-6}\cmidrule{7-9}
  Model: &
    (1) & (2) & (3) & (4) & (5) &
    (6) & (7) & (8) \\
  \cmidrule(r{1em}){2-6}\cmidrule{7-9}
  &&&&&&&& \\
  \bottomrule
\end{tabularx}

\end{document}

In both instances I've used booktabs and tabularx to draw and stretch the table. geometry was added to fit the table inside the margins. It may not be necessary for your end-use document.