在每列中有多个条目的表格中对数字进行舍入

在每列中有多个条目的表格中对数字进行舍入

我正在尝试制作一个包含估计值和置信区间的表格,并且还需要对这些数字进行四舍五入。我使用的代码是

\documentclass{amsart}
\usepackage{amsmath,float,tabularx,booktabs}
\usepackage{caption,numprint}
\begin{table}
\caption{Confidence intervals for each element of the parameter for two samples of size $n=20$ and $n=40$}
\npdecimalsign{.}
\nprounddigits{2}
\begin{tabular}{ | c | n{6}{2} n{6}{2} n{6}{2} | n{6}{2} n{6}{2} n{6}{2}| }
\hline
    terms & {$n=20$}  & {$n=40$}   \\ \hline
{coefficient} & {estimates ( Confidence Interval)}  & {estimates ( Confidence Interval) }  \\ \hline
        $b_{01}$ & 51.167165599999997  11.211644590000001   89.311036540000003  & 55.919065670000002  11.329871410000001  112.66300579999999  \\ \hline
    $b_{01}$ & 14.0436242 & \( -0.45313055000000002 & , 48.954697320000001\) & 27.83246059 & \( -19.193054709999998 & , 69.574692159999998\) \\ \hline
\end{tabular}
\npnoround
\end{table}
\end{document}

如何指定置信区间的舍入?

答案1

我猜你想要这样的东西:

\documentclass{amsart}
\usepackage{amsmath,booktabs,siunitx}

\begin{document}

\begin{table}
\caption{Confidence intervals for each element of the parameter 
  for two samples of size $n=20$ and $n=40$}

\sisetup{round-mode=places,round-precision=2}
\newcommand{\lp}{(}\newcommand{\rp}{)}
\begin{tabular}{
  @{}
  l
  S[table-format=2.2]
  >{\lp}S[table-format=-1.2,table-space-text-pre=\lp]
  @{$,{}$}
  S[table-format=2.2,table-space-text-post=\rp]<{\rp}
  S[table-format=2.2]
  >{\lp}S[table-format=-2.2,table-space-text-pre=\lp]
  @{$,{}$}
  S[table-format=3.2,table-space-text-post=\rp]<{\rp}
  @{}l@{}
}
\toprule
terms & \multicolumn{3}{c}{$n=20$}  & \multicolumn{3}{c}{$n=40$}   \\
\midrule
coefficient & {estimates} & \multicolumn{2}{c}{(CI)}  &
              {estimates} & \multicolumn{2}{c}{(CI)}  \\
\cmidrule(r){1-1}\cmidrule(lr){2-4}\cmidrule(l){5-7}
$b_{01}$ & 51.167165599999997 & 11.211644590000001   & 89.311036540000003 & 
  55.919065670000002 &  11.329871410000001 & 112.66300579999999 &\\
$b_{01}$ & 14.0436242         & -0.45313055000000002 & 48.954697320000001 &
  27.83246059        & -19.193054709999998 & 69.574692159999998 &\\
\bottomrule
\end{tabular}

\end{table}
\end{document}

在此处输入图片描述

最后一l@{}列和&\\数字行是为了解决中的一个小错误所必需的siunitx

完整拼写“置信区间”是行不通的,除非进行进一步的破解。

相关内容