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

direction

The four directions into which content can be laid out.

Possible values are:

  • ltr: Left to right.
  • rtl: Right to left.
  • ttb: Top to bottom.
  • btt: Bottom to top.

These values are available globally and also in the direction type's scope, so you can write either of the following two:

#stack(dir: rtl)[A][B][C]
#stack(dir: direction.rtl)[A][B][C]
Preview

Definition
Definition
These functions and types can have related definitions. To access a definition, specify the name of the function or type, followed by the definition name separated by a period.

from

Returns a direction from a starting point.

direction.from()->
Show example
direction.from(left) \
direction.from(right) \
direction.from(top) \
direction.from(bottom)
Preview

side
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.

to

Returns a direction from an end point.

direction.to()->
Show example
direction.to(left) \
direction.to(right) \
direction.to(top) \
direction.to(bottom)
Preview

side
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.

axis

The axis this direction belongs to, either "horizontal" or "vertical".

self.axis(
)->
Show example
#ltr.axis() \
#ttb.axis()
Preview

sign

The corresponding sign, for use in calculations.

self.sign(
)->
Show example
#ltr.sign() \
#rtl.sign() \
#ttb.sign() \
#btt.sign()
Preview

start

The start point of this direction, as an alignment.

self.start(
)->
Show example
#ltr.start() \
#rtl.start() \
#ttb.start() \
#btt.start()
Preview

end

The end point of this direction, as an alignment.

self.end(
)->
Show example
#ltr.end() \
#rtl.end() \
#ttb.end() \
#btt.end()
Preview

inv

The inverse direction.

self.inv(
)->
Show example
#ltr.inv() \
#rtl.inv() \
#ttb.inv() \
#btt.inv()
Preview
Open official docs

Search