2

I am trying to round numbers in the following table.

\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}

However, if I do the following revision by replacing c with S[round-precision=2], latex compiler reports error and subscripts of theta will be lost.

\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}

I also want to avoid changing the decimal places for each number. any suggestions?

1 Answer 1

1

Try the following:

\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}

enter image description here

1
  • It worked very well and out of the box. Simpler than using the package numprint as explained in this answer. This solution only touches the preamble to declare the package import and in the column heading without upsetting the original alignment. Commented May 21, 2020 at 0:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .