注意 当サイトは、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 ドキュメント日本語版

measure

Measures the layouted size of content.

The measure function lets you determine the layouted size of content. Note that an infinite space is assumed, therefore the measured height/width may not necessarily match the final height/width of the measured content. If you want to measure in the current layout dimensions, you can combine measure and layout.

Example

The same content can have a different size depending on the context that it is placed into. For example, in the example below #content is of course bigger when we increase the font size.

#let content = [Hello!]
#content
#set text(14pt)
#content
Preview

For this reason, you can only measure when context is available.

#let thing(body) = context {
  let size = measure(body)
  [Width of "#body" is #size.width]
}

#thing[Hey] \
#thing[Welcome]
Preview

The measure function returns a dictionary with the entries width and height, both of type length.

Parameters
Parameters are the inputs to a function. They are specified in parentheses after the function name.

content
content
RequiredPositional
Positional parameters are specified in order, without names.

The content whose size to measure.

styles
none styles
Positional
Positional parameters are specified in order, without names.

Compatibility: This argument only exists for compatibility with Typst 0.10 and lower and shouldn't be used anymore.

Default:none