如何添加零以达到表格中小数点后的位数相同?

如何添加零以达到表格中小数点后的位数相同?
\documentclass{article}
\usepackage[locale=FR]{siunitx}
\usepackage{booktabs}
\usepackage{geometry}
\begin{document}
\begin{table}
    \centering
    \begin{tabular}{lS[table-format=4.6]S[table-format=2.3]}
    \toprule
        {A} & B & C\\
    \midrule
        a &1231,1231 & 1,12\\
        b & 1254,121231 & 1,7\\
    \bottomrule
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\end{document}

答案1

使用table-auto-round选项:

在此处输入图片描述

\documentclass{article}
\usepackage[locale=FR]{siunitx}
\usepackage{booktabs}
\usepackage{geometry}
\begin{document}
\begin{table}
    \centering
    \begin{tabular}{
      l
      S[table-format=4.6,table-auto-round]
      S[table-format=2.3,table-auto-round]
    }
    \toprule
        {A} & B & C\\
    \midrule
        a & 1231,1231   & 1,12 \\
        b & 1254,121231 & 1,7  \\
    \bottomrule
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\end{document}

相关内容