2

This question includes a solution but I really want to know why it works and why what "should" work doesn't I think my MWE says is all:

\documentclass[12pt]{article}
\usepackage{siunitx}
% TeX Live 2015 (Ubuntu 18.04)
% siunitx Ver 2.6m
\sisetup{
group-digits=integer,
group-minimum-digits={3},
group-separator={,} % NOT "\,"
}

\begin{document}

After  looking at a number of examples (and the
documentation) I could not got what I wanted
(3,000). If group-separator is set to \verb:{\,}: 
the thousands separator is a space. But if set to
"," it works.

\begin{tabular}{ccc}
Code in document    &              & Typeset as\\
\hline
\verb:\num{3000}:    &  \num{3000}  & 3,000\\
\verb:$\num{3000}$:  & $\num{3000}$ & 3,000\\
\verb:\num{$3000$}:  & does not work\\
\end{tabular}
\end{document}
4
  • 1
    \, is a thin space in LaTeX, if you use it, you get a space, not a comma. What's the problem with using the comma directly?
    – gusbrs
    Commented Dec 10, 2018 at 23:36
  • 3
    With group-separator={,} you get a comma; with group-separator={\,} you get \,, which is a thin space.
    – egreg
    Commented Dec 10, 2018 at 23:36
  • I don't really understand the issue? Is it that you tried group-seperator=, and group-separator={,} and it only worked with the latter? Since group-separator=\, also worked, but didn't show a , (because \, is a thin space)...?
    – Werner
    Commented Dec 10, 2018 at 23:54
  • Thanks all. Is it allowed to make the admission that I had turned off the brain-box? I thought I had looked at examples which asked to put "," as the thousands separator, and thought they all used "\,". Oh well problem solved. Commented Dec 11, 2018 at 15:13

1 Answer 1

6

The token \, is not an “escaped comma”, but a command on its own, which means “insert a thin space (one sixth of an em). With

group-separator={whatever}

the separation between groups is set to whatever. Thus with

group-separator={,}

you'll get a comma, but with

group-separator={\,}

you'll get a thin space.

The braces are only mandatory with the comma, otherwise the option parser would get confused.

You must log in to answer this question.

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