cancel元素0.3.0起可用
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) $

参数
math.cancel(
content,length: relative,inverted: bool,cross: bool,angle: autoanglefunction,stroke: lengthcolorgradientstroketilingdictionary,background: bool,
) → contentbody
The content over which the line should be placed.
length默认值:100% + 0.3em
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.
展开示例
$ a + cancel(x, length: #200%)
- cancel(x, length: #200%) $

inverted默认值:false
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.
展开示例
$ (a cancel((b + c), inverted: #true)) /
cancel(b + c, inverted: #true) $

cross默认值:false
Whether two opposing cancel lines should be drawn, forming a cross over the element. Overrides inverted.
展开示例
$ cancel(Pi, cross: #true) $

angle默认值:auto
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.
展开示例
$ 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)) $

stroke默认值:0.05em
How to stroke the cancel line.
展开示例
$ cancel(
sum x,
stroke: #(
paint: red,
thickness: 1.5pt,
dash: "dashed",
),
) $

background默认值:false
Whether the line is placed behind the content.
展开示例
#set math.cancel(stroke: red + 2pt)
$ cancel("behind", background: #true) \
cancel("in front", background: #false) $
