Examples

One page per thing a reader is trying to do.

A worked Keisen table to start from, and a page for each outcome: totals by group, declared groups, estimates with their error, local notation, threshold marks, long tables, in-cell plots, and right-to-left text.

Every table in this section is compiled, when the site is built, from the file in the repository’s tests/visual/ directory that the page shows. The listings are those files as they are, except that the site writes their /lib.typ import as the package import a reader writes. tools/check.sh compiles them on every run, and tools/dry-release.sh compiles them against an installed copy of the package.

A table, built and formatted

The smallest thing worth calling a display table: a title, labelled columns, formatted numbers, and a source note.

// A title, a subtitle, column labels, formatted numbers and a source note.

#import "@preview/keisen:0.0.1": *

#set page(width: auto, height: auto, margin: 0.5cm)
#set text(font: "Libertinus Serif", size: 10pt)

#display-table(
  (
    model: ("Audi A4", "BMW 320i", "Volkswagen Golf"),
    consumption: (7.25, 8.5, 6.125),
    year: (2019, 2021, 2020),
  ),
  table-header(
    title: [Fuel consumption],
    subtitle: [Litres per 100 kilometres],
  ),
  columns-label(
    model: [Model],
    consumption: [Consumption],
    year: [Year],
  ),
  format-number("consumption", decimals: 2),
  format-integer("year", grouping: none),
  table-source-note([Source: manufacturer figures.]),
)

A table titled Fuel consumption with three car models, their consumption to two decimals, and the model year, above a source note.

Numeric columns align themselves against the end edge and the others against the start edge, so nothing needed saying about alignment. 6.125 rounds to 6.13: the default is half-up, computed in decimal arithmetic rather than in floats.

That is the shape of every table below. Data goes in first, directives follow in the order they should apply, and the theme is an argument like any other.

Find your case

Back to top