6
$\begingroup$

https://worldbuilding.stackexchange.com/a/31762/885

So what's the right way to put units inside of TeX blocks? I remember a font directive but not what the word was. And it's a kludge anyway — was a proper unit macro notation ever added?

$\endgroup$
0
2
$\begingroup$

Use \text{}.

This MathJaX code:

1 \times 10^{23} kg

produces this output:

$ 1 \times 10^{23} kg $

By wrapping the kg in \text{ }, we get:

1 \times 10^{23} \text{ kg}

which produces

$ 1 \times 10^{23} \text{ kg} $

$\endgroup$
4
  • $\begingroup$ So what's the difference between mathrm and text? The latter might have a better chance of being remembered anyway. $\endgroup$ – JDługosz Jan 4 '16 at 5:50
  • $\begingroup$ @JDługosz the only difference I've found is that mathrm strips spaces, text doesn't. $\endgroup$ – ArtOfCode Jan 4 '16 at 7:46
  • $\begingroup$ So the tilde on the outside lets $\TeX$ decide the right amount of space, while a space inside of text forces it to be an actual space character in that font. $\endgroup$ – JDługosz Jan 4 '16 at 12:50
  • 1
    $\begingroup$ You can also use something like 1 \times 10^{23} ~ \text{kg}: $ 1 \times 10^{23} ~ \text{kg} $ $\endgroup$ – user Jan 4 '16 at 15:30

You must log in to answer this question.

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