Number/unit formatting and decimal-alignment in tables with Zero:0.4.0

This new release of Zero is a big one!

  • New: Units and quantities
  • Upgrading number alignment in tables

What is Zero?

Zero is a package for formatting numbers in a consistent and scientifically accurate way, e.g., num[1.7+-0.2e5]. Also, for tables it provides alignment of numerals at the decimal point (and more). Check out the detailed documentation via the link above.

Why use Zero?

Zero can take a lot of effort from your hands. Moreover, Zero is used by other packages like Lilaq and Pillar and various templates. The advantage: you only need to configure number formatting once in the entire document according to your language’s and personal preferences.

What’s new in this version?

On the one hand, the new version zero:0.4.0 features units and quantities, as repeatedly requested. Unlike other unit packages, Zero takes a different approach which is less prone to typos and a little more concise in usage (after the necessary units have been declared once), see below.

On the other hand, Zeros’s popular feature for number alignment in tables got an upgrade: it can now seamlessly combined with many other table packages through non-obtrusive show-rules.

Oh, and of course there are various improvements and fixes, view the full changelog.

Units and quantities

In order to avoid repetition (DRY principle) and to avoid accidental errors, every unit is

  • first declared (or already predefined)
  • and then used as a function to produce a quantity.

Many basic units are already predeclared in the zi module (and we can add more common combined units in the future).

#import "@preview/zero:0.4.0": zi

#let kgm-s2 = zi.declare("kg m/s^2")

- The current world record for the 100 metres is held by Usain Bolt with #zi.s[9.58]. 
- The velocity of light is #zi.m-s[299792458].
- A Newton is defined as #kgm-s2[1]. 
- The unit of a frequency is #zi.Hz(). 

Please refer to zero: declaring-a-new-unit for naming conventions when declaring units.

Table alignment

Instead of using a wrapper function for table, Zero provides a function that can be used in a show rule. It does not matter how the table was generated, Zero can format and align the numbers (except when the cell content again is wrapped by something else).

#{
  show table: zero.format-table(none, auto, auto)
  table(
    columns: 3,
    align: center,
    $n$, $α$, $β$,
    [1], [3.45], [-11.1],
    ..
  )
}

How to support this work

If you want to support this open-source work, you can sponsor the project with a small amount.

6 Likes