0

I would like to obtain those lines below columns header as in the example I show below

enter image description here

I have tried using \multicolumn{3}{c}{-} but it does not do the job. Neither using \midruleor other stuff worked. Any hint?

Full code below for sake of completeness

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{rotating}
\usepackage{booktabs,tabularx,dcolumn,adjustbox}
\usepackage[flushleft]{threeparttable}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{d}[1]{D..{#1}}
\usepackage[font=large,skip=.333\baselineskip]{caption}
\usepackage[margin=0.5in]{geometry}

\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\newcommand\mC[1]{\multicolumn{1}{c}{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}}
\newcommand\ic[1]{\multicolumn{1}{D..{6.2}}{#1}}
\newcommand\pc[1]{\multicolumn{1}{D..{0.1}}{#1}}

\begin{document}

\begin{center}
\begin{threeparttable}

\captionof{table}{Labour and money control}
        \begin{tabular}{@{} l *{7}{d{2.5}} @{}} 
            \toprule\toprule
            &\multicolumn{3}{c}{\textbf{Poor sample}}&\multicolumn{3}{c}{\textbf{Rich sample}}\\
            &\cline{1-3}&\cline{4-6}
            & \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)} & \mc{(5)} & \mc{(6)}  \\\midrule
            \addlinespace
            Outcome & \mC{OLS} 
            & \mC{RF} 
            & \mC{IV}
            & \mC{OLS} 
            & \mC{RF} 
            & \mC{IV}\\ 
            \midrule
            Employed & 0.002 & 0.0107 & 0.0276 & 0.0144^{***}&0.0618^{*}& 0.316 \\
            & (0.003) &  (0.0286) &(0.0755)& (0.003)  & (0.0332) & (0.444)\\ 
            \addlinespace
            Agricultural job & -0.003  & -0.004&  -0.0056&-0.0213^{***}&0.0558 & 0.212\\
            & (0.004) &  (0.0315) & (0.0466)& (0.0313)& (0.0218) & (0.235) \\ 
            \addlinespace
            Paid job & 0.001 & -0.079^{*}  &-0.167& 0.0317^{***}&-0.125^{*}& 0.559\\
            & (0.004)  & (0.0437) & (0.123) & (0.003) & (0.0528) & (0.785) \\ 
            \addlinespace
            Self employed & 0.005 & 0.007  &0.008& -0.0253^{***}&-0.0458& 0.485\\
            & (0.004)  & (0.0424) & (0.0501) & (0.004) & (0.0419) & (1.793) \\ 
            \addlinespace
            Family worker & -0.003 & 0.0296  &-0.0370&-0.004&0.0451^{*}& -0.722\\
            & (0.003)  & (0.0362) & (0.0424) & (0.003) & (0.0268) & (3.551) \\ 
            \addlinespace
            Own earings decision & 0.0141^{*} & -0.0107^{*}  &-0.009& 0.0123^{***}&0.0688& 0.458\\
            & (0.008)  & (0.0840) & (0.0726) & (0.004) & (0.0572) & (1.504) \\ 
            \addlinespace
            Husband's earings decision & 0.0140^{***} & 0.0739^{*}  &0.0221^{***}& 0.0123^{***}&-0.0303& -0.106\\
            & (0.004)  & (0.0507) & (0.0737) & (0.003) & (0.0512) & (0.175) \\ 
            \addlinespace
            \textit{Mean} & \pc{0.71}& \pc{0.39}& \pc{0.44} & \pc{0.70} & \pc{0.14}& \pc{3.16}\\
            Bandwidth & \ic{34} & \ic{35} & \ic{32} & \ic{29}& \ic{23}& \ic{34}\\ 
            Obs & \ic{4,322} & \ic{4,454} & \ic{2,822}& \ic{2,630}& \ic{2,109}& \ic{4,454}\\
            \bottomrule
            \addlinespace
            \multicolumn{7}{c}{ $^{***}\ p<0.01$; $^{**}\ p<0.05$; $^{*}\  p<0.1$} \\
        \end{tabular}
\begin {tablenotes}
\small
\item Notes: 
\end{tablenotes}
\end{threeparttable}
\end{center}
\end{document}

edit: my result is enter image description here

How to have the two lines on the same level?

  • 2
    \cline{1-2} (adjust column values) will help. – TeXnician Jul 3 '17 at 14:24
  • Good to know, thanks @TeXnician! But in that way I get something as above. – PhDing Jul 3 '17 at 15:01
0

As you use booktabs here's a fully working version with \cmidrule. The (lr) shortens the bar a little bit.

cmidrule

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{rotating}
\usepackage{booktabs,tabularx,dcolumn,adjustbox}
\usepackage[flushleft]{threeparttable}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcolumntype{d}[1]{D..{#1}}
\usepackage[font=large,skip=.333\baselineskip]{caption}
\usepackage[margin=0.5in]{geometry}

\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\newcommand\mC[1]{\multicolumn{1}{c}{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}}
\newcommand\ic[1]{\multicolumn{1}{D..{6.2}}{#1}}
\newcommand\pc[1]{\multicolumn{1}{D..{0.1}}{#1}}

\begin{document}

\begin{center}
\begin{threeparttable}

\captionof{table}{Labour and money control}
        \begin{tabular}{@{} l *{7}{d{2.5}} @{}} 
            \toprule
            &\multicolumn{3}{c}{\textbf{Poor sample}}&\multicolumn{3}{c}{\textbf{Rich sample}}\\\cmidrule(lr){2-4}\cmidrule(lr){5-7}
            & \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)} & \mc{(5)} & \mc{(6)}  \\\midrule
            \addlinespace
            Outcome & \mC{OLS} 
            & \mC{RF} 
            & \mC{IV}
            & \mC{OLS} 
            & \mC{RF} 
            & \mC{IV}\\ 
            \midrule
            Employed & 0.002 & 0.0107 & 0.0276 & 0.0144^{***}&0.0618^{*}& 0.316 \\
            & (0.003) &  (0.0286) &(0.0755)& (0.003)  & (0.0332) & (0.444)\\ 
            \addlinespace
            Agricultural job & -0.003  & -0.004&  -0.0056&-0.0213^{***}&0.0558 & 0.212\\
            & (0.004) &  (0.0315) & (0.0466)& (0.0313)& (0.0218) & (0.235) \\ 
            \addlinespace
            Paid job & 0.001 & -0.079^{*}  &-0.167& 0.0317^{***}&-0.125^{*}& 0.559\\
            & (0.004)  & (0.0437) & (0.123) & (0.003) & (0.0528) & (0.785) \\ 
            \addlinespace
            Self employed & 0.005 & 0.007  &0.008& -0.0253^{***}&-0.0458& 0.485\\
            & (0.004)  & (0.0424) & (0.0501) & (0.004) & (0.0419) & (1.793) \\ 
            \addlinespace
            Family worker & -0.003 & 0.0296  &-0.0370&-0.004&0.0451^{*}& -0.722\\
            & (0.003)  & (0.0362) & (0.0424) & (0.003) & (0.0268) & (3.551) \\ 
            \addlinespace
            Own earings decision & 0.0141^{*} & -0.0107^{*}  &-0.009& 0.0123^{***}&0.0688& 0.458\\
            & (0.008)  & (0.0840) & (0.0726) & (0.004) & (0.0572) & (1.504) \\ 
            \addlinespace
            Husband's earings decision & 0.0140^{***} & 0.0739^{*}  &0.0221^{***}& 0.0123^{***}&-0.0303& -0.106\\
            & (0.004)  & (0.0507) & (0.0737) & (0.003) & (0.0512) & (0.175) \\ 
            \addlinespace
            \textit{Mean} & \pc{0.71}& \pc{0.39}& \pc{0.44} & \pc{0.70} & \pc{0.14}& \pc{3.16}\\
            Bandwidth & \ic{34} & \ic{35} & \ic{32} & \ic{29}& \ic{23}& \ic{34}\\ 
            Obs & \ic{4,322} & \ic{4,454} & \ic{2,822}& \ic{2,630}& \ic{2,109}& \ic{4,454}\\
            \bottomrule
            \addlinespace
            \multicolumn{7}{c}{ $^{***}\ p<0.01$; $^{**}\ p<0.05$; $^{*}\  p<0.1$} \\
        \end{tabular}
\begin {tablenotes}
\small
\item Notes: 
\end{tablenotes}
\end{threeparttable}
\end{center}
\end{document}

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.