#text line height and line numbers
18 messages · Page 1 of 1 (latest)
Not sure if I understand the question correctly, but if you run
set text(size: 15pt)
Then every future reference to 1em will be 15pt
?r
#set text(size: 15pt)
#let body = [Hello world! `1em` is #style(styles => measure(v(1em), styles).height)]
#body
#set text(size: 50pt)
#body
I think they try to fit precisely 44 lines of text in a 660pt tall container. No idea how to do that programmatically. If this is a one time need, I'd just eyeball the result byt tweaking the text->size parameter and par->leading parameter.
You can check out fit-to-height from the polylux package
?r
#import "@preview/polylux:0.3.1": fit-to-height
#fit-to-height(150pt, prescale-width: 150%)[
#lorem(1000)
]
It will shrink the text to fit in your specified container size, you can optionally set "prescale-width" to determine when the lines wrap
More docs here: https://polylux.dev/book/utils/fit-to-height.html#fit-to-height
I do not mean the font size. I mean the distance between two text lines (baseline to baseline) should be 15 pt.
If you can set the text height to 660 pt you should got it, Ragaga. You have to be able to set both the line height and the text height.
Something like #set par(leading: 15pt)?
https://typst.app/docs/reference/model/par/#parameters-leading
Leading is the gap between two lines, not the distance between two baselines. So that alone won't give the desired results. But measure() helps here:
#let thing(body) = style(styles => {
let size = measure(body, styles)
[Height of "#body" is #size.height]
})
#thing[Hey] \
Shows you the height of a single line. Then you can use that to apply the desired leading using par() so that the sum is 15.0. Still no idea if one can do this automatically.
Maybe something like this:
?r ```
#block(width: 100%, height: 660pt, stroke: 1pt + white)[
#style(styles => {
set par(leading: 15pt - measure(text[x], styles).height)
for n in range(44) [#{n+1} \ ]
})
]
Thank you all. That is very helpful. I may not have been precise enough: I didn't mean line numbers but the number of lines. This makes the for-loop redundant. Is there no other possibility to set the text height, line height or number of lines? In LaTeX I mean you can set the text height; in ConTeXt you can set the text height and the number of lines.