Feeds:
Posts
Comments

Archive for August, 2011

Typesetting numerical data (with units) in LaTeX correctly can be difficult and time-consuming. Note that I emphasized “correctly.”

Fortunately, siunitx comes to the rescue. From its description:

Typesetting values with units requires care to ensure that the combined mathematical meaning of the value plus unit combination is clear. In particular, the SI units system lays down a consistent set of units with rules on how they are to be used. However, different countries and publishers have differing conventions on the exact appearance of numbers (and units). A number of LaTeX packages have been developed to provide consistent application of the various rules: SIunits, sistyle, unitsdef and units are the leading examples. The numprint package provides a large number of number-related functions, while dcolumn and rccol provide tools for typesetting tabular numbers.

The siunitx package takes the best from the existing packages, and adds new features and a consistent interface. A number of new ideas have been incorporated, to fill gaps in the existing provision. The package also provides backward-compatibility with SIunits, sistyle, unitsdef and units. The aim is to have one package to handle all of the possible unit-related needs of LaTeX users.

Some examples stolen from its manual:

  • \num{1+-2i} produces 1 \pm 2\text{i}
  • \num{.3e45} produces 0.3 \times 10^{45}
  • \si{kg.m.s^{-1}} or \si{\kilogram\metre\per\second} both produce \text{kg}\,\text{m}\,\text{s}^{-1}
  • \si[per-mode=symbol]{\kilogram\metre\per\second} produces \text{kg}\,\text{m} / \text{s}

These are just a few examples. The possibility is much larger and the package is very useful. So keep my words: “Always use siunitx when possible.”

Read Full Post »