Aligned Overset
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.9k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
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}
$$
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing MathJax's current overset and underset behavior with the aligned-overset package linked in the issue, focusing on the align environment and placement of the alignment marker. Confirm the desired syntax, including \overset{x\perp y}\u0026{=}, and verify that the annotation no longer disrupts equation alignment across the examples shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, latex
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100