Why does the cancel function have a # in front of the parameters?

When I use the cancel function I notice that I need to put the # character in front of the parameters for the document to work.

$
cancel(x, length: #150%, angle: #40deg)
$

However this is not necessary with other functions, for example

#line(length: 20%, angle: 45deg)

While I can use both of these functions fine by looking at the examples in the documentation I was wondering what is the internal logic behind this?

1 Like

Because you are using the math mode which has different syntax from the code mode (and the accessible in-scope functions and stuff are different), which results in occasional more narrow code mode switches for argument values like ratios, lengths, degrees, etc.

This is already documented: https://typst.app/docs/reference/math/#function-calls.

1 Like