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

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

A list of terms and their descriptions.

Displays a sequence of terms and their descriptions vertically. When the descriptions span over multiple lines, they use hanging indent to communicate the visual hierarchy.

Example

/ Ligature: A merged glyph.
/ Kerning: A spacing adjustment
  between two adjacent letters.
Preview

Syntax

This function also has dedicated syntax: Starting a line with a slash, followed by a term, a colon and a description creates a term list item.

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

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

If this is false, the items are spaced apart with term list spacing. If it is true, they use normal leading instead. This makes the term list more compact, which can look better if the items are short.

In markup mode, the value of this parameter is determined based on whether items are separated with a blank line. If items directly follow each other, this is set to true; if items are separated by a blank line, this is set to false.

默认:true

查看示例
/ Fact: If a term list has a lot
  of text, and maybe other inline
  content, it should not be tight
  anymore.

/ Tip: To make it wide, simply
  insert a blank line between the
  items.
Preview

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

The separator between the item and the description.

If you want to just separate them with a certain amount of space, use h(2cm, weak: true) as the separator and replace 2cm with your desired amount of space.

默认:h(amount: 0.6em, weak: true)

查看示例
#set terms(separator: [: ])

/ Colon: A nice separator symbol.
Preview

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

The indentation of each item.

默认:0pt

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

The hanging indent of the description.

This is in addition to the whole item's indent.

默认:2em

查看示例
#set terms(hanging-indent: 0pt)
/ Term: This term list does not
  make use of hanging indents.
Preview

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

The spacing between the items of a wide (non-tight) term list.

If set to auto, uses the spacing below blocks.

默认:auto

children
content array
必需参数位置参数
位置参数按顺序传入,不带名称。
可变参数
可变参数可以多次传入。

The term list's children.

When using the term list syntax, adjacent items are automatically collected into term lists, even through constructs like for loops.

查看示例
#for (year, product) in (
  "1978": "TeX",
  "1984": "LaTeX",
  "2019": "Typst",
) [/ #product: Born in #year.]
Preview

定义
函数和类型可以有与其关联的定义 (成员或方法)。可以使用 "." 操作符来访问调用它们。

item

A term list item.

terms.item() -> content

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

The term described by the list item.

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

The description of the term.