我正在使用以下 Stata 代码导出包含 5 个时期内 4 个变量的平均值的表格。
est clear
forv p=1/5 {
eststo filenum`p': quietly estpost summarize x1111 x22222 x33333333 x444444444444 if filenum==`p'
}
esttab filenum* using "C_centcomp.tex", replace title(Minimum Working Example\label{tab1}) cells("mean(pattern(1 1 1 1 1) fmt(2))") collabels(none) label booktabs nomtitle nonotes ///
addnotes("\begin{minipage}{1.0\linewidth} \footnotesize \smallskip Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blahblah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah \end{minipage}")
这是最终的 LaTeX 代码。
\begin{table}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{Minimum Working Example\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)}\\
\midrule
x1111 & 0.41& 0.41& 0.41& 0.43& 0.43\\
x22222 & 0.05& 0.05& 0.05& 0.05& 0.05\\
x33333333 & 0.54& 0.54& 0.55& 0.55& 0.56\\
x444444444444 & 0.14& 0.14& 0.14& 0.14& 0.14\\
\midrule
Observations & 1527& 1478& 1429& 1297& 1180\\
\bottomrule
\multicolumn{6}{l}{\footnotesize \begin{minipage}{1.0\linewidth} \footnotesize \smallskip Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blahblah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah\end{minipage}}\\
\end{tabular}
\end{table}
运行 LaTeX 代码后,您会注意到列间距不均匀。您能否建议对 Stata 代码进行修改,以便列间距正确反映在 LaTeX 代码中。谢谢。
答案1
我建议你使用三部分包。这样,图例可以自动格式化,使其宽度等于相关tabular
环境的宽度,同时避免将图例放置在minipage
某个预定宽度中可能产生的任何复杂性。
顺便说一句,我看不出有什么理由将列标题((1)、(2) 等)放在\multicolumn{1}{c}{...}
“包装器”中。这是由 Stata 完成的吗?
\documentclass{article}
\usepackage{booktabs}
\usepackage[flushleft]{threeparttable}
\renewcommand{\TPTtagStyle}{\textit}
\begin{document}
\begin{table}[htbp]
\centering
\begin{threeparttable}
% Part 1: the caption
\caption{Minimum Working Example\tnote{a}}\label{tab1}
% Part 2: the tabular-like environment (with \tnote{...} directives)
\begin{tabular}{@{} l *{5}{c} @{}}
\toprule
& (1) & (2) & (3) & (4) & (5) \\
\midrule
x1111 & 0.41& 0.41& 0.41& 0.43& 0.43\\
x22222 & 0.05& 0.05& 0.05& 0.05& 0.05\\
x33333333 & 0.54& 0.54& 0.55& 0.55& 0.56\\
x444444444444 & 0.14& 0.14& 0.14& 0.14& 0.14\\
\midrule
Observations\tnote{b} & 1527& 1478& 1429& 1297& 1180\\
\bottomrule
\end{tabular}
\smallskip
\footnotesize
% Part 3: the table notes (with \item[...] directives
\begin{tablenotes}[flushleft]
\item[a] Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\item[b] blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}