Reading Typst

2026-08-23 • Manuel Vázquez Acosta

Typst is one surprising discovery. I wrote my master’s thesis in reStructuredText [1], with some custom scripts to pre-process it and translate it to LaTeX.

It was a different era. Today I would have gone to Typst without a doubt. I have yet to master Typst enough to know whether it supports penalties to semi-automatically control where to insert page breaks in large texts. Nevertheless, I never really mastered all the TeX macros and only knew a tiny fraction of LaTeX. I never read the code of TeX.

Typst is kind of different. I’m reading the master’s thesis [2] that describes the core algorithm; and I’m about to read the code. The thesis provides the background (the Red-Green tree used for incremental compilation) while the code will provide the gritty details and all the surface API available to users.

To get things going, I have used CeTZ to create lamportian-dramatis; which eases the creation of Lamport diagrams for distributed systems:

A diagram that showcases |lamportian-dramatis|_ with three vertical timelines of replicas S, A, and C.  It shows several symmetrical synchronization events, and also asymmetrical send/receive pairs.  Events can be labeled, and the whole diagram can be customized with arbitrary CeTZ functions.
#lamport-diagram(
  replicas: (replica("S", color: luma(0)), "A", "C"),
  orientation: vertical,
  events: (
    "S": (
      sync("boot"),
      send("c-reads"),
      sync("a-pushes"),
      recv("c-pushes"),
      sync("a-catches-up")
    ),
    "C": (
      recv("c-reads"),
      event(id: "c1")[`C.1`],
      send("c-pushes")
    ),
    "A": (
      [`A.1`],
      sync("boot"),
      event(id: "a2")[`A.2`],
      sync("a-pushes"),
      sync("a-catches-up")
    ),
  ),
  // overlays: ...
)

Of course [3], the library has been written with the help of coding agents. I control the API decisions; the LLM does the implementation. And while I’m reading the generated code, I haven’t really managed it or modified it by hand. In some regard this approach is both an accelerator and decelerator: I’m still not fluent in Typst, but I discover things faster than by solely reading the Typst docs. I can understand the generated code, but I’m still having “Oh! I didn’t know this!” moments.

I value the journey; and I also think AI agents have a role on that being, as long as they don’t compromise my own abilities. AI agents are my pedantic, annoying sidekicks that talk funny but still teach me something new now and then. And they also take over for me when I get no satisfaction from typing things I have already worked out in my head, and when I only need those things done because the ideation already happened. Not all crafting is equally satisfying.

Footnotes

[1]I still owe you a rant about Markdown. Let’s just say reStructuredText was better: better designed, better documented, and with enough extension points to avoid all the inconsistency of Markdown flavors. That I could use it back then, when Markdown was not yet everywhere, to produce a very nicely typeset document is basically my whole argument.
[2]There are two theses mentioned in the CITATION.cff file, but I’m more interested in Fast typesetting with incremental compilation.
[3]It’s 2026.