How to add a negative space between symbols in math mode?

In theory you could create a function like this: #let ! = h(-2pt) and anywhere you want a negative space you would write #!(). However, this doesn’t work.
See this forum post by xkevio for the variable naming rules in Typst.

You can use @quachpas’ solution and replace the ! in the show rule with any single character that you know won’t be found in any of your equations:

#show math.equation: it => {
  show "ü": h(-2pt)
  it
}
${{ A!, B, C }}$\
${ü{ A!, B, C }ü}$\
${ü ü{ A!, B, C }ü ü}$
Output

image

Or you could use a function.

Using a Function

It’s not as clean but you can define a function with a short name (here ns for negative space):

#let ns = h.with(-2pt)
${#ns()#ns(){ A!, B!, C! }#ns()#ns()}$

The .with() basically asks the compiler "please create a function that calls h() with these given arguments. This new function is stored with the name ns.

2 Likes