mathtools icon indicating copy to clipboard operation
mathtools copied to clipboard

[Feature proposal] Left aligned stackrel

Open FelixBenning opened this issue 2 years ago • 4 comments

The following

\documentclass{article}
\usepackage{mathtools}
\begin{document}
    \begin{align}
    	&\text{First Statement}\\
    	&\implies \text{Second Statement}\\
    	&\stackrel{\text{Explanation}}{\implies}\text{Third Statement}\\
        &\stackrel{\mathclap{\text{Explanation}}}{\implies} \text{Fourth Statement}
\end{align}
\end{document}

compiles to

misaligned implications

The solution I ended up building for this looks like this:

\newcommand*{\lstackrel}[2]{ %uses leftsides smashoperator thus ignoring overlap towards the left
        \mathrel{% makes the resulting stack a relation class (like =,<,>,...)
		\smashoperator[l]{\mathop{#2}^{#1}}
        }
}% use when aligning to the left

where \lstackrel{\text{explanation}}{=} aligns the equal sign towards the left.

FelixBenning avatar Mar 09 '22 13:03 FelixBenning

You can use the aligned-overset package for this which also ensures that it never overlaps with any potential content on the left:

\documentclass{article}
\usepackage{aligned-overset}
\begin{document}
\begin{align}
  &\text{First Statement}\\
  &\implies \text{Second Statement}\\
  \overset{\text{Explanation}}&{\implies} \text{Third Statement}\\
  \overset{\text{Explanation}}&{\implies} \text{Fourth Statement}
\end{align}
\end{document}

zauguin avatar Mar 09 '22 16:03 zauguin

Amazing! Could this relatively unknown package become part of mathtools, or perhaps be mentioned in the documentation?

blefloch avatar Mar 09 '22 17:03 blefloch

@blefloch Sorry, I missed your comment. I wouldn't mind merging it into mathtools if @daleif is happy with that.

zauguin avatar Mar 26 '22 16:03 zauguin

I think the only problem about a merge is that even thoug it might seem so, mathtools is not written in expl3 (Morten made a self contained variant of it before expl3 was consolitated or something like that).

I'm currently unsure as to which direction to go with mathtools, either convert it into expl3 (which can cause issues for those who update manually), or leave it as it is now (I'm not particularly well versed in expl3 programming, or Mortens setup for that matter)

daleif avatar Mar 28 '22 07:03 daleif