One large number in table with decimals

I am using siunitx to align numbers in a column. Problem is I got by intention one row at the beginning which is a large number, indicated by ',' per 1,000. See the following example.

What I would like to achieve:

1) Align the decimals to the decimal point '.' This is row 2, 3 and 4.

2) center the big numbers, i.e. row 1 and 5 in this example. When I tested different options, the large numbers where always either too much to the left or too much to the right. If possible, they should simply be centered. I believe that makes the most sense in terms of formatting.

Is it possible?

\documentclass{article}
\usepackage{siunitx}

\sisetup{%
input-ignore={,},
input-decimal-markers = {.},
table-format = 2.2,
table-number-alignment = center,
}%

\begin{document}
\begin{tabular}{SS}
row & alignToDec \\
row1: & 19,000,000.0 \\
row2: & 12.38 \\
row3: & 1.97  \\
row4: & 91.01  \\
row5: & 87,000,000.0 \\
\end{tabular}
\end{document}

• Try adding a pair of braces around the large numbers. – Bernard Mar 8 '19 at 21:51
• @Bernard what do you mean precisely? I could add braces (could it be anything else but braces?), but I am not sure on the exact consequence of doing that. If I added them only on the left, what would happen? Pls elaborate a bit. – ghx Mar 8 '19 at 21:55
• Apart from your question: Do not use S type columns for columns that only contain text (first column in your example code) and as already suggested by Bernard, enclose text in S type columns (first row in your code) as well as entries that should be centered in a pair of {}. – leandriis Mar 8 '19 at 21:55
• Thanks that works! Does that just generally mean those numbers are ignored? – ghx Mar 8 '19 at 21:59
• Yes: cell content between braces in an Scolumn is considered by siunitx as non-numeric content and centred. – Bernard Mar 8 '19 at 22:42

For some reason your code compiles, but:

1) You should not (at least you have no reason to do that) use an S column type for columns that doesn't contain math.

2) If the contents of a cell inside an 'S' column is text place it inside curly braces. (This way the content will be centered by default from siunitx because it will be considered as a text). [See your "broken" alignToDec in the second column if outside of braces and place it inside braces to see the difference]

3) Use the same method as above for your big numbers...

4) You could specify the table-format as an optional argument in your S columns. (siunitx behaves better like this in general)

\documentclass{article}
\usepackage{siunitx}

\sisetup{%
input-ignore={,},
input-decimal-markers = {.},
table-number-alignment = center,
}%

\begin{document}
\begin{tabular}{cS[table-format=2.2]}
row & {alignToDec} \\
row1: & {19,000,000.0} \\
row2: & 12.38 \\
row3: & 1.97  \\
row4: & 91.01  \\
row5: & {87,000,000.0} \\
\end{tabular}
\end{document}


PS: Remove the luatex tag.

• thanks a lot! My code always compiles ;) – ghx Mar 8 '19 at 22:02
• Welcome... For me, rarely it compiles by the first try when using siunitx... (but usually my tables are somehow ... somehow)... Anyway... I tried to say that usually siunitx doesn't like text when is waiting for numbers and doesn't compile without errors. Happy TeXing – koleygr Mar 8 '19 at 22:05
• No offense taken. Have a great day and thx for your reply. – ghx Mar 8 '19 at 22:06