28

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.

tpg2114
  • 1,403
  • Your advisor is wrong. The only acceptable separator for thousands is a thin space, both for the ISO and good typography. – egreg Sep 18 '13 at 20:25
  • 1
    @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 Sep 18 '13 at 20:27
  • I sympathize with you. After all, getting the right typesetting is just commenting one line in the source file. ;-) – egreg Sep 18 '13 at 20:28

2 Answers2

34

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}
Torbjørn T.
  • 206,688
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}
  • 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. – Andrew Swann Feb 06 '15 at 13:27
  • Spaces are stripped out of input on parsing: what happens when formatting is a separate step. – Joseph Wright Feb 06 '15 at 14:34