2

How do you vertically align equality signs when one of them has some text underset? My solution is:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[american]{babel}

\usepackage{amsmath}

\begin{document}
\begin{align*}
  a &\underset{\text{explanation}}{=} b + c\\
  d &\underset{\phantom{\text{explanation}}}{=} e + f + d
\end{align*}
\end{document}

However, that's not very elegant especially when several \underset are involved.

1
  • Are you actually referring to horizontal alignment?
    – Werner
    Apr 18 '12 at 22:48
2

The result is not particularly pleasing. If you don't need equation numbers, then an array can do:

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[american]{babel}

\usepackage{amsmath,array}

\begin{document}
\begin{align*}
  a &\underset{\text{explanation}}{=} b + c\\
  d &\underset{\phantom{\text{explanation}}}{=} e + f + d
\end{align*}

\[
\renewcommand{\arraystretch}{1.5}\setlength{\arraycolsep}{0pt}
\begin{array}{r >{{}}c<{{}} l}
  a &\underset{\text{explanation}}{=} & b + c\\
  d &= & e + f + d
\end{array}
\]
\end{document}

Top your code, bottom mine:

enter image description here

3
  • Thanks for your help. Equation numbers would be nice to have. But I see, it's not trivial. I just tried to work with alignat but couldn't find a solution. Another solution is to use \mathclap around the text, but then of course the word extends over the left- and right-hand side -- which is ugly, too. Apr 19 '12 at 5:43
  • @MariusHofert I really would try a different way; usually the explanation is set to the side of the formula.
    – egreg
    Apr 19 '12 at 7:43
  • What if you have several equations in a line (because they are short and you don't want to waste space -- as on slides, for example), but you want to address a specific equation? (the problem came up like this on the slides I use to teach). But thanks, anyway. Apr 19 '12 at 11:31
-1

I use \stackrel to put text above arrows and stuff. I confess that I'm not sure, but I think it's part of the amsmath package. Try

$\stackrel{-\frac{1}{6} R_3}{\longrightarrow}$

Maybe this helps.

2
  • does it or not? what a strange answer!
    – peter
    Nov 26 '20 at 18:32
  • it does not. it's apparently a known issue of align that it can't handle relation symbols of different sizes. note also that your suggestion writes something over the arrow instead of under.
    – peter
    Nov 26 '20 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.