我想创建一个表格,在其中按点对齐条目。对于第一列条目值,这种对齐效果很好。但是,对于第二列,方括号括起来的负值发生了移动,因此点没有对齐。有什么建议可以解决这个问题吗?
\begin{table}[htbp!]
\centering
\begin{tabular}{*{1}{l}*{3}{S[table-format=1.2]}}
\toprule
\toprule
& {$\alpha$} & {$\beta$} & {$R^{2}$}\\
\midrule
Credit Spread & 0.00 & 0.13 & 0.00\\
&\hbox{[$0.26$]} & \hbox{[$-5.56$]} & \\
\addlinespace
\bottomrule
\end{tabular}
\end{table}
答案1
我假设你正在尝试做以下事情
\documentclass[a4paper]{memoir}
\usepackage{siunitx}
\begin{document}
\begin{table}[htbp!]
\centering
\sisetup{
parse-numbers=false,
}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\begin{tabular}{
l
S[table-format=2.3] % space for []'s
S[table-format=-2.3] %
S[table-format=1.3] %
}
\toprule
& \mc{$\alpha$} & \mc{$\beta$} & \mc{$R^{2}$}
\\
\midrule
Credit Spread & 0.00 & 0.13 & 0.00
\\
& [0.26] & [-5.56] &
\\
\addlinespace
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
您需要为括号保留空间:
\documentclass{article}
\usepackage{siunitx,booktabs}
\begin{document}
\begin{table}[htp]
\centering
\caption{Whatever}
\sisetup{
table-space-text-pre=[,
table-space-text-post=],
}
\begin{tabular}{
l
S[table-format=1.2]
S[table-format=-1.2]
S[table-format=1.2]
}
\toprule
& {$\alpha$} & {$\beta$} & {$R^{2}$}\\
\midrule
Credit Spread & 0.00 & 0.13 & 0.00 \\
& [0.26] & [-5.56] & \\
\bottomrule
\end{tabular}
\end{table}
\end{document}