Info
This site is generated using the static site generator developed by the Typst Community. Please adjust the text content of this banner according to your usage requirements. At Typst GmbH's request, when publishing documentation, you must clearly indicate that it is non-official and display the version of Typst being documented. For details, refer to Issue #874 on typst/typst.
TypstDocumentEnglish
v0.dev.2025-09-12

locate
Context
Context
Context functions can only be used when the context is known.

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>
Preview

Parameter
Parameter
Parameters are input values for functions. Specify them in parentheses after the function name.

selector
Required
Required
Required parameters must be specified when calling the function.
Positional
Positional
Positional parameters can be set by specifying them in order, omitting the parameter name.

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 the location() method on content.
Open official docs

Search