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") \

ParameterParameterParameters are input values for functions. Specify them in parentheses after the function name.
Parameter
Parameters are input values for functions. Specify them in parentheses after the function name.
eval(,mode:,)->anysourceRequiredRequiredRequired parameters must be specified when calling the function.PositionalPositionalPositional parameters can be set by specifying them in order, omitting the parameter name.
sourceRequired
Required
Required parameters must be specified when calling the function.
Positional
Positional
Positional parameters can be set by specifying them in order, omitting the parameter name.
A string of Typst code to evaluate.
mode
modeThe syntactical mode in which the string is parsed.
Show example
#eval("= Heading", mode: "markup")
#eval("1_2^3", mode: "math")

Available string values
markupEvaluate as markup, as in a Typst file.
mathEvaluate as math, as in an equation.
codeEvaluate as code, as after a hash.
Default value:
"code"scope
scopeA scope of definitions that are made available.
Show example
#eval("x + 1", scope: (x: 2)) \
#eval(
  "abc/xyz",
  mode: "math",
  scope: (
    abc: $a + b + c$,
    xyz: $x + y + z$,
  ),
)

Default value:
(:)