注意 / Info
本站经 Typst GmbH 许可,提供 Typst v0.10.0+后期随缘更新 官方文档的翻译,由中文社区维护。建议与官方文档一同阅读,因为可能存在错译、漏译或过时信息。如有意改进翻译内容或网站本身,可在GitHub上提出 Issue、发起 Pull Requests。此外,也欢迎加入「Typst 非官方中文交流群」(QQ 793548390)
This site provides a Chinese translation of the Typst v0.10.0+后期随缘更新 documentation maintained by the “Typst Chinese Community” with permission from Typst GmbH. We recommend using this alongside the official documentation. We welcome contributions through Issues and Pull Requests on our GitHub repository for both translation improvements and website enhancements. Feel free to join our QQ chat group “Typst 非官方中文交流群” (793548390).
Typst文档简体中文版
v0.10.0+后期随缘更新

outline
元素
元素
元素函数可用setshow规则自定义样式。

A table of contents, figures, or other elements.

This function generates a list of all occurrences of an element in the document, up to a given depth. The element's numbering and page number will be displayed in the outline alongside its title or caption. By default this generates a table of contents.

Example

#outline()

= Introduction
#lorem(5)

= Prior work
#lorem(10)
Preview

Alternative outlines

By setting the target parameter, the outline can be used to generate a list of other kinds of elements than headings. In the example below, we list all figures containing images by setting target to figure.where(kind: image). We could have also set it to just figure, but then the list would also include figures containing tables or other material. For more details on the where selector, see here.

#outline(
  title: [List of Figures],
  target: figure.where(kind: image),
)

#figure(
  image("tiger.jpg"),
  caption: [A nice figure!],
)
Preview

Styling the outline

The outline element has several options for customization, such as its title and indent parameters. If desired, however, it is possible to have more control over the outline's look and style through the outline.entry element.

参数
参数
参数是传给函数的输入,写在函数名后的括号中。

title
可用set规则
可用set规则
可用set规则设置参数,更改后续调用时的默认值。

The title of the outline.

  • When set to auto, an appropriate title for the text language will be used. This is the default.
  • When set to none, the outline will not have a title.
  • A custom title can be set by passing content.

The outline's heading will not be numbered by default, but you can force it to be with a show-set rule: show outline: set heading(numbering: "1.")

默认值:

auto

展开例子

target
可用set规则
可用set规则
可用set规则设置参数,更改后续调用时的默认值。

The type of element to include in the outline.

To list figures containing a specific kind of element, like a table, you can write figure.where(kind: table).

默认值:

heading.where(outlined: true)

展开例子
#outline(
  title: [List of Tables],
  target: figure.where(kind: table),
)

#figure(
  table(
    columns: 4,
    [t], [1], [2], [3],
    [y], [0.3], [0.7], [0.5],
  ),
  caption: [Experiment results],
)
Preview

depth
可用set规则
可用set规则
可用set规则设置参数,更改后续调用时的默认值。

The maximum level up to which elements are included in the outline. When this argument is none, all elements are included.

默认值:

none

展开例子
#set heading(numbering: "1.")
#outline(depth: 2)

= Yes
Top-level section.

== Still
Subsection.

=== Nope
Not included.
Preview

indent
可用set规则
可用set规则
可用set规则设置参数,更改后续调用时的默认值。

How to indent the outline's entries.

  • none: No indent
  • auto: Indents the numbering of the nested entry with the title of its parent entry. This only has an effect if the entries are numbered (e.g., via heading numbering).
  • Relative length: Indents the item by this length multiplied by its nesting level. Specifying 2em, for instance, would indent top-level headings (not nested) by 0em, second level headings by 2em (nested once), third-level headings by 4em (nested twice) and so on.
  • Function: You can completely customize this setting with a function. That function receives the nesting level as a parameter (starting at 0 for top-level headings/elements) and can return a relative length or content making up the indent. For example, n => n * 2em would be equivalent to just specifying 2em, while n => [] * n would indent with one arrow per nesting level.

Migration hints: Specifying true (equivalent to auto) or false (equivalent to none) for this option is deprecated and will be removed in a future release.

默认值:

none

展开例子
#set heading(numbering: "1.a.")

#outline(
  title: [Contents (Automatic)],
  indent: auto,
)

#outline(
  title: [Contents (Length)],
  indent: 2em,
)

#outline(
  title: [Contents (Function)],
  indent: n => [] * n,
)

= About ACME Corp.
== History
=== Origins
#lorem(10)

== Products
#lorem(10)
Preview

fill
可用set规则
可用set规则
可用set规则设置参数,更改后续调用时的默认值。

Content to fill the space between the title and the page number. Can be set to none to disable filling.

默认值:

repeat(body: [.])

展开例子
#outline(fill: line(length: 100%))

= A New Beginning
Preview

定义
定义
这些函数和类型带有附属定义。要访问这种定义,请先写上函数或类型的名称,再加上定义的名称,并用句点在中间分隔。

entry
元素
元素
元素函数可用setshow规则自定义样式。

Represents each entry line in an outline, including the reference to the outlined element, its page number, and the filler content between both.

This element is intended for use with show rules to control the appearance of outlines. To customize an entry's line, you can build it from scratch by accessing the level, element, body, fill and page fields on the entry.

展开例子
#set heading(numbering: "1.")

#show outline.entry.where(
  level: 1
): it => {
  v(12pt, weak: true)
  strong(it)
}

#outline(indent: auto)

= Introduction
= Background
== History
== State of the Art
= Analysis
== Setup
Preview

level
必需参数
必需参数
必需参数在调用函数时必须传入。
位置参数
位置参数
位置参数按顺序传入,不带参数名。

The nesting level of this outline entry. Starts at 1 for top-level entries.

element
必需参数
必需参数
必需参数在调用函数时必须传入。
位置参数
位置参数
位置参数按顺序传入,不带参数名。

The element this entry refers to. Its location will be available through the location method on content and can be linked to.

body
必需参数
必需参数
必需参数在调用函数时必须传入。
位置参数
位置参数
位置参数按顺序传入,不带参数名。

The content which is displayed in place of the referred element at its entry in the outline. For a heading, this would be its number followed by the heading's title, for example.

fill
必需参数
必需参数
必需参数在调用函数时必须传入。
位置参数
位置参数
位置参数按顺序传入,不带参数名。

The content used to fill the space between the element's outline and its page number, as defined by the outline element this entry is located in. When none, empty space is inserted in that gap instead.

Note that, when using show rules to override outline entries, it is recommended to wrap the filling content in a box with fractional width. For example, box(width: 1fr, repeat[-]) would show precisely as many - characters as necessary to fill a particular gap.

page
必需参数
必需参数
必需参数在调用函数时必须传入。
位置参数
位置参数
位置参数按顺序传入,不带参数名。

The page number of the element this entry links to, formatted with the numbering set for the referenced page.

转到官方文档(英文)

搜索