标题中的回归表和数学的对齐问题

标题中的回归表和数学的对齐问题

我在回归表中的逗号对齐方面遇到了问题。由于标题中也有数学表达式,我找到的其他解决方案不起作用。这里还能把逗号排成一行吗?这是一个最小的例子(我使用 LuaLaTeX):

\documentclass[12pt]{scrartcl}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{unicode-math}
\usepackage{booktabs}
\usepackage{array}
\usepackage{threeparttable}
\usepackage{tabularx}

\begin{document}

\begin{table}[h]
\begin{center}
\caption{Table}
\begin{threeparttable}
\begin{tabularx}{0.7\textwidth}{@{}>{$}X<{$}>{$}c<{$}>{$}c<{$}>{$}c<{$}@{}}\\
\toprule
& (\text{minw} - p50) & (\text{minw} - p50)^2 & R^2\\
\midrule
p5 - p50 & 1{,}106^{***} & 0{,}375^{***} & 0{,}441\\
& (0{,}100) & (0{,}085) &\\
p10 - p50 & 1{,}161^{***} & 0{,}516^{***} & 0{,}575\\
& (0{,}089) & (0{,}079) &\\
\bottomrule
\end{tabularx}
\begin{tablenotes}[flushleft]
\setlength\labelsep{0pt} %So that the word „Notes“ is on the left margin
\footnotesize
\item[]Notes
\end{tablenotes}
\end{threeparttable}
\end{center}
\end{table}

\end{document}

输出如下: 在此处输入图片描述

答案1

我的主要建议是,你采用包及其D列类型,而不是c列类型,以便将三个数据列中的数字与各自的小数点标记(逗号,不再需要用花括号括起来)对齐。第二个建议是将\caption指令里面环境并在环境启动后立即threeparttable省略该指令。第三,不要使用\\tabularxcenter 环境在环境内table;而是使用\centering命令。

在此处输入图片描述

\documentclass[12pt]{scrartcl}
%\usepackage{amsmath} % 'amsmath' is loaded automatically by 'mathtools'
\usepackage{mathtools}
\usepackage{unicode-math}
\usepackage{booktabs}
%\usepackage{array} % 'array' is loaded automatically by 'tabularx'
\usepackage{threeparttable}
\usepackage{tabularx}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D,,{#1}} % perform alignment on commas
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro

\begin{document}

\begin{table}[ht]
\centering % not '\begin{center}'
\begin{threeparttable}
\caption{Table} % \caption directive should be part of 'threeparttable' env.
\begin{tabularx}{0.7\textwidth}{@{} >{$}X<{$} *{2}{d{2.5}} d{1.3} @{}}
\toprule
& \mc{$(\textrm{minw} - p50)$} 
  & \mc{$(\textrm{minw} - p50)^2$} 
    & \multicolumn{1}{c@{}}{$R^2$} \\
\midrule
p5 - p50  & 1,106^{***} & 0,375^{***} & 0,441 \\
          & (0,100)     & (0,085) \\
p10 - p50 & 1,161^{***} & 0,516^{***} & 0,575 \\
          & (0,089)     & (0,079) \\
\bottomrule
\end{tabularx}

\smallskip\footnotesize
\begin{tablenotes}[flushleft]
\setlength\labelsep{0pt} %So that the word „Notes“ is on the left margin
\item[]Notes 
\end{tablenotes}

\end{threeparttable}
%\end{center}
\end{table}

\end{document}

答案2

您可以尝试使用\mathrlap

\documentclass[12pt]{scrartcl}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{unicode-math}
\usepackage{booktabs}
\usepackage{array}
\usepackage{threeparttable}
\usepackage{tabularx}

\begin{document}

\begin{table}[h]
\begin{center}
\caption{Table}
\begin{threeparttable}
\begin{tabularx}{0.7\textwidth}{@{}>{$}X<{$}>{$}c<{$}>{$}c<{$}>{$}c<{$}@{}}\\
\toprule
& (\text{minw} - p50) & (\text{minw} - p50)^2 & R^2\\
\midrule
p5 - p50 & 1{,}106\mathrlap{^{***}} & 0{,}375\mathrlap{^{***}} & 0{,}441\\
& (0{,}100) & (0{,}085) &\\
p10 - p50 & 1{,}161\mathrlap{^{***}} & 0{,}516\mathrlap{^{***}} & 0{,}575\\
& (0{,}089) & (0{,}079) &\\
\bottomrule
\end{tabularx}
\begin{tablenotes}[flushleft]
\setlength\labelsep{0pt} %So that the word „Notes“ is on the left margin
\footnotesize
\item[]Notes
\end{tablenotes}
\end{threeparttable}
\end{center}
\end{table}

\end{document}

上述代码的输出

相关内容