How to number every 5th line?

Hello everyone,

I am currently using the following code to number each line in my text:

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

However, I would like to number only every 5th line (for example, lines 5, 10, 15, etc.). Is there a way to achieve this in Typst? I would appreciate any help or suggestions on how to implement this!

Thank you in advance for your support!

Hi @Mathemensch ,

The numbering parameter of par.line also accepts a function which the line number is passed to. You can use this to filter out numbers that are not divisible by 5 like this:

#set par.line(numbering: i => if calc.rem(i, 5) == 0 { i })
2 Likes

Thank you very much!
I love how versatily typst is.

1 Like

Actually I thought just the same when writing down the answer :D

1 Like

This seems like a great example to add to the docs. PR/issue time? :eyes:

1 Like