# Preserving thousands separator with siunitx

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.

• 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
• @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

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

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

\SI{90000}{\m}

\end{document}

• So I had tried what I assumed was equivalent with \sisetup{group-separator = {\,}, but apparently \, does not behave the same as just , – tpg2114 Sep 18 '13 at 20:23
• @tpg2114 No, \, is a thin space. – Torbjørn T. Sep 18 '13 at 20:24
• Lots of time wasted... sigh. Thanks for the solution! – tpg2114 Sep 18 '13 at 20:25
• 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. – Thorsten Donig Sep 18 '13 at 20:25
• @ThorstenDonig Oops, you're right, seems I should read the manual more thoroughly ... Thanks! – Torbjørn T. Sep 18 '13 at 20:26

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}

• 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 6 '15 at 13:27
• Spaces are stripped out of input on parsing: what happens when formatting is a separate step. – Joseph Wright Feb 6 '15 at 14:34