Typesetting large tables of numerical data is a common task when writing reports and papers. To improve the readability, the numbers are frequently aligned at the decimal point.
The package Zero:0.5.0 provides a drop-in show rule for aligning the content of individual columns.
In previous versions, one could use the table wrapper zero.ztable
to achieve that. The wrapper is still available, however, now there is a more powerful way: format-table
. This function can be applied as a scoped (!) show rule before a table to activate (and configure) decimal alignment.
The advantage: now you can combine Zero with many other packages that generate or modify tables!
#import "@preview/zero:0.5.0": format-table
#{
show: format-table(none, auto, auto) // decimal alignment for column 2 and 3
table(
columns: 3,
$n$, $α$, $β$,
[1], [3.45], [-11.1],
..
)
}
Tipp 1: Be sure to only use show: format-table(..)
in a local scope because it cannot be applied twice in a row. The most idiomatic way to use it is the following:
#figure(
{
show: format-table(..)
table(..)
},
caption: []
)
Tipp 2: You could also use show table: format-table(..)
. The only difference is that if you have more than one table in the scope where the show rule was defined, the same spacing is applied to both tables if it is a show:
and not a show table:
rule. This is most easily understood through an example:
#figure(
{
show: format-table(auto)
table[1][21.223]
table[1][1.2]
},
caption: []
)
\
#figure(
{
show table: format-table(auto)
table[1][21.223]
table[1][1.2]
},
caption: []
)
A breaking change with Zero:0.5.0
The rounding setup has been streamlined. The rounding mode
can no longer be none
; instead it defaults to "places"
while the default precision is none
, meaning that no rounding is applied. This is more convenient when rounding single numbers to a specific precision (e.g., num(round: (precision: 2))[9.80665]
) because the mode does not have to be set repeatedly.
Powerful units
A new way of declaring more complex units, including arbitrary math and Typst content has been added to Zero. You can read up about it in Mc-Zen/zero · Declaring a unit.
Have fun with the new version! You are very welcome to give feedback here or share your use cases with Zero :)