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

alignment

Where to align something along an axis.

Possible values are:

  • start: Aligns at the start of the text direction.
  • end: Aligns at the end of the text direction.
  • left: Align at the left.
  • center: Aligns in the middle, horizontally.
  • right: Aligns at the right.
  • top: Aligns at the top.
  • horizon: Aligns in the middle, vertically.
  • bottom: Align at the bottom.

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

#align(center)[Hi]
#align(alignment.center)[Hi]
Preview

2D alignments

To align along both axes at the same time, add the two alignments using the + operator. For example, top + right aligns the content to the top right corner.

#set page(height: 3cm)
#align(center + bottom)[Hi]
Preview

Fields

The x and y fields hold the alignment's horizontal and vertical components, respectively (as yet another alignment). They may be none.

#(top + right).x \
#left.x \
#left.y (none)
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.

axis

The axis this alignment belongs to.

  • "horizontal" for start, left, center, right, and end
  • "vertical" for top, horizon, and bottom
  • none for 2-dimensional alignments
self.axis(
)->
Show example
#left.axis() \
#bottom.axis()
Preview

inv

The inverse alignment.

self.inv(
)->
Show example
#top.inv() \
#left.inv() \
#center.inv() \
#(left + bottom).inv()
Preview
Open official docs

Search