注意 当サイトは、Typst v0.11.1 公式ドキュメントを、日本語コミュニティが非公式に翻訳したものです。誤訳・未訳・古い情報が含まれている可能性があるため、公式ドキュメント との併用を推奨します。このサイトの内容に誤りを発見された方は、GitHubリポジトリまでご報告を頂けましたら幸いです。我々のコミュニティにご興味のある方は、ぜひ非公式Discordサーバー「くみはんクラブ」にご参加ください。
Warning: This site provides an unofficial translation of the Typst v0.11.1 documentation by the Japanese Community. Please note that there may be some inaccuracies, untranslated sections or outdated information. We highly recommend referring to the latest official documentation as well. If you find any errors in the content, please let us know through our GitHub repository. If you are interested in our community, feel free to join our unofficial Discord server, “Kumihan Club.”
Typst ドキュメント日本語版

length

A size or distance, possibly expressed with contextual units.

Typst supports the following length units:

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

Definitions
Functions and types and can have associated definitions. These are accessed by specifying the function or type, followed by a period, and then the definition's name.

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(
) -> float

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(
) -> float

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(
) -> float

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(
) -> float

to-absolute

Resolve this length to an absolute length.

self.to-absolute(
) -> length
View example
#set text(size: 12pt)
#context [
  #(6pt).to-absolute() \
  #(6pt + 10em).to-absolute() \
  #(10em).to-absolute()
]

#set text(size: 6pt)
#context [
  #(6pt).to-absolute() \
  #(6pt + 10em).to-absolute() \
  #(10em).to-absolute()
]
Preview