On writing inline math $ like this $ (with the spaces)

When writing LaTeX, I’m used to putting a space between the dollars signs and the math, like this: $ \sum_{i = 1}^n i $ (notice the two spaces). I particularly dislike writing $\sum_{i = 1}^n i$ (without spaces). I find it unnecessarily confusing.

In Typst, however, the first expression is interpreted as display math, and the second one as inline math. Is it possible to modify this behavior?

As far sa I know you can’t do this “automatically”, i.e. by show/set rules. Maybe it’s possible to somehow detect if you’re writing from within a paragraph and set a show rule for math equations, but I couldn’t figure this out.

If you’re okay with a bit of overhead, you could wrap your equations inside a function that sets your equation to be inline regardless of the spaces:

#let m = math.equation.with(block: false)

We see that #m($ sum_(i = 1)^n i $) is a sum
1 Like