# Get your units right with LaTeX

The LaTeX package SIunits (which seems to be a descendant from the units package that I once used) addresses one of the most nagging issues in physics and engineering: getting the units well typeset. While the source is a bit cumbersome, it is quite readable:

\$R=8.314\$ \joule\per(\mole\usk\kelvin)

There are prefixes, so that “\mega\ohm” is ok. Many ready-to-use units are predefined, such as \kilogrammetrepersecond for your momentum, or\kilogrammetrepersecondnp if you prefer negative powers instead of division.

As a bonus, \celsius adds the little “degree” symbol that’s so easy to get wrong, and \kelvin does not, as it should be:

\$0\$\celsius=\$273.15\$ \kelvin.

Also, units maybe inside formulae or outside:

\$9.81 \newton\$ or\$9.81\$\newton

The space in the first equation is ignored, btw, so both produce the same output. This space, is moreover, one of the few things left to the author:

\$9.81\$ \newton or\$9.81\$\newton ???

It seems the first one is correct, but one may use this to get things always right:

\unit{120}{\kilo\meter\per\hour}

This later choice is a bit more cumbersome, but convenient: math mode is invoked, no need to use \$\$; also, no need to remember the extra \  at the end of the command: “a force of \$1\$ \newton\ is required \ldots”.

## 6 thoughts on “Get your units right with LaTeX”

1. I appreciate this post. Is there a similar solution for those of us who are stuck using both English and SI units?

• Both English and SI units? I am not sure I understand: the package should be as international as the SI system. In fact, the name of some units is translated in Spanish (“Julio” for Joule), but never the symbol. Another difference is that \$1.1\$ ends out having a comma (1,1) in the output, when using the babel package (but that’s correct in Spanish).

2. The package siunitx is even newer, it provides new features but also backward-compatibility with SIunits, units and related packages.

3. Hi, Danny,

I didn’t know you had a blog! Nice work! I just came across this because I have the same problem as Oscar above. Those of us who live in barbaric countries have to sometimes use (the horrors) both SI and imperial units in the same document, for example when writing some exercises for our students, as I am doing right now. When I searched for “latex package imperial units”, your blog was the first thing that came up. I did not find any solution, though, except manually adding imperial units to `siunitx` package. It somehow seems wrong, though, to write `\DeclareSIUnit\inch{in}`. Although it has some interesting possibilities, for example kiloinch and centiinch :).

• Hi Jan. I do, I made this blog for this special reader: myself. I check it very often to remind myself of these little things I keep forgetting. There’s some opinion, too… Anyway, now I finally understand Oscar’s comment. But wait, units cannot be imperial in the US! Not since the tea incident. Seriously, I really don’t know the solution. The problem could also appear with weird scientific units such as the Rydberg, or the Hartree. I must admit I often ignore my own advice and just write “\$E=10\$ mJ”.