How to make oversetting work with alignment

I have the following code:

  $
    0 < 1/omega(G) = &1 + min {-x^T A x | e^T x = 1, x >= 0_n} \
    = &min {(e^T x)^T (e^T x) - x^T A x | e^T x = 1, x >= 0_n} \
    = &min {x^T (E - A_G) x | e^T x = 1, x >= 0_n} \
    =^#text[@4.7_satz] &min {angled(E - A_G, X) | angled(E, X) = 1, X in C_comp} \
    =^#text[@-4.7-] &min {y in RR | (E - A_G) - y E in C_kop, y > 0} \
    = &max {lr(1/lambda in RR |) (E - A_G) - 1/lambda E in C_kop, lambda > 0} \
    = &max {lr(1/lambda in RR |)lambda(E - A_G) - E in C_kop, lambda > 0} \
    => omega(G) = &min {lambda in RR | lambda(E - A_G) - E in C_kop, lambda > 0}
  $

The problem is that it looks like this

How can I align stuff with oversets correctly?

1 Like

The width of the oversetted relator is the max of itself and the overset text. So just force the overset to have no width: replace #text[@4.7_satz] with #box(width: 0pt)[@4.7_satz]

(note that text doesn’t do anything, #[@4.7_satz] would have been enough. so adding box is what you need; it’s not critical that I got rid of text at the same time)

You can further add baseline: -3pt or something in that direction to your box, to not make the collision with the min so egregious.

Wow, that is simple. I was just going to post a solution where the oversetting is ignored using place, and, because aligning that easily breaks, the equal sign is inside the place, but there is also hidden equal sign outside to make space.

&#box[#hide($=$)#place(bottom + center, $=^#[@4.7_satz]$)]

Why doesn’t & for alignment work inside a function argument? I think that the simplest way would be attach(limits(&=), t: #[@4.7_satz]), but it does not work. More simply, it would be (&=)^#[@4.7_satz], but, for that, parentheses would need to be ignored for displaying.

Unforunately, this removes the background (it seems that is tied to the width) and moves the text itself to the right

I can’t reproduce that with the code you showed (which doesn’t do any highlighting). This works as expected:

#set math.equation(numbering: "(1)")

#set highlight(radius: 2pt, fill: fuchsia.desaturate(70%), extent: 1pt)
#show ref: highlight

$ 1+1 = 2 $ <foo>

$
  a = &b \
    =^#box(width: 0pt, baseline: -3pt)[@foo] &c
$

Are you using any template that may be interfering?

Maybe I didn’t test what you meant, but &=^... works for me it seems.

it seems to do something so it’s not completely ignored, but I can’t interpret what exactly it’s doing…

I used a box for highlighting, not a box. Now the color works.

The problem is that my equations are aligned to the left, but I can solve that by aligning it in the center manually in the equations.

#box(width: 0pt)[#align(center)[@4.7_satz #v(3pt)]] 

worked in the end.

1 Like

The problem which I meant is that the parentheses are displayed, and they are just to syntactically group the &=. Without them, the & applies also to the oversetting, not just the = By that they need to be ignored, I meant that they need to be hidden. In LATEX, {, } are only to syntactically group, never displayed. Typst needs something similar in math.