measure
Measures the layouted size of content.
The measure
function lets you determine the layouted size of content. Note that an infinite space is assumed, therefore the measured height/width may not necessarily match the final height/width of the measured content. If you want to measure in the current layout dimensions, you can combine measure
and layout
.
Example
The same content can have a different size depending on the styles that are active when it is layouted. For example, in the example below #content
is of course bigger when we increase the font size.
#let content = [Hello!]
#content
#set text(14pt)
#content

To do a meaningful measurement, you therefore first need to retrieve the active styles with the style
function. You can then pass them to the measure
function.
#let thing(body) = style(styles => {
let size = measure(body, styles)
[Width of "#body" is #size.width]
})
#thing[Hey] \
#thing[Welcome]

The measure function returns a dictionary with the entries width
and height
, both of type length
.
ParametersParameters are the inputs to a function. They are specified in parentheses after the function name.
content
The content whose size to measure.
styles
stylesRequiredPositionalPositional parameters are specified in order, without names.
The styles with which to layout the content.