Length
Documentation for the Length type.
A size or distance, possibly expressed with contextual units.
Typst supports the following length units:
- Points:
72pt - Millimeters:
254mm - Centimeters:
2.54cm - Inches:
1in - Relative to font size:
2.5em
You can multiply lengths with and divide them by integers and floats.
Example
Fields
abs: A length with just the absolute component of the current length (that is, excluding theemcomponent).em: The amount ofemunits in this length, as a float.
Methods
Converts this length to points.
Fails with an error if this length has non-zero em units (such as 5em + 2pt instead of just 2pt). Use the abs field (such as in (5em + 2pt).abs.pt()) to ignore the em component of the length (thus converting only its absolute component).
Converts this length to millimeters.
Fails with an error if this length has non-zero em units. See the pt method for more details.
Converts this length to centimeters.
Fails with an error if this length has non-zero em units. See the pt method for more details.
Converts this length to inches.
Fails with an error if this length has non-zero em units. See the pt method for more details.
Resolve this length to an absolute length.