Compare these two:


\unit{0.01 kilogram}
$ \unit{0.01 kilogram} $


I would naively expect these to produce very similar results, but the latter case—the one in math mode—we get an obnoxious looking space between the decimal point and the first 0. Observe:

enter image description here

What am I misunderstanding or doing wrong?

2 Answers 2


(I'm making this a separate answer because I think "it was broken, and this is how" and "it works now, and this is how" are conceptually different answers. Also because changing the answer would make the comments under it look odd.)

Your problem was actually a problem with the beta; this is fixed in the current Mark IV beta (2012.12.03 11:33). There are now three options to \setupmathematics[autopunctuation=...]:

  • autopunctuation=no — default TeX behaviour. Commas get a thin space, periods get nothing.
  • autopunctuation=yes — manual control for commas. Commas followed by a space get a thin space; periods, and commas followed by something else, do not.
  • autopunctuation=all — like yes, but the same behaviour for periods.

As for \unit{2.5} or \unit{2,5}: neither decimal marks nor digit separators get any unwanted spaces after them, no matter which one is the comma and which one the period. So that works all right again, as it did before the beta briefly broke.

Code illustrating the behaviour. The 'desired' column uses full spaces out of laziness.




\NC input  \NC desired \NC output  \NC \NR
\NC 2,5  \NC 2, 5 \NC $2,5$  \NC \NR
\NC 2, 5 \NC 2, 5 \NC $2, 5$ \NC \NR
\NC 2.5  \NC 2.5  \NC $2.5$  \NC \NR
\NC 2. 5 \NC 2.5  \NC $2. 5$ \NC \NR



\NC input  \NC desired \NC output  \NC \NR
\NC 2,5  \NC 2,5  \NC $2,5$  \NC \NR
\NC 2, 5 \NC 2, 5 \NC $2, 5$ \NC \NR
\NC 2.5  \NC 2.5  \NC $2.5$  \NC \NR
\NC 2. 5 \NC 2.5  \NC $2.5$  \NC \NR



\NC input  \NC desired \NC output  \NC \NR
\NC 2,5  \NC 2,5  \NC $2,5$  \NC \NR
\NC 2, 5 \NC 2, 5 \NC $2, 5$ \NC \NR
\NC 2.5  \NC 2.5  \NC $2.5$  \NC \NR
\NC 2. 5 \NC 2. 5 \NC $2. 5$ \NC \NR


Here's the results --- the image quality is not the best, but the (thin) spaces should still be visible.

behavior of autopunctuation settings for commas and periods with and without spaces

For completeness: the behaviour under Mark II.

  • Spaces are ignored.

  • Without \enablemathpunctuation (there is no \disablemathpunctuation):

    % default TeX behaviour
    2.5 or 2. 5 --> 2.5
    2,5 --> 2, 5
  • With \enablemathpunctuation:

    2.5 --> 2.5
    2,5 --> 2,5
  • My pleasure. Perhaps you could change the accepted answer to this one, as this one most accurately reflects the current state of affairs?
    – Esteis
    Dec 3, 2012 at 23:33
  • Sure--I didn't realize I had that power. Dec 3, 2012 at 23:44

This is because autopunctuation is currently buggy. See also autopunctuation not working properly. The only difference between the questions is the symptom you describe. You are asking why math punctuation looks bad by default (i.e. when autopunctuation=no); mbork is asking why autopunctuation=yes does not do what he expects.

% this example uses \m{...} rather than $...$, 
% the result is identical, but \m{...} is preferred
\m{(2,5)} versus \m{(2, 5)} -- no, default
\m{(2.5)} versus \m{(2. 5)} -- no, default

\m{(2,5)} versus \m{(2, 5)} -- yes
\m{(2.5)} versus \m{(2. 5)} -- yes

show that autopunction=no leads to space after comma

To quote Aditya in the recent mailing list thread "A problem with autopunctuation":

[I would expect] autopunctuation [to behave] this: if comma is followed by a non-space, the comma should behave like an "ord"; if it is followed by a space, it should behave like a "punctuation". Clearly that is not happening.

That thread took place back at the start of this month, but the issue is still present in today's beta. I'll revive the issue in the mailing list.

  • 1
    This is a well known problem when the comma is used as a decimal separator as well as punctuation. My opinion is that no automatic setup can safely guard the user against this. The safest way out, I believe, is to properly segregate decimal numbers into the argument of a macro.
    – egreg
    Nov 30, 2012 at 12:12
  • One more question then: it seems the \unit command circumvents the \setupmathematics[autopunctuation=yes] option. Is there a way I can make this look right? Nov 30, 2012 at 14:25
  • @DanielLyons As far as I know, the \unit command obeys the \setupmathematics[autopunctuation=yes] setup; whether that setup does something sensible at the moment is a separate matter, but $0.01$ and $\unit{0.01 kg}$ should give identical results. (Footnote: any autopunctuation rules operate on what \unit{...} outputs, actually.) Hans is currently working on fixing the autopunctuation behaviour.
    – Esteis
    Dec 2, 2012 at 0:48
  • Thanks—I solved my problem by moving the value outside the unit: changing \unit{9.8 cm} into 9.8 \unit{cm}. Dec 2, 2012 at 7:07

You must log in to answer this question.

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