情報アイコン
情報 / Info
当サイトは、Typst GmbHの許諾を得て、日本語コミュニティ「Typst Japan Community」がTypst v0.13.1の公式ドキュメントを翻訳したものです。誤訳や古い情報が含まれている可能性があるため、公式ドキュメントとの併用を推奨します。翻訳の改善やサイトの機能向上について、GitHubでのIssueやPull Requestを歓迎します。コミュニティにご興味のある方はDiscordサーバー「くみはんクラブ」にぜひご参加ください。
This site provides a Japanese translation of the Typst v0.13.1 documentation maintained by the "Typst Japan 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 Discord server "Kumihan Club".
言語アイコン
未翻訳

このページはまだ翻訳されていません。原文の内容が表示されています。

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 until Typst 0.14 to give package authors time to upgrade.

  • Checks like int == "integer" evaluate to true
  • Adding/joining a type and string will yield a string
  • The in operator on a type and a dictionary will evaluate to true if the dictionary has a string key matching the type's name

コンストラクタ
ヘルプアイコン

Determines a value's type.

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

value
any
Required
ヘルプアイコン
Positional
ヘルプアイコン

The value whose type's to determine.

検索