答案1
这是一个使用该dcolumn
包来对齐小数点标记上的数字的解决方案。
\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}
答案2
这是一个使用选项booktabs
仅。使用额外的左右对齐.
列来实现小数点周围的对齐:r
l
\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}
合并siunitx
留给读者作为练习。