提示:本教程存在过时问题,更详细教程请阅读 小蓝书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 中文文档

version

A version with an arbitrary number of components.

The first three components have names that can be used as fields: major, minor, patch. All following components do not have names.

The list of components is semantically extended by an infinite list of zeros. This means that, for example, 0.8 is the same as 0.8.0. As a special case, the empty version (that has no components at all) is the same as 0, 0.0, 0.0.0, and so on.

You can convert a version to an array of explicitly given components using the array constructor.

构造函数
如果类型具有构造函数,可以像函数一样调用它来创建一个该类型的值。

Creates a new version.

It can have any number of components (even zero).

version() -> version
#version() \
#version(1) \
#version(1, 2, 3, 4) \
#version((1, 2, 3, 4)) \
#version((1, 2), 3)
Preview

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

The components of the version (array arguments are flattened)

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

at

Retrieves a component of a version.

The returned integer is always non-negative. Returns 0 if the version isn't specified to the necessary length.

self.at() -> int

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

The index at which to retrieve the component. If negative, indexes from the back of the explicitly given components.