我正在尝试对下表中的数字进行四舍五入。
\begin{table}[H]
\centering
\begin{tabular} {c| cccc}
T(sample size) & $\theta_0$ & $\theta_1$ & $\theta_2$ & $\theta_3$ \\ \hline
200&-0.081295&-0.090014&-0.089029&0.010305\\\hline
500&-0.05266&-0.037185&-0.03383&-0.001537\\\hline
\end{tabular}
\caption{I.I.D. contexts: bias in estimating the optimal policy parameter. Bias=$\mathbb{E}(\hat{\theta}_t)-\theta^*$. }
\label{iid_b}
\end{table}
但是,如果我进行以下修改,将 c 替换为 S[round-precision=2],latex 编译器会报告错误,并且 theta 的下标将丢失。
\begin{table}[H]
\centering
\begin{tabular} {c| S[round-precision=2]S[round-precision=2]S[round-precision=2]S[round-precision=2]}
T(sample size) & $\theta_0$ & $\theta_1$ & $\theta_2$ & $\theta_3$ \\ \hline
200&-0.081295&-0.090014&-0.089029&0.010305\\\hline
500&-0.05266&-0.037185&-0.03383&-0.001537\\\hline
\end{tabular}
\caption{I.I.D. contexts: bias in estimating the optimal policy parameter. Bias=$\mathbb{E}(\hat{\theta}_t)-\theta^*$. }
\label{iid_b}
\end{table}
我还想避免更改每个数字的小数位。有什么建议吗?
答案1
请尝试以下操作:
\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{siunitx}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{c|
*{4}{S[table-auto-round,
table-format=-1.2]}
}
T(sample size) & {$\theta_0$} &{$\theta_1$} & {$\theta_2$} & {$\theta_3$}\\\hline
200 & -0.081295 & -0.090014 & -0.089029 & 0.010305 \\\hline
500 & -0.05266 & -0.037185 & -0.03383 & -0.001537 \\\hline
\end{tabular}
\caption{I.I.D. contexts: bias in estimating the optimal policy parameter. Bias=$\mathbb{E}(\hat{\theta}_t)-\theta^*$. }
\label{iid_b}
\end{table}
\end{document}