How to add more horizontal spacing in formulas when not using commas?

I have a number of Typst math formulas, which use exists and forall heavily:

$ forall K in RR exists N forall n >= N x_n > K $

The problem is, the resulting formula ends squashed together with little spacing around those characters, making it illegible:

image

Is there a way to increase spacing automatically, without littering the formulas with quad and such?

I could add a show rule:

#show sym.forall: it => h(0.5em) + it
#show sym.exists: it => h(0.5em) + it

Or redefine the elements manually:

#let forall = math.class("normal", h(0.5em) + sym.forall)
#let exists = math.class("normal", h(0.5em) + sym.exists)

But I was wondering if there’s a way which scales for more symbols and also doesn’t add spacing if the symbol is first in a formula

In this specific example, adding commas might be better?

$ forall K in RR, exists N, forall n >= N, x_n > K. $

You could set weak: false to h(…).

#let forall = h(0.5em, weak: true) + sym.forall

|$forall n$|

|$A forall n$|

In fact this is the trick in dif:

#repr($dif$)
equation(
  block: false,
  body: sequence(
    h(amount: 0.17em, weak: true),
    styled(child: [d], ..),
  ),
)

Thanks! The weak option solves the issue and is exactly what I was thinking about.

I thought about using commas, but I like the comma-less style more purely aesthetically

Fine, that’s your choice. However, I still suggest adding the comma in ∀ n >= N, x_n > K, or it will become ambiguous in more complex cases: ∀ n >= N k x_n > K means ∀ n >= N k, x_n > K or ∀ n >= N, k x_n > K?

So, after thinking some more about it, I think you are right. I’ve settled on this style:

forall K in RR, exists N : forall n >= N, x_n < K

I think my issue with the commas when I used them everywhere was that they meant both “and” and “such that”, and using the colon instead fixes this.

1 Like