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

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

Provides the current location in the document.

You can think of here as a low-level building block that directly extracts the current location from the active context. Some other functions use it internally: For instance, counter.get() is equivalent to counter.at(here()).

Within show rules on locatable elements, here() will match the location of the shown element.

If you want to display the current page number, refer to the documentation of the counter type. While here can be used to determine the physical page number, typically you want the logical page number that may, for instance, have been reset after a preface.

Examples

Determining the current position in the document in combination with the position method:

#context [
  I am located at
  #here().position()
]
Preview

Running a query for elements before the current position:

= Introduction
= Background

There are
#context query(
  selector(heading).before(here())
).len()
headings before me.

= Conclusion
Preview

Refer to the selector type for more details on before/after selectors.

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

here(
)->
Open official docs

Search