TypstDocumentation

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()!
])
Preview

Parameters
Question mark

locate() -> content

func
function
RequiredPositional
Question mark

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.

Methods
Question mark

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.

value.page(
) -> integer

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.

value.position(
) -> dictionary

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.

value.page-numbering(
) -> stringfunctionnone