我正在尝试构建一个长三部分表格。工作代码如下。请告诉我这里出了什么问题。
\begin{longtable}{
l
>{\raggedright\arraybackslash}p{7cm}
>{\raggedright\arraybackslash}p{8cm}}
\begin{threeparttable}
\caption{Weighted Least Square Estimations – Outcome: $\Delta R_{(t+1)}$}
\label{tab:wls1}\\
\toprule
\textbf{} &\textbf{(1)} & \textbf{(2)} & \textbf{(3)} & \textbf{(4)}
\endfirsthead
\caption{-- continued from previous page}\\
\toprule
\textbf{} &\textbf{(1)} & \textbf{(2)} & \textbf{(3)} & \textbf{(4)}
\endhead
\bottomrule
\multicolumn{5}{r}{{Continued on next page}} \\
\endfoot
\bottomrule
\endlastfoot \midrule
\multicolumn{1}{l}{a } & \multicolumn{1}{r}{0.001} & \multicolumn{1}{r}{-0.0005} & \multicolumn{1}{r}{-0.002} & \multicolumn{1}{r}{-0.001} \\
\multicolumn{1}{l}{b} & \multicolumn{1}{r}{-0.001} & \multicolumn{1}{r}{-0.003} & \multicolumn{1}{r}{-0.003} & \multicolumn{1}{r}{-0.005} \\
\multicolumn{1}{l}{c} & \multicolumn{1}{r}{-0.063***} & \multicolumn{1}{r}{-0.081***} & \multicolumn{1}{r}{-0.079***} & \multicolumn{1}{r}{-0.080***} \\
\multicolumn{1}{l}{d} & \multicolumn{1}{r}{-0.082} & \multicolumn{1}{r}{-0.132**} & \multicolumn{1}{r}{-0.171***} & \multicolumn{1}{r}{-0.184***} \\
\multicolumn{1}{l}{f} & \multicolumn{1}{r}{-0.255**} & \multicolumn{1}{r}{-0.253**} & \multicolumn{1}{r}{-0.307***} & \multicolumn{1}{r}{-0.278**} \\
\multicolumn{1}{l}{g} & \multicolumn{1}{r}{0.022} & \multicolumn{1}{r}{0.015} & \multicolumn{1}{r}{0.004} & \multicolumn{1}{r}{-0.003} \\
\multicolumn{1}{l}{a } & \multicolumn{1}{r}{-0.002***} & \multicolumn{1}{r}{-0.003***} & \multicolumn{1}{r}{-0.003***} & \multicolumn{1}{r}{-0.004***} \\
\multicolumn{1}{l}{b} & \multicolumn{1}{r}{0.012} & \multicolumn{1}{r}{0.016} & \multicolumn{1}{r}{0.014} & \multicolumn{1}{r}{0.013} \\
\multicolumn{1}{l}{c} & \multicolumn{1}{r}{-0.002} & \multicolumn{1}{r}{-0.002} & \multicolumn{1}{r}{-0.003} & \multicolumn{1}{r}{-0.004*} \\
\multicolumn{1}{l}{d} & \multicolumn{1}{r}{-0.412***} & \multicolumn{1}{r}{-0.333***} & \multicolumn{1}{r}{-0.413***} & \multicolumn{1}{r}{-0.367***} \\
\multicolumn{1}{l}{f} & \multicolumn{1}{r}{0.006*} & \multicolumn{1}{r}{0.006} & \multicolumn{1}{r}{0.004} & \multicolumn{1}{r}{0.003} \\
\multicolumn{1}{l}{g} & \multicolumn{1}{r}{-0.012} & \multicolumn{1}{r}{-0.021*} & \multicolumn{1}{r}{-0.021*} & \multicolumn{1}{r}{-0.018} \\
\multicolumn{1}{l}{a } & \multicolumn{1}{r}{0.008**} & \multicolumn{1}{r}{0.011***} & \multicolumn{1}{r}{0.011***} & \multicolumn{1}{r}{0.012***} \\
\multicolumn{1}{l}{b} & \multicolumn{1}{r}{-0.049***} & \multicolumn{1}{r}{-0.045***} & \multicolumn{1}{r}{-0.046***} & \multicolumn{1}{r}{-0.046***} \\
\multicolumn{1}{l}{c} & \multicolumn{1}{r}{0.024**} & \multicolumn{1}{r}{0.021*} & \multicolumn{1}{r}{0.024*} & \multicolumn{1}{r}{0.027**} \\
\multicolumn{1}{l}{d} & \multicolumn{1}{r}{-0.001} & \multicolumn{1}{r}{-0.036} & \multicolumn{1}{r}{-0.043} & \multicolumn{1}{r}{-0.027} \\
\multicolumn{1}{l}{f} & \multicolumn{1}{r}{-0.011*} & \multicolumn{1}{r}{0.001} & \multicolumn{1}{r}{0.0001} & \multicolumn{1}{r}{0.004} \\
\multicolumn{1}{l}{g} & \multicolumn{1}{r}{-0.016} & \multicolumn{1}{r}{-0.016} & \multicolumn{1}{r}{-0.017} & \multicolumn{1}{r}{-0.018*} \\
\multicolumn{1}{l}{a } & \multicolumn{1}{r}{-0.013**} & \multicolumn{1}{r}{-0.0002} & \multicolumn{1}{r}{0.001} & \multicolumn{1}{r}{-0.004} \\
\multicolumn{1}{l}{b} & \multicolumn{1}{r}{0.009} & \multicolumn{1}{r}{0.007} & \multicolumn{1}{r}{0.006} & \multicolumn{1}{r}{0.012} \\
\multicolumn{1}{l}{c} & \multicolumn{1}{r}{-0.268***} & \multicolumn{1}{r}{-0.229***} & \multicolumn{1}{r}{-0.249***} & \multicolumn{1}{r}{-0.226***} \\
\multicolumn{1}{l}{d} & \multicolumn{1}{r}{0.011} & \multicolumn{1}{r}{0.008} & \multicolumn{1}{r}{0.009} & \multicolumn{1}{r}{0.011} \\
\multicolumn{1}{l}{f} & \multicolumn{1}{r}{-0.003} & \multicolumn{1}{r}{-0.002} & \multicolumn{1}{r}{-0.006} & \multicolumn{1}{r}{-0.007} \\
\multicolumn{1}{l}{g} & \multicolumn{1}{r}{0.005} & \multicolumn{1}{r}{0.007} & \multicolumn{1}{r}{0.005} & \multicolumn{1}{r}{0.003} \\
\multicolumn{1}{l}{a } & \multicolumn{1}{r}{0.0004} & \multicolumn{1}{r}{0.002} & \multicolumn{1}{r}{0.002*} & \multicolumn{1}{r}{0.002} \\
\multicolumn{1}{l}{b} & \multicolumn{1}{r}{0.053**} & \multicolumn{1}{r}{0.067**} & \multicolumn{1}{r}{0.064**} & \multicolumn{1}{r}{0.060**} \\
\multicolumn{1}{l}{c} & \multicolumn{1}{r}{1.289} & \multicolumn{1}{r}{0.912} & \multicolumn{1}{r}{1.006} & \multicolumn{1}{r}{0.97} \\
\multicolumn{1}{l}{d} & & \multicolumn{1}{r}{-0.016**} & \multicolumn{1}{r}{-0.015*} & \multicolumn{1}{r}{-0.007} \\
\multicolumn{1}{l}{f} & & \multicolumn{1}{r}{0.007} & \multicolumn{1}{r}{0.007} & \multicolumn{1}{r}{0.011} \\
\multicolumn{1}{l}{g} & & \multicolumn{1}{r}{-0.029***} & \multicolumn{1}{r}{-0.030***} & \multicolumn{1}{r}{-0.028***} \\
\multicolumn{1}{l}{a } & & \multicolumn{1}{r}{0.001} & \multicolumn{1}{r}{0.001} & \multicolumn{1}{r}{0.002} \\
\multicolumn{1}{l}{b} & & \multicolumn{1}{r}{-0.005} & \multicolumn{1}{r}{-0.004} & \multicolumn{1}{r}{-0.007} \\
\multicolumn{1}{l}{c} & & \multicolumn{1}{r}{-0.016*} & \multicolumn{1}{r}{-0.014} & \multicolumn{1}{r}{-0.014} \\
\multicolumn{1}{l}{d} & & & \multicolumn{1}{r}{-0.001} & \multicolumn{1}{r}{-0.001} \\
\multicolumn{1}{l}{f} & & & \multicolumn{1}{r}{-0.006} & \multicolumn{1}{r}{-0.005} \\
\multicolumn{1}{l}{g} & & & \multicolumn{1}{r}{0.003} & \multicolumn{1}{r}{0.006} \\
\multicolumn{1}{l}{a } & & & \multicolumn{1}{r}{0.008} & \multicolumn{1}{r}{0.011} \\
\multicolumn{1}{l}{b} & & & \multicolumn{1}{r}{-0.018**} & \multicolumn{1}{r}{-0.018**} \\
\multicolumn{1}{l}{c} & & & \multicolumn{1}{r}{0.002} & \multicolumn{1}{r}{-0.015} \\
\multicolumn{1}{l}{d} & & & \multicolumn{1}{r}{0.0002} & \multicolumn{1}{r}{-0.019*} \\
\multicolumn{1}{l}{f} & & & \multicolumn{1}{r}{0.002} & \multicolumn{1}{r}{-0.011} \\
\multicolumn{1}{l}{g} & & & \multicolumn{1}{r}{-0.007} & \multicolumn{1}{r}{-0.016} \\
\multicolumn{1}{l}{a } & & & \multicolumn{1}{r}{-0.015*} & \multicolumn{1}{r}{-0.030***} \\
\multicolumn{1}{l}{b} & & & & \multicolumn{1}{r}{0.004*} \\
\multicolumn{1}{l}{c} & & & & \multicolumn{1}{r}{0.009*} \\
\multicolumn{1}{l}{d} & & & & \multicolumn{1}{r}{-0.013} \\
\multicolumn{1}{l}{f} & & & & \multicolumn{1}{r}{0.0003} \\
\multicolumn{1}{l}{g} & & & & \multicolumn{1}{r}{0.042**} \\
\multicolumn{1}{l}{a } & \multicolumn{1}{r}{0.302***} & \multicolumn{1}{r}{0.264***} & \multicolumn{1}{r}{0.288***} & \multicolumn{1}{r}{0.270***} \\
\midrule
\multicolumn{1}{l}{Observations} & \multicolumn{1}{r}{1,210} & \multicolumn{1}{r}{1,210} & \multicolumn{1}{r}{1,210} & \multicolumn{1}{r}{1,210} \\
\multicolumn{1}{l}{R2} & \multicolumn{1}{r}{0.17} & \multicolumn{1}{r}{0.185} & \multicolumn{1}{r}{0.197} & \multicolumn{1}{r}{0.208} \\
\multicolumn{1}{l}{Adjusted R2} & \multicolumn{1}{r}{0.151} & \multicolumn{1}{r}{0.162} & \multicolumn{1}{r}{0.168} & \multicolumn{1}{r}{0.176} \\
\multicolumn{1}{l}{Residual Std. Error} & \multicolumn{1}{r}{0.003} & \multicolumn{1}{r}{0.003} & \multicolumn{1}{r}{0.003} & \multicolumn{1}{r}{0.003} \\
\multicolumn{1}{l}{F Statistic} & \multicolumn{1}{r}{8.989*** } & \multicolumn{1}{r}{8.079***} & \multicolumn{1}{r}{6.662***} & \multicolumn{1}{r}{6.367***} \\
\midrule
\multicolumn{5}{c}{*p<0.1; **p<0.05; ***p<0.01} \\
\being{tablenotes}
\footnotesize
This table provides the results of OLS.
\end{tablenotes}
\end{threeparttable}
\end{longtable}%
答案1
正如我在评论中所说,对于表格末尾的评论你不需要threepartavble
,它可以放在multicolumn
环境中,例如
\multicolumn{5}{l}{\footnotesize
This table provides the results of OLS.
}
如果你坚持使用threepartable
,那么考虑达莱夫评论。
无关:
您的表格没有必要那么复杂(就像您之前的问题中那样,我已经重写了它的代码):所有multicolumn{1}...
都是多余的,如果对于列类型使用S
来自包的列类型,您会得到更好的结果siunitx
。最后不要这样做,下次请考虑大卫·卡莱尔评论。如果您喜欢我们帮助您,请帮助我们。
完全修改后的 MWE 为:
\documentclass[12pt, a4paper, twoside]{article}
\usepackage{array,booktabs,longtable,tabularx}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}% <-- added
\usepackage{caption}% <-- added
\usepackage{ltablex}% <-- added
\usepackage{siunitx}% <-- added
\usepackage[margin=30mm]{geometry}% <-- added
\usepackage{showframe}% don't use in real document
\renewcommand*\ShowFrameColor{\color{red}}% don't use in real document
\begin{document}
\begin{tabularx}{\textwidth}{X*{4}{S[table-format=-2.4,
table-space-text-post=***]}
}
\caption{Weighted Least Square Estimations – Outcome: $\Delta R_{(t+1)}$}
\label{tab:wls1}\\
\toprule
\textbf{} & {\textbf{(1)}} & {\textbf{(2)}} & {\textbf{(3)}} & {\textbf{(4)}}\\
\endfirsthead
\caption{-- continued from previous page}\\
\toprule
\textbf{} & {\textbf{(1)}} & {\textbf{(2)}} & {\textbf{(3)}} & {\textbf{(4)}}\\
\endhead
\bottomrule
\multicolumn{5}{r}{{Continued on next page}} \\
\endfoot
\bottomrule
\endlastfoot
\midrule
a & 0.001 & -0.0005 & -0.002 & -0.001 \\
b & -0.001 & -0.003 & -0.003 & -0.005 \\
c & -0.063*** & -0.081*** & -0.079*** & -0.080*** \\
d & -0.082 & -0.132** & -0.171*** & -0.184*** \\
f & -0.255** & -0.253** & -0.307*** & -0.278** \\
g & 0.022 & 0.015 & 0.004 & -0.003 \\
\addlinespace
a & -0.002*** & -0.003*** & -0.003*** & -0.004*** \\
b & 0.012 & 0.016 & 0.014 & 0.013 \\
c & -0.002 & -0.002 & -0.003 & -0.004* \\
d & -0.412*** & -0.333*** & -0.413*** & -0.367*** \\
f & 0.006* & 0.006 & 0.004 & 0.003 \\
g & -0.012 & -0.021* & -0.021* & -0.018 \\
\addlinespace
a & 0.008** & 0.011*** & 0.011*** & 0.012*** \\
b & -0.049*** & -0.045*** & -0.046*** & -0.046*** \\
c & 0.024** & 0.021* & 0.024* & 0.027** \\
d & -0.001 & -0.036 & -0.043 & -0.027 \\
f & -0.011* & 0.001 & 0.0001 & 0.004 \\
g & -0.016 & -0.016 & -0.017 & -0.018* \\
\addlinespace
a & -0.013** & -0.0002 & 0.001 & -0.004 \\
b & 0.009 & 0.007 & 0.006 & 0.012 \\
c & -0.268*** & -0.229*** & -0.249*** & -0.226*** \\
d & 0.011 & 0.008 & 0.009 & 0.011 \\
f & -0.003 & -0.002 & -0.006 & -0.007 \\
g & 0.005 & 0.007 & 0.005 & 0.003 \\
\addlinespace
a & 0.0004 & 0.002 & 0.002* & 0.002 \\
b & 0.053** & 0.067** & 0.064** & 0.060** \\
c & 1.289 & 0.912 & 1.006 & 0.97 \\
d & & -0.016** & -0.015* & -0.007 \\
f & & 0.007 & 0.007 & 0.011 \\
g & & -0.029*** & -0.030*** & -0.028*** \\
\addlinespace
a & & 0.001 & 0.001 & 0.002 \\
b & & -0.005 & -0.004 & -0.007 \\
c & & -0.016* & -0.014 & -0.014 \\
d & & & -0.001 & -0.001 \\
f & & & -0.006 & -0.005 \\
g & & & 0.003 & 0.006 \\
\addlinespace
a & & & 0.008 & 0.011 \\
b & & & -0.018** & -0.018** \\
c & & & 0.002 & -0.015 \\
d & & & 0.0002 & -0.019* \\
f & & & 0.002 & -0.011 \\
g & & & -0.007 & -0.016 \\
\addlinespace
a & & & -0.015* & -0.030*** \\
b & & & & 0.004* \\
c & & & & 0.009* \\
d & & & & -0.013 \\
f & & & & 0.0003 \\
g & & & & 0.042** \\
\addlinespace
a & 0.302*** & 0.264*** & 0.288*** & 0.270*** \\
\midrule
Observations & 1,210 & 1,210 & 1,210 & 1,210 \\
R2 & 0.17 & 0.185 & 0.197 & 0.208 \\
Adjusted R2 & 0.151 & 0.162 & 0.168 & 0.176 \\
Residual Std. Error & 0.003 & 0.003 & 0.003 & 0.003 \\
F Statistic & 8.989*** & 8.079*** & 6.662*** & 6.367*** \\
\midrule
\multicolumn{5}{c}{*p<0.1; **p<0.05; ***p<0.01} \\
\multicolumn{5}{l}{\footnotesize
This table provides the results of OLS.
}
\end{tabularx}
\end{document}
答案2
您不需要任何这些\multicolumn
s。另一方面,threeparttable
不适用于longtable
;您必须使用threeparttablex
,它的语法略有不同,正如@daleif 所评论的:表格注释必须在开头声明,并用 插入到您想要的位置\insertTableNotes
。我建议使用 的S
列类型来 siunitx
对齐每列中的数字。由于似乎有数据组(a、b、c、d、e、f、g、a、b、c……),我用 将它们分隔开\addlinespace
。另外;我在标题下添加了一些填充。最后,我认为对表名进行硬编码大写也可能使其在交叉引用中变为大写,因此我更喜欢定义uppercase
标签格式:
\documentclass[a4paper]{article}%
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}%
\usepackage{caption}
\DeclareCaptionLabelFormat{uppercase}{\MakeUppercase{#1}~#2}
\captionsetup{labelsep=newline, aboveskip=1ex, labelfont={bf}, labelformat = uppercase}
\usepackage{booktabs, siunitx}
\usepackage[svgnames]{xcolor}
\usepackage{longtable}
\usepackage[flushleft]{threeparttablex}
\begin{document}
\begin{ThreePartTable}
\sisetup{table-format=-1.3, table-number-alignment=center, table-space-text-post=***}
\begin{TableNotes}%
\footnotesize
\item[] * p < 0.1; ** p < 0.05; *** p < 0.01\medskip
\item[] This table provides the results of OLS.
\end{TableNotes}
\begin{longtable}{l*{4}{S}} \caption{Weighted Least Square Estimations – Outcome: $\Delta R_{(t+1)}$}
\label{tab:wls1}\\
\toprule
&{\bfseries(1)} & {\bfseries(2)} &{\bfseries(3)} & {\bfseries(4)} \\%
\endfirsthead
\caption{-- continued from previous page}\\
\toprule
& {\bfseries(1)} & {\bfseries(2)} &{\bfseries(3)} & {\bfseries(4)}\\
\endhead
\bottomrule
\addlinespace
\multicolumn{5}{r}{\footnotesize Continued on next page} \\
\endfoot
\bottomrule
\addlinespace
\insertTableNotes\\
\endlastfoot %
\midrule
a & 0.001 & -0.0005 & -0.002 & -0.001 \\
b & -0.001 & -0.003 & -0.003 & -0.005 \\
c & -0.063*** & -0.081*** & -0.079*** & -0.080*** \\
d & -0.082 & -0.132** & -0.171*** & -0.184*** \\
f & -0.255** & -0.253** & -0.307*** & -0.278** \\
g & 0.022 & 0.015 & 0.004 & -0.003 \\
\addlinespace
a & -0.002*** & -0.003*** & -0.003*** & -0.004*** \\
b & 0.012 & 0.016 & 0.014 & 0.013 \\
c & -0.002 & -0.002 & -0.003 & -0.004* \\
d & -0.412*** & -0.333*** & -0.413*** & -0.367*** \\
f & 0.006* & 0.006 & 0.004 & 0.003 \\
g & -0.012 & -0.021* & -0.021* & -0.018 \\
\addlinespace
a & 0.008** & 0.011*** & 0.011*** & 0.012*** \\
b & -0.049*** & -0.045*** & -0.046*** & -0.046*** \\
c & 0.024** & 0.021* & 0.024* & 0.027** \\
d & -0.001 & -0.036 & -0.043 & -0.027 \\
f & -0.011* & 0.001 & 0.0001 & 0.004 \\
g & -0.016 & -0.016 & -0.017 & -0.018* \\
\addlinespace
a & -0.013** & -0.0002 & 0.001 & -0.004 \\
b & 0.009 & 0.007 & 0.006 & 0.012 \\
c & -0.268*** & -0.229*** & -0.249*** & -0.226*** \\
d & 0.011 & 0.008 & 0.009 & 0.011 \\
f & -0.003 & -0.002 & -0.006 & -0.007 \\
g & 0.005 & 0.007 & 0.005 & 0.003 \\
\addlinespace
a & 0.0004 & 0.002 & 0.002* & 0.002 \\
b & 0.053** & 0.067** & 0.064** & 0.060** \\
c & 1.289 & 0.912 & 1.006 & 0.97 \\
d & & -0.016** & -0.015* & -0.007 \\
f & & 0.007 & 0.007 & 0.011 \\
g & & -0.029*** & -0.030*** & -0.028*** \\
\addlinespace
a & & 0.001 & 0.001 & 0.002 \\
b & & -0.005 & -0.004 & -0.007 \\
c & & -0.016* & -0.014 & -0.014 \\
d & & & -0.001 & -0.001 \\
f & & & -0.006 & -0.005 \\
g & & & 0.003 & 0.006 \\
\addlinespace
a & & & 0.008 & 0.011 \\
b & & & -0.018** & -0.018** \\
c & & & 0.002 & -0.015 \\
d & & & 0.0002 & -0.019* \\
f & & & 0.002 & -0.011 \\
g & & & -0.007 & -0.016 \\
\addlinespace
a & & & -0.015* & -0.030*** \\
b & & & & 0.004* \\
c & & & & 0.009* \\
d & & & & -0.013 \\
f & & & & 0.0003 \\
g & & & & 0.042** \\
\addlinespace
a & 0.302*** & 0.264*** & 0.288*** & 0.270*** \\
\midrule
Observations & 1,210 & 1,210 & 1,210 & 1,210 \\
R2 & 0.17 & 0.185 & 0.197 & 0.208 \\
Adjusted R2 & 0.151 & 0.162 & 0.168 & 0.176 \\
Residual Std. Error & 0.003 & 0.003 & 0.003 & 0.003 \\
F Statistic & 8.989*** & 8.079*** & 6.662*** & 6.367*** \end{longtable}%
\end{ThreePartTable}
\end{document}