Joke: Typographic measure theory (with an additional joke)

The typographic measure function m defined below satisfies m(a) + m(b) ≤ m(a+b), but does not always take equality.

In jargon, m is subadditive, but many contents do not meet the Carathéodory’s criterion and thus not Lebesgue measurable.

let m(a) = measure(a).width

Solution
let x = [一口]
let y = [一、]
let z = [一 ]
let w = h(0.3em, weak: true)
Full code
#set page(height: auto, width: auto, margin: 2em)
#set text(10pt, font: "Noto Serif CJK SC", fallback: false)

#let solution = (
  x: [一口],
  y: [一、],
  z: [一 ],
  w: h(0.3em, weak: true),
)

```typc
let m(a) = measure(a).width
let x = ??
let y = ??
let z = ??
let w = ??
```

#let twin(expr, irregular: false) = (
  {
    set raw(lang: "typc")
    expr
  },
  box(
    outset: 0.25em,
    stroke: if irregular { aqua },
    eval(expr.text, scope: (
      m: a => context measure(a).width,
      ..solution,
    )),
  ),
)


#set table.hline(stroke: 0.5pt)
#table(
  columns: 2 * (1 + 4),
  align: (start, end),
  stroke: (x, y) => if x > 0 and calc.even(x) { (left: 0.5pt) },

  table.cell(colspan: 2, {}),
  ..twin(`m(x)`),
  ..twin(`m(y)`),
  ..twin(`m(z)`),
  ..twin(`m(w)`),
  table.hline(),

  ..twin(`m(x)`),
  ..twin(`m(x + x)`),
  ..twin(`m(x + y)`),
  ..twin(`m(x + z)`),
  ..twin(`m(x + w)`),

  ..twin(`m(y)`),
  ..twin(`m(y + x)`, irregular: true),
  ..twin(`m(y + y)`, irregular: true),
  ..twin(`m(y + z)`, irregular: true),
  ..twin(`m(y + w)`, irregular: true),

  ..twin(`m(z)`),
  ..twin(`m(z + x)`, irregular: true),
  ..twin(`m(z + y)`, irregular: true),
  ..twin(`m(z + z)`, irregular: true),
  ..twin(`m(z + w)`),

  ..twin(`m(w)`),
  ..twin(`m(w + x)`),
  ..twin(`m(w + y)`),
  ..twin(`m(w + z)`),
  ..twin(`m(w + w)`),

  table.hline(),
  [], [],
  ..twin(`m(x + w + x)`, irregular: true),
  ..twin(`m(y + w + y)`, irregular: true),
  ..twin(`m(z + w + z)`, irregular: true),
  ..twin(`m(w + w + w)`, irregular: true),
)
Background

It makes the auto hanging indents of multiline headings inaccurate.

Roughly speaking, the auto indent should be m(numbering + h(0.3em)), but typst uses m(numering) + 0.3em, which can be larger.

I found this mystery while I was developing Fix auto hanging-indent for `一、` heading numbering by YDX-2147483647 · Pull Request #7247 · typst/typst · GitHub.

An additional joke

(Once posted to the Discord discussions channel on 2025-07-30)

#let x = state("x", 5)
#let x-- = x.update(x => x - 1)

- #context x.get();
- #x--;
- #context x.get();
- #x--;
- #context x.get();

6 Likes

Hmm, today I notice that the measure function is also discontinuous.

m[一、#h(0pt)] ≠ lim_(x → 0pt⁺) m[一、#h(x)].

#set text(10pt)
#let m(a) = context measure(a).width

#set raw(lang: "typm")
#context table(
  columns: 2,
  stroke: (x: none, y: 0.5pt),
  `一、`, m[一、],
  `一、#h(0.0pt)`, m[一、#h(0.0pt)],
  `一、#h(0.0000001pt)`, m[一、#h(0.0000001pt)],
)