It seems like most of the time any Typst command requires parentheses after it, even if the parentheses are empty, as in #pagebreak(). I actually think I remember reading that in the documentation. However, the touying package includes commands like #pause and #meanwhile, which don’t need parentheses. Why not? What’s the difference?
Those are not commands per se. They are variables that may contain a constant, such as a marker, or even a function.
This is easy to do yourself if you’d like. As an example:
#let take-a-break = pagebreak()
#lorem(5)
#take-a-break
#lorem(5)
The reason it works is because, unlike in a lot of programming languages, the call to pagebreak() is not made when the variable is defined. The variable is evaluated by the compiler in each place that it appears in the document. This is to take into account the context surrounding where the variable appears. So when the variable appears in the document the compiler recalls its definition and “executes” whatever is stored there. In this case it calls pagebreak() which has the desired effect.
Edit: @ensko details below why my explanation is incorrect. Thanks for the correction and the additional info!
That’s not accurate; Typst is pure but not lazy. Consider this:
#let lets-panic = panic()
// note that lets-panic is never used
#lorem(5)
This code panics, so it proves that the call was made eagerly.
What is true though is that 1) it’s not the function call that results in the pagebreak; instead the return value is an element, and that element can be inserted into the document zero or more times. And 2) there are context expressions which are evaluated only when (and as often as*) inserted into the document:
#let lets-panic = context panic()
#lorem(5)
// #lets-panic // unless this is uncommented, the document compiles
#lorem(5)
*actually, context expression usually evaluate more than once, because the Typst compiler performs multiple iterations until the document “converges”. But only the result of the last iteration actually ends up in the document.
