Skip to content

Aligned Overset #3367

Open
Open
@FelixBenning

Description

@FelixBenning

Is your feature request related to a problem? Please describe.

It is often nice to write something over the equal sign of an equation, perhaps a reference to a theorem, another equation, etc. which justifies a particular equality. This is what the \overset command accomplishes. When the equal signs are aligned however, then the notes above the equal sign mess with the alignment.
For example:

$$ \begin{align} \|x-y\|^2 &= \|x\|^2 + 2\langle x,y\rangle + \|y\|^2 \\ &\overset{x\perp y}= \|x\|^2 + \|y\|^2 \end{align} $$

\begin{align}
\|x-y\|^2
&= \|x\|^2 + 2\langle x,y\rangle + \|y\|^2
\\
&\overset{x\perp y}= \|x\|^2 + \|y\|^2
\end{align}

In LaTeX there is this wonderful package aligned-overset that fixes this problem by allowing the alignment & to be placed within the overset, i.e. \overset{x\perp y}&{=} is valid. The & then causes alignment on the second argument of overset.

Describe the solution you'd like

In my notes I started to heavily rely on this LaTeX feature and would be delighted if Mathjax would offer something similar. The package aligned-overset is extremely small. The overset and underset implementation are each only a single page, copied into the documentation.

Describe alternatives you've considered
Manual mathclaps or mathllaps can often work. But this is a lot of manual fiddling. It also means that I cannot use the same code for mathjax as for LaTeX

e.g. here I use mathclap

$$ \begin{align} \|x-y\|^2 &= \|x\|^2 + 2\langle x,y\rangle + \|y\|^2 \\ &\overset{\mathclap{x\perp y}}= \|x\|^2 + \|y\|^2 \end{align} $$

\begin{align}
\|x-y\|^2
&= \|x\|^2 + 2\langle x,y\rangle + \|y\|^2
\\
&\overset{\mathclap{x\perp y}}= \|x\|^2 + \|y\|^2
\end{align}

observe that this causes the elements on the right of the equation to creep towards the equal sign. If the content is wider you have to add phantoms. mathllap actually works worse:

$$ \begin{align} \|x-y\|^2 &= \|x\|^2 + 2\langle x,y\rangle + \|y\|^2 \\ &\overset{\mathllap{x\perp y}}= \|x\|^2 + \|y\|^2 \end{align} $$

Metadata

Metadata

Assignees

No one assigned

    Labels

    Code ExampleContains an illustrative code example, solution, or work-aroundFeature Request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions