Open yochem opened 7 months ago
I'm very interested in this feature, but I would want it to work the same way as preprints (numbering is associated with absolute page positions rather than text lines). This will allow it to work with images, headings, etc.
My first attempt was to #set page(background: ...)
but this had too many edge cases preventing it from working. But that was awhile ago (typst 0.7 I think?), maybe the attempt would work better now.
In any case, if you submit a PR that adds numbering to the page itself, I'd be quite happy to merge the feature!
#let numbered = layout(size => {
style(styles => {
let spacing = 1.2em
let line-height = measure(v(spacing), styles).height
set align(left + top)
show: pad.with(left: 1em)
box(height: 100%)[
#for ii in range(int(calc.ceil(size.height / line-height))) {
place(dy: spacing * ii, str(ii + 1))
}
]
})
})
#set page(margin: 0.8in, background: numbered)
Here is a start, I will need to troubleshoot to see if there are any problems.
I was thinking about that too, but then it might be ambiguous which number a line would have. Communicating it like "on the line that is between 9 and 10 you missed a comma" is probably not ideal. It is much simpler to implement though.
This is how my current solutions handles e.g. headings and tables:
We could improve this to number every element:
But it currently changes the spacing, which is of course not desired. I'll fix that.
@yochem How does it handle figures, grids, column environments, etc.? If it is robust, I like the way it looks here:
Things to check:
tablex
rowspanxplace
d contentI also haven't fixed the weird spacing issue yet.
I'm currently working on having draft line numbers for paragraphs:
There are still some known bugs, but nothing that can't be fixed. Would this be something that you would like to include in this project? It seems like a great addition to this package to me.