Formatting numerical data

When formatting numerical data, should it be:

$15~\mathrm{kg}$

$15~\mathrm{kg}$

or

15 $\mathrm{kg}$

15 $\mathrm{kg}$

For the sake of consistency, I strongly feel that it should be one or the other, but not both (but in the end I guess it's not my choice to make).

• The first one is the better one in my opinion, in the other one the unit might break the line. May 4, 2015 at 4:48
• I'm unclear on why 15 kg, without unnecessary formatting, is not the preferred choice. I personally find the oversized, arbitrarily bolded text difficult to read. May 11, 2015 at 23:58
– A.K.
Apr 6, 2019 at 1:31

I agree with the comments of Martin and Molx on that the fonts of the value and the unit should match.

If one takes a closer look at the output of expressions using the siunitx package, which isn't available here, one realizes that the gap between the number and the unit is smaller than a standard (protected) space.

The optical equivalent to

\SI[group-digits=false]{8.3146621}{\joule\per\mol\per\kelvin} in MathJax is $8.3146621\,\mathrm{J\,mol^{-1}\,K{^{-1}}}$, and yields

$8.3146621\,\mathrm{J\,mol^{-1}\,K{^{-1}}}$

• May I still use the protected space please? Since the siunitx package is far from being implemented, I find it much easier to just type the tilde. I also like it, when it harmonises with this discussion. May 5, 2015 at 8:59
• What's the difference between $8.1\ \mathrm{g}$, $8.1~\mathrm{g}$ and $8.1\, \mathrm{g}$? The first two seem to yield identical results, while the third gives a smaller space. Does it have to do with being protected? What is that, by the way?
– Molx
May 8, 2015 at 17:20
• @Molx You're right! \, does yield a smaller space, \~ gives a space at which no line break can happen. That's called a protected space. May 8, 2015 at 17:27
• @Martin Yes, please :-) I'm not planning to to go on an edit spree to convert spaces in MathJax expressions with a script ;-) Having siunitx would nice, but since it isn't available, we live with what we have. And actually, that is already quite a lot, as compared to other sites. May 8, 2015 at 17:35