I am having hard time finding how to do In Typst what in LaTeX can be done with \newcommand with parameters. Are there examples online of custom shorthand notations with parameters that work in math and text mode? Did I miss a documentation section about this?
Say, I want to use a “macro” with a parameter to simplify
If you want to only pass in a single argument, I suppose you can pass in an equation:
$intervaloo( #$0, infinity$ )$
But to be clear, arguments are separated by commas in typst (unlike wrapping each of them in {...} as in LaTeX). If you want to avoid unnecessary overhead when calling your function, I’d suggest using the argument sink as shown above.
I don’t know if the #$...$ is explicitly mentioned in the documentation, but the hash prefix can be used in non-code mode to add expressions, which in addition to functions can also be content blocks such as #[Hello world!] or equations #$x^2$ (see also the “blocks” section in the link above).
Well, sure. If you really feel this way, semantically the correct choice would be to escape the commas (or define a variable to use instead of commas #let sep = $,$.body), since to me it makes even less sense to have equations inside of equations. But, if you’re happy with this then okay.