注意 / 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+后期随缘更新

length

A size or distance, possibly expressed with contextual units.

Typst supports the following length units:

  • Points: 72pt
  • Millimeters: 254mm
  • Centimeters: 2.54cm
  • Inches: 1in
  • Relative to font size: 2.5em

You can multiply lengths with and divide them by integers and floats.

Example

#rect(width: 20pt)
#rect(width: 2em)
#rect(width: 1in)

#(3em + 5pt).em \
#(20pt).em \
#(40em + 2pt).abs \
#(5em).abs
Preview

Fields

  • abs: A length with just the absolute component of the current length (that is, excluding the em component).
  • em: The amount of em units in this length, as a float.

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

pt

Converts this length to points.

Fails with an error if this length has non-zero em units (such as 5em + 2pt instead of just 2pt). Use the abs field (such as in (5em + 2pt).abs.pt()) to ignore the em component of the length (thus converting only its absolute component).

self.pt(
)->

mm

Converts this length to millimeters.

Fails with an error if this length has non-zero em units. See the pt method for more details.

self.mm(
)->

cm

Converts this length to centimeters.

Fails with an error if this length has non-zero em units. See the pt method for more details.

self.cm(
)->

inches

Converts this length to inches.

Fails with an error if this length has non-zero em units. See the pt method for more details.

self.inches(
)->
转到官方文档(英文)

搜索