8

I used to format number grouping with a protected space (~). Now I'm switching to siunitx's \num. According to the package documentation ...

The formatter removes ‘hard’ spaces (\, and ~)

but when I surround my numbers with \num it produces the following error output

! siunitx error: "invalid-token-in-number"
! Invalid token '\protect ' in numerical input.

l.5 \num{60~000}

| Numbers can only contain tokens defined using the 'input-...' options:
| the token '\protect ' is not set up as a valid part of a number.

I tried to include \protect to the input-ignore option but it just changes the invalid token in the error message to \unhbox and \voidb.

Here is a MWE (Miktex v2.9 and siunitx v2.5s):

\documentclass{article}
\usepackage{siunitx}
%\sisetup{input-ignore={\protect }}
\begin{document}
\num{60~000}
\end{document}

Of course, one could just remove the tilde character in each number but how would I include it into the ignored input tokens? Do I misinterpret the package documentation?

1 Answer 1

13

That's a mistake in the documentation: currently the standard settings ignore \, but not ~. I'll fix that in a maintenance release: for the moment use

\documentclass{article}
\usepackage{siunitx}
\sisetup{input-ignore=~,
  input-protect-tokens = ~\approx\dots\ge\geq\gg\le\leq\ll\mp\pi\pm\sim}
\begin{document}
\num{60\,000}
\end{document}
4
  • 1
    Logged as github.com/josephwright/siunitx/issues/256 and likely to be actioned by the weekend. I've got a few minor issues to address, one of which means I'll have to bump the version to 2.6. Bother me if CTAN is not updated by Monday!
    – Joseph Wright
    Sep 3, 2014 at 9:26
  • 1
    It's amazing to have such people one the site!
    – clabacchio
    Sep 3, 2014 at 14:47
  • A proper fix has now gone to CTAN: should be with users of TeX Live/MiKTeX within a few days.
    – Joseph Wright
    Sep 5, 2014 at 8:17
  • @JosephWright updated my library today. Works like a charm and makes the workaround unnecessary :)
    – Harald
    Sep 11, 2014 at 14:24

You must log in to answer this question.

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