![如何添加零以达到表格中小数点后的位数相同?](https://linux22.com/image/394008/%E5%A6%82%E4%BD%95%E6%B7%BB%E5%8A%A0%E9%9B%B6%E4%BB%A5%E8%BE%BE%E5%88%B0%E8%A1%A8%E6%A0%BC%E4%B8%AD%E5%B0%8F%E6%95%B0%E7%82%B9%E5%90%8E%E7%9A%84%E4%BD%8D%E6%95%B0%E7%9B%B8%E5%90%8C%EF%BC%9F.png)
\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}