I tried typesetting a document which has multiple numbered lists on the same page. But there is an issue with how the lists are aligned when the lists have different number of digits. Is there a way to deal with this? ideally I’d except all the separators (period, brackets, etc.) to be aligned across the document. Please see this page:
List numbering indentation depends on the longest item number width. If one list has item with 2000. , do you really want list with just 4 items to have numbering taking measure[2000.].width with a big space for no reason on the left side? I’m not sure if there are solutions for this, but sounds like this would need some hackery that might not work great.
You could use the package numbly – Typst Universe.
Or an easy way would be to use this solution by @ensko:
#set enum(numbering: num => context {
let the-numbering = numbering.with("1.")
let max = 99
let width = measure(the-numbering(max)).width
box(width: width, the-numbering(num))
})
You can adjust the max number of entries to your liking.
If you want to change the numbering pattern with the level:
#set enum(
numbering: (..n) => context {
let n = n.pos()
let level = n.len()
let n = n.last()
let (max, the-numbering) = {
if level == 1 {
(99, numbering.with("(1)"))
} else if level == 2 {
(10, numbering.with("(a)"))
} else {
(10, numbering.with("(i)"))
}
}
let widths = range(1, max).map(num => measure(the-numbering(num)).width)
box(width: calc.max(..widths), the-numbering(n))
},
full: true,
)
Credit to @ensko (aka SillyFreak). This was posted a while ago on Reddit and seems like a good working solution. Read the post for more.
