Development build 586e1bd4
Typst文档简体中文版v0.15.1 + dev 586e1bd4

frac元素
Question mark
自始可用Go to source

A mathematical fraction.

Example

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

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.

参数
Question mark

math.frac() → content

num
content
必需参数
Question mark
位置参数
Question mark

The fraction’s numerator.

denom
content
必需参数
Question mark
位置参数
Question mark

The fraction’s denominator.

style
str
可用set规则
Question mark
默认值:"vertical"

How the fraction should be laid out.

Expand展开示例:Styles
$ frac(x, y, style: "vertical") $ $ frac(x, y, style: "skewed") $ $ frac(x, y, style: "horizontal") $
Expand展开示例:Setting the default
#set math.frac(style: "skewed") $ a / b $
Expand展开示例: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 $
Expand展开示例: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 $
Expand展开示例:Use LaTeX-like convention
// Change the default style. #set math.frac(style: "horizontal") // Define a shorthand with the original style. #let frac = math.frac.with(style: "vertical") $ p/q = frac(p, q) $ // The shadowed definition can still be accessed. #assert.eq($p/q$, $std.math.frac(p, q)$)
VariantDetails
"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.