Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.)

share|improve this question

1 Answer 1

up vote 14 down vote accepted

You can tell siunitx to ignore certain characters by using input-ignore={<list of characters>}. However, since the comma is by default one of the decimal separators siunitx looks for, just adding , to the input-ignore list won't work: You also have to tell siunitx that only periods are decimal markers, using input-decimal-markers={.} (by default it is set to {,.}):

\documentclass{article}
\usepackage{siunitx}
\sisetup{input-ignore={,},input-decimal-markers={.}}
\begin{document}
\num{300,000.12}
\end{document}

share|improve this answer
1  
Adding back in group-separator={,} keeps the comma in the output. Thanks! (I think this should be default behaviour for the package: to consider comma as a thousands separator in the input to keep consistent with the output.) –  badroit Apr 11 '12 at 18:32
4  
@badroit You are mistaking setting the output group separator for 'keeping' the material you have in the input. The siunitx package parses your input, then typesets it according to the current settings. The standard settings use a thin space as a group separator as this is recommended by a number of authorities. –  Joseph Wright Apr 11 '12 at 18:40
2  
@Joseph, understood. This is also be a good opportunity to say thanks for a great package! –  badroit Apr 11 '12 at 19:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.