TypstDocumentation

alignment

Where to align something along an axis.

Possible values are:

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

Definitions
Question mark

axis

The axis this alignment belongs to.

self.axis(
)
#left.axis() \
#bottom.axis()
Preview

inv

The inverse alignment.

self.inv(
) -> alignment
#top.inv() \
#left.inv() \
#center.inv() \
#(left + bottom).inv()
Preview