注意:该中文文档为社区驱动的非官网文档,可能存在错译、漏译或过时等问题,请以官网文档 Documentation 为准,如发现错漏,也欢迎 您的贡献镜像)。Typst 非官方中文交流 QQ 群:793548390
Warning: the Chinese document is a community-driven non-official document, there may be mistranslation, omission or outdated problems, please refer to the official website documentation.
Typst 中文文档

cancel 元素
元素函数可以通过 set 和 show 规则进行样式自定义。

在公式上显示对角线。

通常用于表示删除元素。

Example

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

参数
参数是函数的输入,它们在函数名称后面的括号中传入。

body
content
必需参数位置参数
位置参数按顺序传入,不带名称。

被删除线覆盖的内容。

length
relative
可用 Set 规则
可以使用 Set 规则,为函数后续所有的使用设置默认参数。

删除线的长度,相对于被“删除”元素的对角线长度;值为100%时,删除线将恰好穿过元素。

默认:100% + 3pt

查看示例
$ a + cancel(x, length: #200%)
    - cancel(x, length: #200%) $
Preview

inverted
bool
可用 Set 规则
可以使用 Set 规则,为函数后续所有的使用设置默认参数。

是否沿 y 轴反转删除线(指向左上角而非右上角)。

默认:false

查看示例
$ (a cancel((b + c), inverted: #true)) /
    cancel(b + c, inverted: #true) $
Preview

cross
bool
可用 Set 规则
可以使用 Set 规则,为函数后续所有的使用设置默认参数。

是否绘制两条相反的删除线交叉绘制在元素上。会覆盖掉 inverted 参数。

默认:false

查看示例
$ cancel(Pi, cross: #true) $
Preview

angle
auto angle function
可用 Set 规则
可以使用 Set 规则,为函数后续所有的使用设置默认参数。

旋转删除线的角度。

默认:auto

查看示例
$ 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
length color gradient stroke pattern dictionary
可用 Set 规则
可以使用 Set 规则,为函数后续所有的使用设置默认参数。

如何 绘制 描边线,详情请参考 line 文档

默认:0.5pt

查看示例
$ cancel(
  sum x,
  stroke: #(
    paint: red,
    thickness: 1.5pt,
    dash: "dashed",
  ),
) $
Preview