How to properly align symbols in math mode When limits() function is used?

As a minimal example of what I’m referring to, consider:

#let dd = math.upright("d")
#let Re = math.upright("Re")

#math.equation(block: true, numbering: none, $
    integral_(RR^(1, d - 1)) frac(1, (l_(E)^(2) + m^(2))^(A)) frac(dd^(d) l_(E), (2 pi)^(d)) &= 1/(Gamma(A)) integral_(RR^(1, d - 1)) integral_(0)^(infinity) s^(A - 1) e^(-s(l_(E)^(2) + m^(2))) dd s thin frac(dd^(d) l_(E), (2 pi)^(d)) \
    &limits(=)^(Re(d) > 0) (2 pi^(d/2))/(Gamma(A) (2 pi)^(d) thin Gamma(d/2)) Gamma(d/2)/2 integral_(0)^(infinity) s^(A - 1) e^(-s m^(2)) s^(-d/2) dd s \
$)

If one renders this example calculation, one will find that the alignment in the line with “&limits(=)^(Re(d) > 0)” will align the start of the text with the start of the other equalities, and similarly for the next line. Is there a way to ensure the alignment always works with the equality and not the superscripts?

I tried moving the “&” inside the limits(), but that didn’t work for me.

Your minimal example doesn’t compile, it’s also very big for what you are asking. See https://sscce.org/. And you don’t need the limits call. You can open an issue for this, as I don’t see any native solution.

Here is a hack:

#show math.attach: it => {
  let attachments = it.fields()
  let base = attachments.remove("base")
  if base != $=$.body { return it }
  let top = attachments.remove("t")
  if not attachments.values().all(x => x == none) { return it }
  top = $script(top)$
  base
  context {
    let width = measure(top).width
    let space = measure(" ").width

    // place(dx: -space * 2 - width / 2, dy: -1.15em, top)

    place(dx: -space - width / 2, dy: -1.15em, top)
    h(width / 2)
  }
}
Full example
#set math.equation(numbering: "(1)")

#let dd = math.upright("d")
#let Re = $upright("Re")$

#show math.attach: it => {
  let attachments = it.fields()
  let base = attachments.remove("base")
  if base != $=$.body { return it }
  let top = attachments.remove("t")
  if not attachments.values().all(x => x == none) { return it }
  base
  top = $script(top)$
  context {
    let width = measure(top).width
    let w = measure(" ").width

    // place(dx: -w * 2 - width / 2, dy: -1.15em, top)

    place(dx: -w - width / 2, dy: -1.15em, top)
    h(width / 2)
  }
}

#[
  #set math.equation(numbering: none)
  $
    integral_(RR^(1, d - 1)) frac(1, (l_E^2 + m^2)^A) frac(dd^d l_E, (2 pi)^d)
    &= 1 / Gamma(A) integral_(RR^(1, d - 1)) integral_0^oo s^(A - 1) e^(-s(l_E^2 + m^2)) dd s thin frac(dd^d l_E, (2 pi)^d) \
    &=^(Re(d) > 0) (2 pi^(d / 2)) / (Gamma(A) (2 pi)^d thin Gamma(d / 2)) Gamma(d / 2) / 2 integral_0^oo s^(A - 1) e^(-s m^2) s^(-d / 2) dd s \
  $
]

image


Thank you. And I fixed the original post, including the missing #let dd command and cutting down on the example size.

1 Like

Nice. I don’t know if you’ve noticed it, but you also don’t need the countless parentheses around simple super-/subscript values. You shouldn’t overcomplicate an already complex expression. You can also move out repetitive chunks and name them. If the name is short and descriptive, then it should improve overall readability.

I am aware regarding the parentheses. I’ve always just included the extra from the outset, since I find myself regularly enough needing to go back and add more to the subscripts, requiring the parentheses anyways. I think of it as saving time up front, but as I get better, I’ll probably work on anticipating when I really need them.