注意 当サイトは、Typst v0.12.0 公式ドキュメントを、日本語コミュニティが非公式に翻訳したものです。誤訳・未訳・古い情報が含まれている可能性があるため、公式ドキュメント との併用を推奨します。このサイトの内容に誤りを発見された方は、GitHubリポジトリまでご報告を頂けましたら幸いです。我々のコミュニティにご興味のある方は、ぜひ非公式Discordサーバー「くみはんクラブ」にご参加ください。
Warning: This site provides an unofficial translation of the Typst v0.12.0 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. By default an infinite space is assumed, so the measured dimensions may not necessarily match the final dimensions of the 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. In the example below, the #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.

width

The width available to layout the content.

Setting this to auto indicates infinite available width.

Note that using the width and height parameters of this function is different from measuring a sized block containing the content. In the following example, the former will get the dimensions of the inner content instead of the dimensions of the block.

Default:auto

View example
#context measure(lorem(100), width: 400pt)

#context measure(block(lorem(100), width: 400pt))
Preview

height

The height available to layout the content.

Setting this to auto indicates infinite available height.

Default:auto

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 is deprecated. It only exists for compatibility with Typst 0.10 and lower and shouldn't be used anymore.

Default:none