提示:本教程存在过时问题,更详细教程请阅读 小蓝书Typst 中文社区导航 FAQ
注意:该中文文档为社区驱动的非官网文档,可能存在错译、漏译或过时等问题,请以官网文档 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 中文文档

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

A bullet list.

Displays a sequence of items vertically, with each item introduced by a marker.

Example

Normal list.
- Text
- Math
- Layout
- ...

Multiple lines.
- This list item spans multiple
  lines because it is indented.

Function call.
#list(
  [Foundations],
  [Calculate],
  [Construct],
  [Data Loading],
)
Preview

Syntax

This functions also has dedicated syntax: Start a line with a hyphen, followed by a space to create a list item. A list item can contain multiple paragraphs and other block-level content. All content that is indented more than an item's marker becomes part of that item.

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

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

If this is false, the items are spaced apart with list spacing. If it is true, they use normal leading instead. This makes the 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

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

- To make a list wide, simply insert
  a blank line between the items.
Preview

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

The marker which introduces each item.

Instead of plain content, you can also pass an array with multiple markers that should be used for nested lists. If the list nesting depth exceeds the number of markers, the last one is repeated. For total control, you may pass a function that maps the list's nesting depth (starting from 0) to a desired marker.

默认:[]

查看示例
#set list(marker: [--])
- A more classic list
- With en-dashes

#set list(marker: ([], [--]))
- Top-level
  - Nested
  - Items
- Items
Preview

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

The indent of each item.

默认:0pt

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

The spacing between the marker and the body of each item.

默认:0.5em

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

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

If set to auto, uses the spacing below blocks.

默认:auto

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

The bullet list's children.

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

查看示例
#for letter in "ABC" [
  - Letter #letter
]
Preview

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

item

A bullet list item.

list.item() -> content

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

The item's body.