Typst in legal writing

Typst just recently introduced a line numbering function:

#set par.line(numbering: "1", numbering-scope: "page")
#lorem(200)

Although customization currently has its limits, for example: if you need US style four-digit numbers like [0001], you’ll need your own function, as there is currently no zero padding, at least to the best of my knowledge. Additionally, skipping paragraphs you don’t want numbered likely requires some initial thought.

Bibliography management is already implemented quite well. You can also use your own .csl files. So it is certainly already feasible to use for legal writing. But be prepared to need a little hack here and there. I suggest testing it with a simple case to determine if you’re willing to invest the time to adopt it.

For example:

#let pad_zeros(n, width) = {
  let s = str(n)
  if s.len() < width {
    return "0" * (width - s.len()) + s
  }
  return s
}

#set par.line(numbering: i => if calc.rem(i, 5) == 0 { "[" + pad_zeros(i, 4) + "]" })
#lorem(200)

This is what the code would look like to number every 5th line and add zero padding [0001]-style, just as an example of what is possible. Inspired by this and that. So while many things can be done in a custom way, expectation management is essential.