Recently I found the very useful siunitx
package, and immediately looked to use it for some tables. Unfortunately, I already have all my numbers typeset with ,
thousand separator and .
decimal separator.
If I try something like:
\documentclass{standalone}
\usepackage[group-separator={,}]{siunitx}
\begin{document}
\begin{tabular}{S[table-format=6.2]}
300,000.12\\
\end{tabular}
\end{document}
I get errors like:
Duplicate decimal marker '.' in input.
If I replace 300,000.12
with 300,000
it considers it as the 300.000
(i.e., 300
).
This seems strange to me as the package interprets 300000
as 300,000
but it interprets 300,000
as 300.000
.
I've scanned through the detailed siunitx
documentation, but could not find any flags for picking up input separators. Anyone know how siunitx
can be parameterised to treat raw input numbers like 300,000.12 gracefully?
(I would rather not remove all commas from all input numbers.)
Best Answer
You can tell
siunitx
to ignore certain characters by usinginput-ignore={<list of characters>}
. However, since the comma is by default one of the decimal separatorssiunitx
looks for, just adding,
to theinput-ignore
list won't work: You also have to tellsiunitx
that only periods are decimal markers, usinginput-decimal-markers={.}
(by default it is set to{,.}
):