locate
Determines the location of an element in the document.
Takes a selector that must match exactly one element and returns that
element's location
. This location can, in particular, be used to
retrieve the physical page
number and
position
(page, x, y) for that element.
Examples
Locating a specific element:
#context [
Introduction is at: \
#locate(<intro>).position()
]
= Introduction <intro>
Compatibility
In Typst 0.10 and lower, the locate
function took a closure that made the
current location in the document available (like here
does now). This
usage pattern is deprecated. Compatibility with the old way will remain for
a while to give package authors time to upgrade. To that effect, locate
detects whether it received a selector or a user-defined function and
adjusts its semantics accordingly. This behaviour will be removed in the
future.
引数
Parameters are the inputs to a function. They are specified in parentheses after the function name.
selector
A selector that should match exactly one element. This element will be located.
Especially useful in combination with
here
to locate the current context,- a
location
retrieved from some queried element via thelocation()
method on content.