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

type

Describes a kind of value.

To style your document, you need to work with values of different kinds: Lengths specifying the size of your elements, colors for your text and shapes, and more. Typst categorizes these into clearly defined types and tells you where it expects which type of value.

Apart from basic types for numeric values and typical types known from programming languages, Typst provides a special type for content. A value of this type can hold anything that you can enter into your document: Text, elements like headings and shapes, and style information.

Example

#let x = 10
#if type(x) == int [
  #x is an integer!
] else [
  #x is another value...
]

An image is of type
#type(image("glacier.jpg")).
Preview

The type of 10 is int. Now, what is the type of int or even type?

#type(int) \
#type(type)
Preview

Compatibility

In Typst 0.7 and lower, the type function returned a string instead of a type. Compatibility with the old way will remain for a while to give package authors time to upgrade, but it will be removed at some point.

Constructor
If a type has a constructor, you can call it like a function to create a new value of the type.

Determines a value's type.

type() -> type
#type(12) \
#type(14.7) \
#type("hello") \
#type(<glacier>) \
#type([Hi]) \
#type(x => x + 1) \
#type(type)
Preview

value
any
RequiredPositional
Positional parameters are specified in order, without names.

The value whose type's to determine.