我有以下文本:
\documentclass[11pt]{article}
\usepackage{rotating}
\usepackage{longtable}
\usepackage[labelfont=bf, labelsep=newline, justification=centering, textfont=it]{caption}
\usepackage{adjustbox}
\usepackage{graphicx}
\usepackage{booktabs, makecell, siunitx}
\usepackage{eqparbox}
\pagenumbering{gobble}
\usepackage{booktabs}
\usepackage[referable,para]{threeparttablex}
\usepackage[a4paper,margin=1.5cm]{geometry}
\usepackage{multirow}
\usepackage{pdflscape}
\usepackage{stackengine}
\usepackage{interval}
\usepackage{amsmath,ragged2e} % <-- new
\usepackage{interval,pbox}
\sisetup{group-separator={,}, table-format=1.3, table-space-text-post=***,
table-number-alignment =center}
\newcommand*{\MyIndent}
{\hspace*{1.5cm}}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D..{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\newcommand\mytab[1]{%
\smash[b]{\begin{tabular}[t]{@{}c@{}}#1\end{tabular}}}
\hyphenation{bur-kina}
\begin{document}
\begin{table}[p]
\setlength{\tabcolsep}{10pt}
\caption{Summary statistics}
\label{tab:sumstat}
\centering
\normalsize
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{threeparttable}
\begin{tabular}{l*{5}{d{1.5}}}
\toprule \toprule
Variables & \mc{Obs.} &\mc{Mean} &\mc{S.D.} &\mc{Min.} &\mc{Max.} \\
\midrule
HP & 326,463 & 0.841 & 0.365 & \mc{0} & \mc{1}\\
CAF & 326,463 & 0.006 & 2.213 & -7.446 & 4.996\\
GLOB & 326,463 & 0.255 & 0.436 & \mc{0} & \mc{1}\\
\bottomrule \bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item[]{\textit{Notes}:My notes}
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
当我编译它时,我得到以下结果:
我不明白为什么红色突出显示的三列没有对齐。
对此有任何支持吗?
答案1
不清楚你的第二栏内容是什么。我怀疑你想实现这样的目标:
但我不确定(请参阅我在你的问题下面的评论)。
通过使用tabularray
和siunitx
包,重现上表的 MWE 为:
\documentclass[11pt]{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\sisetup{group-separator={,},
table-format=-1.3
}
\begin{document}
\begin{table}[p]
\centering
\begin{talltblr}[
caption = {Summary statistics},
label = {tab:sumstat},
remark{Note} = {My notes}
]{
l S[table-format=6.0] *{4}{S}
}
\toprule
Variables & {{{Obs.}}} & {{{Mean}}} & {{{S.D.}}} & {{{Min.}}} & {{{Max.}}} \\
\midrule
HP & 326 463 & 0.841 & 0.365 & {{{0}}} & {{{1}}} \\
CAF & 326 463 & 0.006 & 2.213 & -7.446 & 4.996 \\
GLOB & 326 463 & 0.255 & 0.436 & {{{0}}} & {{{1}}} \\
\bottomrule
\end{talltblr}
\end{table}
\end{document}
答案2
利用siunitx
而不是dcolumn
。
\documentclass[11pt]{article}
\usepackage[labelfont=bf, labelsep=newline, justification=centering, textfont=it]{caption}
\usepackage{booktabs,siunitx}
\usepackage[referable,para]{threeparttablex}
\usepackage[a4paper,margin=1.5cm]{geometry}
\sisetup{
group-separator={,},
%table-format=1.3,
%table-space-text-post=***,
%table-number-alignment =center
}
\begin{document}
\begin{table}[p]
\centering
\begin{threeparttable}
\setlength{\tabcolsep}{10pt}
\caption{Summary statistics}
\label{tab:sumstat}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
\begin{tabular}{
@{}
l
S[table-format=3.3]
S[table-format=1.3]
S[table-format=1.3]
S[table-format=-1.3]
S[table-format=1.3]
@{}
}
\toprule
Variables & {Obs.} & {Mean} & {S.D.} & {Min.} & {Max.} \\
\midrule
HP & 326,463 & 0.841 & 0.365 & 0 & 1 \\
CAF & 326,463 & 0.006 & 2.213 & -7.446 & 4.996 \\
GLOB & 326,463 & 0.255 & 0.436 & 0 & 1 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item[]{\textit{Notes}: My notes}
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
我注释掉了\sisetup
实际上不属于那里的三个设置。