我正在尝试在期刊(apa6)环境中的 LaTeX 文档(MiKTeX)中组织一组从 Stata 导入的回归结果。
我有三个表格,我想在双列文本文档类型的跨两列的单个页面中绘制它们。
所需的格式如下:
表 1:第一阶段结果:治疗概率
表 1a:近距 +/-2 表 1b:近距 +/-3 表 1c:近距 +/-5
我如何合并这三个表并使它们成为子表,并将它们放在我的双列日记帐环境中的单个页面中?
提前感谢您的反馈!
\documentclass[jou]{apa6}
%Packages
\usepackage[american]{babel}
\usepackage{hyperref}
\usepackage[inline, shortlabels]{enumitem}
\usepackage{amsmath}
\usepackage{graphicx}
\graphicspath{{Graphics/}}
\usepackage{caption, subcaption}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage{threeparttable}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{soul}
\usepackage{bookmark}
\usepackage{apacite}
\begin{document}
\maketitle
\section{Results}
\begin{table*}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{First stage Results: Probability of Treatment (Vecinity +/-2)\label{regFS2.tex}}
\begin{tabular}{l*{4}{c}}
\hline\hline
&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} \\
\hline
Eligibility Status (Z)& 0.14\sym{***}& 0.14\sym{***}& 0.10\sym{*} & 0.10\sym{*} \\
& (0.05) & (0.05) & (0.06) & (0.06) \\
[1em]
SRII Index & 0.01 & 0.21 & 0.00 & -0.20 \\
& (0.02) & (0.75) & (0.02) & (0.81) \\
[1em]
SRII 2 & & -0.30 & & 0.30 \\
& & (1.11) & & (1.21) \\
[1em]
Controls & No & No & Yes & Yes \\
\hline
Observations & 6925 & 6925 & 2291 & 2291 \\
R-squared & 0.02 & 0.02 & 0.11 & 0.11 \\
F-statistic & 10.07 & 6.72 & 12.59 & 11.68 \\
\hline\hline
\multicolumn{5}{l}{\footnotesize Standard errors are clustered at the household level.}\\
\multicolumn{5}{l}{\footnotesize Significance levels: * p<0.10, ** p<0.05, *** p<0.01.}\\
\end{tabular}
\end{table*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{table*}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{First stage Results: Probability of Treatment (Vecinity +/-3)\label{regFS3.tex}}
\begin{tabular}{l*{4}{c}}
\hline\hline
&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} \\
\hline
Eligibility Status (Z)& 0.12\sym{***}& 0.12\sym{***}& 0.12\sym{***}& 0.12\sym{**} \\
& (0.04) & (0.04) & (0.05) & (0.05) \\
[1em]
SRII Index & -0.00 & -0.13 & 0.01 & -0.13 \\
& (0.01) & (0.27) & (0.01) & (0.29) \\
[1em]
SRII 2 & & 0.20 & & 0.21 \\
& & (0.40) & & (0.43) \\
[1em]
Controls & No & No & Yes & Yes \\
\hline
Observations & 10446 & 10446 & 3442 & 3442 \\
R-squared & 0.02 & 0.02 & 0.10 & 0.10 \\
F-statistic & 15.53 & 10.41 & 17.35 & 16.05 \\
\hline\hline
\multicolumn{5}{l}{\footnotesize Standard errors are clustered at the household level.}\\
\multicolumn{5}{l}{\footnotesize Significance levels: * p<0.10, ** p<0.05, *** p<0.01.}\\
\end{tabular}
\end{table*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{table*}[htbp]\centering
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{First stage Results: Probability of Treatment (Vecinity +/-5)\label{regFS5.tex}}
\begin{tabular}{l*{4}{c}}
\hline\hline
&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} \\
\hline
Eligibility Status (Z)& 0.07\sym{**} & 0.07\sym{**} & 0.05 & 0.05 \\
& (0.03) & (0.03) & (0.04) & (0.04) \\
[1em]
SRII Index & -0.02\sym{***}& 0.00 & -0.02\sym{**} & 0.02 \\
& (0.01) & (0.08) & (0.01) & (0.08) \\
[1em]
SRII 2 & & -0.03 & & -0.06 \\
& & (0.11) & & (0.12) \\
[1em]
Controls & No & No & Yes & Yes \\
\hline
Observations & 17068 & 17068 & 5583 & 5583 \\
R-squared & 0.03 & 0.03 & 0.11 & 0.11 \\
F-statistic & 48.41 & 32.70 & 30.31 & 28.11 \\
\hline\hline
\multicolumn{5}{l}{\footnotesize Standard errors are clustered at the household level.}\\
\multicolumn{5}{l}{\footnotesize Significance levels: * p<0.10, ** p<0.05, *** p<0.01.}\\
\end{tabular}
\end{table*}
\section{Conclusion}
\bibliographystyle{apacite}
\bibliography{Bibliography_test}
\end{document}
答案1
以下是如何将这三个表格合并为一个表格的第一个粗略版本:
\documentclass[jou]{apa6}
%Packages
\usepackage[american]{babel}
\usepackage{hyperref}
\usepackage[inline, shortlabels]{enumitem}
\usepackage{amsmath}
\usepackage{graphicx}
\graphicspath{{Graphics/}}
\usepackage{caption, subcaption}
\usepackage{array}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\usepackage{threeparttable}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{blindtext}
\usepackage{xcolor}
\usepackage{soul}
\usepackage{bookmark}
\usepackage{apacite}
\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}}
\begin{document}
\section{Results}
\begin{table*}[htbp]
\centering
\setlength{\tabcolsep}{0pt}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\caption{First stage Results: Probability of Treatment\label{regFS2.tex}}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}l*{12}{c}}
\toprule
& \multicolumn{4}{c}{Vecinity +/-2} & \multicolumn{4}{c}{Vecinity +/-3} & \multicolumn{4}{c}{Vecinity +/-5}\\
\cmidrule(r){2-5} \cmidrule(lr){6-9} \cmidrule(l){10-13}
&\mc{(1)} &\mc{(2)} &\mc{(3)} &\mc{(4)} &\mc{(1)} &\mc{(2)} &\mc{(3)} &\mc{(4)} &\mc{(1)} &\mc{(2)} &\mc{(3)} &\mc{(4)} \\
\midrule
Eligibility Status (Z)& 0.14\sym{***}& 0.14\sym{***}& 0.10\sym{*} & 0.10\sym{*} & 0.12\sym{***}& 0.12\sym{***}& 0.12\sym{***}& 0.12\sym{**} & 0.07\sym{**} & 0.07\sym{**} & 0.05 & 0.05 \\
& (0.05) & (0.05) & (0.06) & (0.06) & (0.04) & (0.04) & (0.05) & (0.05) & (0.03) & (0.03) & (0.04) & (0.04) \\
\addlinespace
SRII Index & 0.01 & 0.21 & 0.00 & -0.20 & -0.00 & -0.13 & 0.01 & -0.13 & -0.02\sym{***}& 0.00 & -0.02\sym{**} & 0.02 \\
& (0.02) & (0.75) & (0.02) & (0.81) & (0.01) & (0.27) & (0.01) & (0.29) & (0.01) & (0.08) & (0.01) & (0.08) \\
\addlinespace
SRII 2 & & -0.30 & & 0.30 & & 0.20 & & 0.21 & & -0.03 & & -0.06 \\
& & (1.11) & & (1.21) & & (0.40) & & (0.43) & & (0.11) & & (0.12) \\
\addlinespace
Controls & No & No & Yes & Yes & No & No & Yes & Yes & No & No & Yes & Yes \\
\midrule
Observations & 6925 & 6925 & 2291 & 2291 & 10446 & 10446 & 3442 & 3442 & 17068 & 17068 & 5583 & 5583 \\
R-squared & 0.02 & 0.02 & 0.11 & 0.11 & 0.02 & 0.02 & 0.10 & 0.10 & 0.03 & 0.03 & 0.11 & 0.11 \\
F-statistic & 10.07 & 6.72 & 12.59 & 11.68 & 15.53 & 10.41 & 17.35 & 16.05 & 48.41 & 32.70 & 30.31 & 28.11 \\
\bottomrule
\multicolumn{5}{l}{\footnotesize Standard errors are clustered at the household level.}\\
\multicolumn{5}{l}{\footnotesize Significance levels: * p<0.10, ** p<0.05, *** p<0.01.}\\
\end{tabular*}
\end{table*}
\end{document}
答案2
在序言中
- 替换
\usepackage{threeparttable}
并\usepackage[referable]{threeparttablex}
在表格设计中使用它, - 添加
tabularx
(用于表环境)和siunitx
包(用于使用S
能够将数字小数点对齐的列类型) - 添加命令缩写的定义
multicolumn
,使用\NewExpandableDocumentCommand
命令(在xparse
包中定义,现在是 LaTeX 内核的一部分)
对于表格使用:字体大小\small
,缩小tabcolsep
到 2pt 并S
通过 自定义列参数\sisetup
。
考虑到上述情况,您的代码可以重写为:
\documentclass[jou]{apa6}
%Packages
\usepackage{booktabs, tabularx}
\usepackage[referable]{threeparttablex} % <--- for \note, \source
%\usepackage{xparse}
\NewExpandableDocumentCommand\mc{O{1}m}
{\multicolumn{#1}{c}{#2}}
\usepackage{siunitx}
\begin{document}
\section{Results}
\begin{table*}[htbp]
\centering
\sisetup{input-symbols=( ),
table-format=-1.2,
table-space-text-post=\tnote{***},
group-four-digits}
\small
\setlength{\tabcolsep}{1pt}
\begin{threeparttable}
\caption{First stage Results: Probability of Treatment}
\label{regFS2.tex}
\begin{tabularx}{\textwidth}{@{} X *{12}{S} @{}}
\toprule
& \mc[4]{Vecinity +/-2}
& \mc[4]{Vecinity +/-3}
& \mc[4]{Vecinity +/-5}\\
\cmidrule(r){2-5}
\cmidrule(lr){6-9}
\cmidrule(l){10-13}
&\mc{(1)} &\mc{(2)} &\mc{(3)} &\mc{(4)}
&\mc{(1)} &\mc{(2)} &\mc{(3)} &\mc{(4)}
&\mc{(1)} &\mc{(2)} &\mc{(3)} &\mc{(4)} \\
\midrule
Eligibility Status (Z)
& 0.14\tnote{***} & 0.14\tnote{***} & 0.10\tnote{*} & 0.10\tnote{*}
& 0.12\tnote{***} & 0.12\tnote{***} & 0.12\tnote{***} & 0.12\tnote{**}
& 0.07\tnote{**} & 0.07\tnote{**} & 0.05 & 0.05 \\
& (0.05) & (0.05) & (0.06) & (0.06)
& (0.04) & (0.04) & (0.05) & (0.05)
& (0.03) & (0.03) & (0.04) & (0.04) \\
\addlinespace
SRII Index
& 0.01 & 0.21 & 0.00 & -0.20
& -0.00 & -0.13 & 0.01 & -0.13
& -0.02\tnote{***}& 0.00 & -0.02\tnote{**} & 0.02 \\
& (0.02) & (0.75) & (0.02) & (0.81)
& (0.01) & (0.27) & (0.01) & (0.29)
& (0.01) & (0.08) & (0.01) & (0.08) \\
\addlinespace
SRII 2
& & -0.30 & & 0.30
& & 0.20 & & 0.21
& & -0.03 & & -0.06 \\
& & (1.11) & & (1.21)
& & (0.40) & & (0.43)
& & (0.11) & & (0.12) \\
\addlinespace
Controls
& {No} & {No} & {Yes} & {Yes}
& {No} & {No} & {Yes} & {Yes}
& {No} & {No} & {Yes} & {Yes} \\
\midrule
Observations
& \num{6925} & \num{6925} & \num{2291} & \num{2291}
& \num{10446} & \num{10446} & \num{3442} & \num{3442}
& \num{17068} & \num{17068} & \num{5583} & \num{5583}\\
R-squared
& 0.02 & 0.02 & 0.11 & 0.11
& 0.02 & 0.02 & 0.10 & 0.10
& 0.03 & 0.03 & 0.11 & 0.11 \\
F-statistic
& 10.07 & 6.72 & 12.59 & 11.68
& 15.53 & 10.41 & 17.35 & 16.05
& 48.41 & 32.70 & 30.31 & 28.11 \\
\bottomrule
\end{tabularx}
\begin{tablenotes}[flushleft, para]\footnotesize
\note Standard errors are clustered at the household level. Significance levels:
%
\item[*] $p<$0.1; \item[**] $p<0.05$; and \item[***] $p<0.01$
\end{tablenotes}
\end{threeparttable}
\end{table*}
\end{document}
并给出结果,其中小数在小数点处对齐(无论它们是否有减号或是否在括号中),并且花括号中的整数如果长度超过三位数字则分组:
编辑:
对于上述软件包的新版本,siunitx
MWE 不起作用,因为它不再定义input-symbols
(和group-four-digits
) 选项。因此,您需要进行以下更改之一:
- 替换
\usepackage{siunitx}
为\usepackage{siunitx}[=v2]
调用向后可组合性到siunutx
版本 2,或者 - 对列使用以下设置
S
:
\sisetup{input-open-uncertainty=,
input-close-uncertainty=,
table-align-text-before= false,
table-format={(}-1.2{$^{***}$},
group-minimum-digits=4}
经过这一更改后,结果与原始答案相同。