locate
Provides access to the location of content.
This is useful in combination with queries, counters, state, and links. See their documentation for more details.
#locate(loc => [
My location: \
#loc.position()!
])

ParametersParameters are the inputs to a function. They are specified in parentheses after the function name.
func
A function that receives a location
. Its return value is displayed
in the document.
This function is called once for each time the content returned by
locate
appears in the document. That makes it possible to generate
content that depends on its own location in the document.
MethodsMethods are functions that are available on values of a type. They can be called for a value using the .
operator.
.
operator.page
method
Return the page number for this location.
Note that this does not return the value of the page counter at this location, but the true page number (starting from one).
If you want to know the value of the page counter, use
counter(page).at(loc)
instead.
position
method
Return a dictionary with the page number and the x, y position for this location. The page number starts at one and the coordinates are measured from the top-left of the page.
If you only need the page number, use page()
instead as it allows Typst
to skip unnecessary work.
page-numbering
method
Returns the page numbering pattern of the page at this location. This can be used when displaying the page counter in order to obtain the local numbering. This is useful if you are building custom indices or outlines.
If the page numbering is set to none
at that location, this function returns none
.