30

I'm writing a paper and my advisor is requiring that all large numbers have a comma as a thousands separator. I've read this question which asks about how to make siunitx not throw errors when there is a comma in the input, but how can I force a comma in the output when using \SI?

Ideally it would only do it for numbers with more than 4 digits -- ie. \SI{9000} would not contain a space or comma but \SI{10000} would be 10,000. But if that's not possible, I'd settle for 9,000 also.

3
  • Your advisor is wrong. The only acceptable separator for thousands is a thin space, both for the ISO and good typography.
    – egreg
    Commented Sep 18, 2013 at 20:25
  • 2
    @egreg I would agree completely if he didn't sign the paychecks and hold this paper not being done over my head as a reason for delaying my thesis proposal. Graduating >> commas.
    – tpg2114
    Commented Sep 18, 2013 at 20:27
  • I sympathize with you. After all, getting the right typesetting is just commenting one line in the source file. ;-)
    – egreg
    Commented Sep 18, 2013 at 20:28

2 Answers 2

37

This is described in section 5.6 Printing numbers of the manual (for v. 2.5s, dated 2013/07/31). The group-separator key defines the separator between groups of digits. By default grouping is not applied for numbers with four digits (e.g. 9000), so there's no need to do anything for that. (This can be changed with group-minimum-digits, which defines how many digits must be present for grouping to apply.)

enter image description here

\documentclass[12pt]{article}
\usepackage{siunitx}
\sisetup{group-separator = {,}}
\begin{document}
\SI{9000}{\m}

\SI{90000}{\m}

\end{document}
6
  • 1
    So I had tried what I assumed was equivalent with \sisetup{group-separator = {\,}, but apparently \, does not behave the same as just ,
    – tpg2114
    Commented Sep 18, 2013 at 20:23
  • 2
    @tpg2114 No, \, is a thin space. Commented Sep 18, 2013 at 20:24
  • Lots of time wasted... sigh. Thanks for the solution!
    – tpg2114
    Commented Sep 18, 2013 at 20:25
  • 4
    The key group-minimum-digits=5 is not necessary here because it is set by default. The grouping of four digits can explicitly be set by group-four-digits. Commented Sep 18, 2013 at 20:25
  • @ThorstenDonig Oops, you're right, seems I should read the manual more thoroughly ... Thanks! Commented Sep 18, 2013 at 20:26
0

The thin space for group separator can be achieved by using \text{}, thus circumventing the build-in removal of spaces in the \num{} handler.

\documentclass[12pt]{article}
\usepackage{siunitx}
\sisetup{group-separator = \text{\,}}
\begin{document}
\SI{9000}{\m}

\SI{90000}{\m}

\end{document}
2
  • 3
    Welcome to TeX.SX! In the comments, the poster specifically says that this is not what is wanted. In any case, the thin space is what siunitx provides by default here, see page 27 of the manual. Commented Feb 6, 2015 at 13:27
  • Spaces are stripped out of input on parsing: what happens when formatting is a separate step.
    – Joseph Wright
    Commented Feb 6, 2015 at 14:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .