In this table with some big numbers the column headers centered over the decimal point look odd to me. And, too, the columns seem a little too wide.
I've puttered a bit with other answers here and package documentation to little effect. Maybe I haven't looked hard enough – so am asking for help.
Here's the MWE:
\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{input-ignore={,},input-decimal-markers={.},group-separator={,}}
\begin{document}
\begin{tabular}{lSSS}
\toprule
& & & \multicolumn{1}{c}{Natural} \\
Time unit & \multicolumn{1}{c}{Births} & \multicolumn{1}{c}{Deaths} & \multicolumn{1}{c}{increase} \\
\midrule
Year & 134,176,254 & 56,605,700 & 77,570,553 \\
Month & 11,181,355 & 4,717,142 & 6,464,213 \\
Day & 367,606 & 155,084 & 212,522 \\
Minute& 255 & 108 & 148 \\
Second& 4.3 & 1.8 & 2.5 \\
\bottomrule
\end{tabular}
\end{document}
Best Answer
You need to tell
siunitx
how many digits are to the left and right of the decimal separator (alignment point). The keytable-format
does the trick.Note also that here, a brace group is sufficient to escape the header text. The
\multicolumn
solution is only required in special cases.The setting
table-format=9.1
indicates that there are 9 digits before the alignment point and 1 digit after it. Similar for the other columns. I've also used*<num>{<col-spec>}
notation for repeated common columns to reduce repetition.