注意:该中文文档为社区驱动的非官网文档,可能存在错译、漏译或过时等问题,请以官网文档 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 中文文档

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

为文本添加下划线。

Example

This is #underline[important].
Preview

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

stroke
auto length color gradient stroke pattern dictionary
可用 Set 规则
可以使用 Set 规则,为函数后续所有的使用设置默认参数。

如何绘制线条。

详细内容参见 line 的文档 如果设为 auto, 则采用文本颜色和当前字体定义的粗细。

默认:auto

查看示例
Take #underline(
  stroke: 1.5pt + red,
  offset: 2pt,
  [care],
)
Preview

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

相对于基准线的位置。如果设为 auto,则从字体表中读取。

默认:auto

查看示例
#underline(offset: 5pt)[
  The Tale Of A Faraway Line I
]
Preview

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

超出文本长度的量(如果设为负数则缩短)。

默认:0pt

查看示例
#align(center,
  underline(extent: 2pt)[Chapter 1]
)
Preview

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

是否跳过与字形冲突的部分。

默认:true

查看示例
This #underline(evade: true)[is great].
This #underline(evade: false)[is less great].
Preview

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

下划线是否应该放在内容后.

默认:false

查看示例
#set underline(stroke: (thickness: 1em, paint: maroon, cap: "round"))
#underline(background: true)[This is stylized.] \
#underline(background: false)[This is partially hidden.]
Preview

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

要添加下划线的内容。