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

cancel
Element
Element
Element functions can be customized with set and show rules.

Displays a diagonal line over a part of an equation.

This is commonly used to show the elimination of a term.

Example

Here, we can simplify:
$ (a dot b dot cancel(x)) /
    cancel(x) $
Preview

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

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

The content over which the line should be placed.

length
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

The length of the line, relative to the length of the diagonal spanning the whole element being "cancelled". A value of 100% would then have the line span precisely the element's diagonal.

Default value:

100% + 3pt

Show example
$ a + cancel(x, length: #200%)
    - cancel(x, length: #200%) $
Preview

inverted
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

Whether the cancel line should be inverted (flipped along the y-axis). For the default angle setting, inverted means the cancel line points to the top left instead of top right.

Default value:

false

Show example
$ (a cancel((b + c), inverted: #true)) /
    cancel(b + c, inverted: #true) $
Preview

cross
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

Whether two opposing cancel lines should be drawn, forming a cross over the element. Overrides inverted.

Default value:

false

Show example
$ cancel(Pi, cross: #true) $
Preview

angle
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

How much to rotate the cancel line.

  • If given an angle, the line is rotated by that angle clockwise with respect to the y-axis.
  • If auto, the line assumes the default angle; that is, along the rising diagonal of the content box.
  • If given a function angle => angle, the line is rotated, with respect to the y-axis, by the angle returned by that function. The function receives the default angle as its input.

Default value:

auto

Show example
$ cancel(Pi)
  cancel(Pi, angle: #0deg)
  cancel(Pi, angle: #45deg)
  cancel(Pi, angle: #90deg)
  cancel(1/(1+x), angle: #(a => a + 45deg))
  cancel(1/(1+x), angle: #(a => a + 90deg)) $
Preview

stroke
Settable
Settable
Settable parameters can be set using the set rule, changing the default value used thereafter.

How to stroke the cancel line.

Default value:

0.5pt

Show example
$ cancel(
  sum x,
  stroke: #(
    paint: red,
    thickness: 1.5pt,
    dash: "dashed",
  ),
) $
Preview
Open official docs

Search