siunitx 中带括号数字的表格

siunitx 中带括号数字的表格

我想使用siunitx包来格式化下表:

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}

\begin{table}
\centering
\begin{tabular}{S[table-format=3.0]ccc} \\
\toprule
$n$ & A & $\alpha_0$ & $\beta_0$ \\
\midrule
100 & ML & 3.1525(0.3580) & 0.4773(0.1209) \\
200 & YW & 3.1866(0.3272) & 0.4593(0.1075) \\
300 & ML & 3.1540(0.2660) & 0.4834(0.0858) \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

关键的是第 3 列和第 4 列,格式为 X.XXXX(Y.YYYY)。有什么建议可以正确格式化这些列吗?

答案1

就我的情况而言,它们已经是了。那么,当您的代码失败时,您能发布另一个示例吗?

为了提供一点帮助,我修改了您的代码,以便在第 3 列和第 4 列中显示不确定的数字。我不知道您在第 2 列中的内容是什么,如果它们是 si 单位,您也可以明确说明。

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{table}
\centering
\begin{tabular}{S[table-format=3.0]cS[table-format=1.4(5)]S[table-format=1.4(5)]} \\
\toprule
{$n$} & A & {$\alpha_0$} & {$\beta_0$} \\
\midrule
100 & ML & 3.1525 \pm 0.3580 & 0.4773 \pm 0.1209 \\
200 & YW & 3.1866 \pm 0.3272 & 0.4593 \pm 0.1075 \\
300 & ML & 3.1540 \pm 0.2660 & 0.4834 \pm 0.0858 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

示例_默认

如果需要,您可以修改不确定性的显示方式。我个人不喜欢默认样式,但我不知道您的品味。

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{separate-uncertainty = true}

\begin{document}
\begin{table}
\centering
\begin{tabular}{S[table-format=3.0]cS[table-format=1.4(5)]S[table-format=1.4(5)]} \\
\toprule
{$n$} & A & {$\alpha_0$} & {$\beta_0$} \\
\midrule
100 & ML & 3.1525 \pm 0.3580 & 0.4773 \pm 0.1209 \\
200 & YW & 3.1866 \pm 0.3272 & 0.4593 \pm 0.1075 \\
300 & ML & 3.1540 \pm 0.2660 & 0.4834 \pm 0.0858 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

例如_separate_unc

答案2

另一种方法是利用所有siunitx功能:

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{table}[htb]   % standard record of uncertainty
\centering
\begin{tabular}{S[table-format=3.0]
                c
           *{2}{S[table-format=1.4(4)]}
                }
\toprule
{$n$} & A & {$\alpha_0$} & {$\beta_0$} \\
\midrule
100 & ML & 3.1525(3580) & 0.4773(1209) \\
200 & YW & 3.1866(3272) & 0.4593(1075) \\
300 & ML & 3.1540(2660) & 0.4834(0858) \\
\bottomrule
\end{tabular}
\end{table}

\begin{table}[htb]   % separate record of uncertainty
\sisetup{separate-uncertainty} % <---
\centering
\begin{tabular}{S[table-format=3.0]
                c
           *{2}{S[table-format=1.4(4)]}
                }
\toprule
{$n$} & A & {$\alpha_0$} & {$\beta_0$} \\
\midrule
100 & ML & 3.1525(3580) & 0.4773(1209) \\
200 & YW & 3.1866(3272) & 0.4593(1075) \\
300 & ML & 3.1540(2660) & 0.4834(0858) \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

在此处输入图片描述

相关内容