booktabs 如何决定哪些中间规则应提供更大的宽度?用 修复它们\midrule[0.5em]
并不适用于所有情况。
我正在创建一个不寻常的表格:
\documentclass[a4paper,12pt, twoside]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{natbib}
\usepackage{fancyhdr}
\usepackage[onehalfspacing]{setspace}
\usepackage{graphicx} % enable includegraphics
\usepackage{rotating}
\usepackage{eurosym}
\usepackage{bm}
\usepackage[UKenglish]{babel}
\setlength{\headheight}{15pt}
\usepackage{hyperref}
\usepackage{booktabs}
%\setlength{\parindent}{0cm}
\usepackage[paper=a4paper,left=25mm,right=25mm,top=25mm,bottom=25mm]{geometry}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\begin{document}
\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Summary Table - Difference-in-Differences Estimator\label{tab1}}
\begin{tabular}{l*{5}{c}}
\toprule
&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} \\
& All & Less\_corr & More\_corr & Less\_dem & More\_dem \\
\midrule
25km&&&&&\\
\addlinespace
Police& 0.0201\sym{*} & -0.0163 & 0.0550\sym{**} & 0.0988\sym{***} & -0.0128 \\
\addlinespace
Permit& 0.0129 & -0.0255\sym{**} & 0.0555\sym{**} & 0.107\sym{***} & -0.0154 \\
\midrule
75km&&&&&\\
\addlinespace
Police& 0.00786 & -0.0134 & 0.0323\sym{*} & 0.0687\sym{***} & -0.0190\sym{*} \\
\addlinespace
Permit& 0.00100 & -0.0150\sym{*} & 0.0224 & 0.0528\sym{***} & -0.0147 \\
\midrule
Rounds 2-4&&&&&\\
\addlinespace
Police& 0.0396\sym{**} & 0.00487 & 0.0783\sym{***} & 0.0814\sym{***} & 0.0112 \\
\addlinespace
Permit& 0.0471\sym{***} & 0.000628 & 0.0979\sym{***} & 0.109\sym{***} & 0.0140 \\
\midrule
Rounds 3-5&&&&&\\
\addlinespace
Police& 0.0146 & -0.00887 & 0.0418\sym{*} & 0.0815\sym{***} & -0.00929 \\
\addlinespace
Permit& 0.00899 & -0.0104 & 0.0382 & 0.0780\sym{***} & -0.00763 \\
\midrule
Incl. non-ODA&&&&&\\
\addlinespace
Police& 0.0145\sym{*} & -0.00938 & 0.0430\sym{**} & 0.0573\sym{***} & -0.00892 \\
\addlinespace
Permit& 0.00495 & -0.00759 & 0.0211 & 0.0517\sym{***} & -0.0136 \\
\midrule
Ordinal Variables&&&&&\\
\addlinespace
Police ordinal& 0.0196 & -0.0303\sym{*} & 0.0709\sym{*} & 0.129\sym{***} & -0.0333\\
\addlinespace
Permit ordinal& 0.0126 & -0.0291\sym{*} & 0.0592 & 0.137\sym{***} & -0.0292\\
\midrule
Alternative Outcomes&&&&&\\
\addlinespace
School& -0.00494 & -0.00629 & 0.0151 & 0.0607\sym{***} & -0.0246\sym{**}\\
\addlinespace
Water& -0.0108 & -0.0282\sym{**} & 0.0162 & 0.0554\sym{***} & -0.0377\sym{***}\\
\bottomrule
\multicolumn{6}{l}{\footnotesize Robust standard errors (clustered by survey clusters) in parentheses}\\
\multicolumn{6}{l}{\footnotesize * p<0.05 ** p<0.01 *** p<0.001}\\
\multicolumn{6}{l}{\footnotesize All estimations include baseline individual controls, year fixed effects and region fixed effects}\\
\end{tabular}
\end{table}
\end{document}
条目显然实际上并没有重复。不知何故,一些中间规则随机地具有更大的宽度。我尝试使用 来修复宽度\midrule[0.5em]
,但随后一些线条随机不遵守。我做错了什么?
答案1
我将使用siunitx
和threeparttable
来改善表格的外观,并使用一些\multicolumn
s 作为组标题:
\documentclass[a4paper,12pt, twoside, UKenglish]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[margin=25mm, headheight=15pt]{geometry}
\usepackage{natbib}
\usepackage{fancyhdr}
\usepackage[onehalfspacing]{setspace}
\usepackage{graphicx} % enable includegraphics
\usepackage{rotating}
\usepackage{eurosym}
\usepackage{bm}
\usepackage{siunitx, caption, threeparttable}
\usepackage{booktabs}
\usepackage{hyperref}
%\setlength{\parindent}{0cm}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}
\begin{document}
\begin{table}[!htbp]
\centering
\begin{threeparttable}
\def\sym#1{\ifmmode^{\,#1}\else\(^{\,#1}\)\fi}
\sisetup{table-format=-1.5, table-number-alignment=center, table-space-text-post=$^{\,***}$, table-align-text-post=false, group-digits=false}
\caption{Summary Table - Difference-in-Differences Estimator\label{tab1}}
\begin{tabular}{@{}l*{2}{S}*{2}{S[table-format=1.4]}S@{}}
\toprule
& {(1)} & {(2)} & {(3)} & {(4)} & {(5)} \\
& {All} & {Less\_corr} & {More\_corr} & {Less\_dem} & {More\_dem} \\
\midrule
25km&&&&&\\
\addlinespace
Police& 0.0201\sym{*} & -0.0163 & 0.0550\sym{**} & 0.0988\sym{***} & -0.0128 \\
\addlinespace
Permit& 0.0129 & -0.0255\sym{**} & 0.0555\sym{**} & 0.107\sym{***} & -0.0154 \\
\midrule
75km&&&&&\\
\addlinespace
Police& 0.00786 & -0.0134 & 0.0323\sym{*} & 0.0687\sym{***} & -0.0190\sym{*} \\
\addlinespace
Permit& 0.00100 & -0.0150\sym{*} & 0.0224 & 0.0528\sym{***} & -0.0147 \\
\midrule
Rounds 2-4&&&&&\\
\addlinespace
Police& 0.0396\sym{**} & 0.00487 & 0.0783\sym{***} & 0.0814\sym{***} & 0.0112 \\
\addlinespace
Permit& 0.0471\sym{***} & 0.000628 & 0.0979\sym{***} & 0.109\sym{***} & 0.0140 \\
\midrule
Rounds 3-5&&&&&\\
\addlinespace
Police& 0.0146 & -0.00887 & 0.0418\sym{*} & 0.0815\sym{***} & -0.00929 \\
\addlinespace
Permit& 0.00899 & -0.0104 & 0.0382 & 0.0780\sym{***} & -0.00763 \\
\midrule
Incl. non-ODA&&&&&\\
\addlinespace
Police& 0.0145\sym{*} & -0.00938 & 0.0430\sym{**} & 0.0573\sym{***} & -0.00892 \\
\addlinespace
Permit& 0.00495 & -0.00759 & 0.0211 & 0.0517\sym{***} & -0.0136 \\
\midrule
\multicolumn{2}{@{}l}{Ordinal Variables} \\
\addlinespace
Police ordinal& 0.0196 & -0.0303\sym{*} & 0.0709\sym{*} & 0.129\sym{***} & -0.0333\\
\addlinespace
Permit ordinal& 0.0126 & -0.0291\sym{*} & 0.0592 & 0.137\sym{***} & -0.0292\\
\midrule
\multicolumn{2}{@{}l}{Alternative Outcomes} \\
\addlinespace
School& -0.00494 & -0.00629 & 0.0151 & 0.0607\sym{***} & -0.0246\sym{**}\\
\addlinespace
Water& -0.0108 & -0.0282\sym{**} & 0.0162 & 0.0554\sym{***} & -0.0377\sym{***}\\
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft, online]\footnotesize\smallskip
\item[Robust standard errors (clustered by survey clusters) in parentheses]
\item[* p<0.05\enspace ** p<0.01\enspace *** p<0.001]
\item[All estimations include baseline individual controls, year fixed effects and region fixed effects]
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}