
如何根據 \pm 而不是根據點對齊數字?每行也應該有不同的小數位數。
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\begin{table}
\caption{}
\centering
\small
\sisetup{separate-uncertainty}
\begin{tabular}{lS[table-format = 5.4(1)]}
\hline\hline\noalign{\smallskip}
Parameter & Value \\
\noalign{\smallskip}\hline\noalign{\smallskip}
A & 26.5 \pm 2.0 \\
B & 11.102 \pm 1.2 \\
C & 53839 \pm 550 \\
D & 0.5863 \pm 0.016 \\
\noalign{\smallskip}\hline\noalign{\smallskip}
\end{tabular}
\end{table}
\end{document}
答案1
作為這個答案建議,S
套件提供的列siunitx
僅附帶某些對齊功能,主要將數字調整為小數點分隔符,這不是您想要的。
因此,我建議您調整上面連結的好答案,並在不使用該siunitx
包的情況下手動進行對齊。由於我不知道您希望如何對齊標誌後面的數字\pm
,因此我提供了以下兩種替代解決方案。我還建議看看包裝booktabs
:
\documentclass{article}
%\usepackage{siunitx}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ l r @{\,\( \pm \)\,} r }
\toprule
{Parameter} & \multicolumn{2}{c}{Value} \\
\midrule
A & 26.5 & 2.0 \\
B & 11.102 & 1.2 \\
C & 53839 & 550 \\
D & 0.5863 & 0.016 \\
\bottomrule
\end{tabular}
\bigskip
\begin{tabular}{ l r @{\,\( \pm \)\,} l }
\toprule
{Parameter} & \multicolumn{2}{c}{Value} \\
\midrule
A & 26.5 & 2.0 \\
B & 11.102 & 1.2 \\
C & 53839 & 550 \\
D & 0.5863 & 0.016 \\
\bottomrule
\end{tabular}
\end{document}
答案2
我不知道是否siunitx
實現了任何將數字集中在不確定性標記周圍的功能。也許有,但我不知道。我能想到的唯一解決方法是將數字分成兩列以獲得效果。您仍然可以使用siunitx
將數字四捨五入到一些小數位。除此之外,siunitx
不需要
\documentclass{article}
\usepackage{siunitx}
\newcommand\ustrut{\rule{0pt}{12pt}}
\newcommand\lstrut{\rule[-6pt]{0pt}{12pt}}
\begin{document}
\begin{table}
\sisetup{
round-mode=figures,
round-precision=3,
table-alignment-mode=none,
separate-uncertainty,
}
\caption{}
\centering
\small
\begin{tabular}{
l
S[table-number-alignment=right]
@{\(\;\pm\;\)}
S[table-number-alignment=left]
}
\hline\hline
\ustrut Parameter & \multicolumn{2}{c}{Value\lstrut}\\
\hline\ustrut
A & 26.5 & 2.0 \\
B & 11.102 & 1.2 \\
C & 53839 & 550 \\
D & 0.5863 & 0.016 \lstrut \\
\hline
\end{tabular}
\end{table}
\end{document}