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-10-13

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

A mathematical fraction.

Example

$ 1/2 < (x+1)/2 $
$ ((x+1)) / 2 = frac(a, b) $
Preview

Syntax

This function also has dedicated syntax: Use a slash to turn neighbouring expressions into a fraction. Multiple atoms can be grouped into a single expression using round grouping parentheses. Such parentheses are removed from the output, but you can nest multiple to force them.

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

num
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 fraction's numerator.

denom
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 fraction's denominator.

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

How the fraction should be laid out.

Show example: Styles
$ frac(x, y, style: "vertical") $
$ frac(x, y, style: "skewed") $
$ frac(x, y, style: "horizontal") $
Preview
Show example: Setting the default
#set math.frac(style: "skewed")
$ a / b $
Preview
Show example: Handling of grouping parentheses
// Grouping parentheses are removed.
#set math.frac(style: "vertical")
$ (a + b) / b $

// Grouping parentheses are removed.
#set math.frac(style: "skewed")
$ (a + b) / b $

// Grouping parentheses are retained.
#set math.frac(style: "horizontal")
$ (a + b) / b $
Preview
Show example: Different styles in inline vs block equations
// This changes the style for inline equations only.
#show math.equation.where(block: false): set math.frac(style: "horizontal")

This $(x-y)/z = 3$ is inline math, and this is block math:
$ (x-y)/z = 3 $
Preview

Default value:

"vertical"

Available string values
  • vertical

    Stacked numerator and denominator with a bar.

  • skewed

    Numerator and denominator separated by a slash.

  • horizontal

    Numerator and denominator placed inline and parentheses are not absorbed.

Open official docs

Search