Is there a way to write the same show rule for multiple symbols at once?

I like increasing spacing around equals signs and proportional signs. So far, I’ve done that like this:

#show math.prop: it => [#h(10pt) #it #h(10pt)]
#show math.eq: it => [#h(10pt) #it #h(10pt)]

Any way I could do both at once? I would like to avoid repeated code. I believe using a for loop would limit the scope of the show rules to inside the loop.

I’m far from the math typesetting, but here are my 3 thoughts on this. First solution is a simple extraction of the repetitive part:

#let math-space(body) = [#h(10pt) #body #h(10pt)]
#show math.prop: math-space
#show math.eq: math-space
$a prop b$ \
$a eq b$

If you want to remove multiple show rules:

#show math.equation: it => {
  // import sym: *
  // or
  import math: *
  let symbols = (eq, prop)
  show regex("[" + symbols.join() + "]"): it => [#h(10pt) #it #h(10pt)]
  it
}
$a prop b$ \
$a eq b$

But from the docs these symbols are classified as “relation” class, so I assume that using custom spacing around the symbol can result in pure typesetting, which I assume can be fixed by wrapping it in the appropriate class:

#show math.prop: it => math.class("relation")[#h(10pt) #it #h(10pt)]
#show math.eq: it => math.class("relation")[#h(10pt) #it #h(10pt)]
$a prop b$ \
$a eq b$

Which does in fact increase the spacing even more than without it.

But that’s about it from me.

1 Like