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

eval

Evaluates a string as Typst code.

This function should only be used as a last resort.

Example

#eval("1 + 1") \
#eval("(1, 2, 3, 4)").len() \
#eval("*Markup!*", mode: "markup") \
Preview

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

source
str
RequiredPositional
Positional parameters are specified in order, without names.

A string of Typst code to evaluate.

mode
str

The syntactical mode in which the string is parsed.

Default:"code"

View example
#eval("= Heading", mode: "markup")
#eval("1_2^3", mode: "math")
Preview

scope

A scope of definitions that are made available.

Default:(:)

View example
#eval("x + 1", scope: (x: 2)) \
#eval(
  "abc/xyz",
  mode: "math",
  scope: (
    abc: $a + b + c$,
    xyz: $x + y + z$,
  ),
)
Preview