1

In an article I met this table.enter image description here

How can one design such a table?

  • 1
    I'd suggest the booktabs package for nice horizontal lines and the siunitx package for column aligned on decimal point. Other than that the table looks pretty simple. – Sergei Golovan Feb 24 '17 at 06:19
  • 2
    booktabs for the horizontal lines; siunitx for lining the digits on the decimal point; threeparttable(x) for the 'notes' at the bottom; \multicolumn to make things span more than one column. – jon Feb 24 '17 at 06:20
  • For statistics results, if you use R, before to make any table at hand, check that some R packages as xtable, stargazer or texreg cannot make that table automatically for you. See the Reproducible Research if you are interested in LaTeX ouputs from R. – Fran Feb 24 '17 at 06:56

2 Answers2

3

Here's a solution that uses the dcolumn package to align the numbers on the decimal markers.

enter image description here

\documentclass{article} 

\usepackage{dcolumn,booktabs}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro

\begin{document} 
\begin{table}
\centering
\begin{tabular}{ l *{4}{d{4.5}} }
\toprule
& \multicolumn{2}{c}{A} & \multicolumn{2}{c}{B}\\
\cmidrule(lr){2-3} \cmidrule(l){4-5}
& \mc{Weight (lbs.)} & \mc{Weight (lbs.)} & \mc{Price} & \mc{Price} \\
\midrule 
Mileage & -108.4^{***} & -91.22^{***} & & \\
        & (-11.60) & (-10.34) & & \\
\addlinespace
Car type & & & & \\
 & & & & \\
\addlinespace
Weight (lbs.) & & & 1.747^{***} & 3.465^{***}\\
              & & & (2.72) & (5.49) \\
\addlinespace
Constant & 5328.8^{***} & & & \\
         & (25.85)      & & & \\
\midrule
Observations & \mc{74} & \mc{74} & \mc{74} & \mc{74} \\
\bottomrule
\multicolumn{5}{l}{\footnotesize $t$ statistics in parentheses}\\
\multicolumn{5}{l}{\footnotesize ${}^{*}\ p<0.05$, \dots}\\
\end{tabular}
\end{table}
\end{document}
Mico
  • 506,678
1

Here is an option using booktabs only. Alignment around the decimal . is achieved using extra right-and-left aligned columns:

enter image description here

\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{tabular}{ l *{4}{r@{}l} }
  \toprule
  & \multicolumn{4}{c}{A} & \multicolumn{4}{c}{B} \\
  \cmidrule(lr){2-5} \cmidrule(lr){6-9}
  & \multicolumn{2}{c}{Weight (lbs.)} & \multicolumn{2}{c}{Weight (lbs.)} &
    \multicolumn{2}{c}{Price} & \multicolumn{2}{c}{Price} \\
  \midrule
  Mileage (mpg) & $-108$&$.4^{***}$ &  $-91$&$.22^{***}$ &  $-49$&$.51$       &    $21$&$.85$        \\
                & $(-11$&$.60)$     & $(-10$&$.34)$      &  $(-0$&$.57)$      &    $(0$&$.29)$       \\
  \addlinespace
  Car type      &       &           & $-550$&$.1^{***}$  &       &            &  $3673$&$.1^{***}$   \\
                &       &           &  $(-4$&$.96)$      &       &            &    $(5$&$.37)$       \\
  \addlinespace
  Weight (lbs.) &       &           &       &            &    $1$&$.747^{**}$ &     $3$&$.465^{***}$ \\
                &       &           &       &            &   $(2$&$.72)$      &    $(5$&$.49)$       \\
  \addlinespace
  Constant      & $5328$&$.8^{***}$ & $5125$&$.7^{***}$  & $1946$&$.1$        & $-5853$&$.7$         \\
                &  $(25$&$.85)$     &  $(27$&$.93)$      &   $(0$&$.54)$      &   $(-1$&$.73)$       \\
  \midrule
  Observations  &   $74$&           &  $74$ &            &   $74$&            &    $74$&             \\
  \bottomrule
  \multicolumn{9}{l}{\small $t$ statistics in parentheses}                                           \\
  \multicolumn{9}{l}{\small $^*\ p < 0.05$, $^{**}\ p < 0.01$, $^{***}\ p < 0.0001$}
\end{tabular}

\end{document}

Incorporating siunitx is left to the reader as an exercise.

Werner
  • 603,163