Math & ScienceAligning relation symbols in align*

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
crossdressingrodney
Posts: 2
Joined: Thu Feb 05, 2009 5:06 pm

Aligning relation symbols in align*

Post by crossdressingrodney »

Hi,

I have recently abandoned eqnarray* in favour of align*, which solved many problems, including some I hadn't realised I was suffering from. However, there's one feature of eqnarray* which doesn't seem to exist in align*.

If I want to put some text, say "Lemma 1", over an equals sign using \overset in a multiline equation display, the equals signs do not line up, e.g.

Code: Select all

\usepackage{amsmath}

\begin{document}
\begin{align*}
   A&\overset{\text{Lemma }1}{=}B\\
    &=C
\end{align*}
\end{document}
I can make the B and C line up using alignat:

Code: Select all

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{alignat*}{2}
   A&\overset{\text{Lemma }1}{=}&B\\
    &=&C
\end{alignat*}
\end{document}
but the equals signs are still wonky. This was not a problem in eqnarray, since the equals signs were sandwiched between two alignment tabs, and were centrally aligned, i.e.

Code: Select all

\documentclass{article}

\begin{document}
\begin{eqnarray*}
   A&\overset{\text{Lemma }1}{=}&B\\
    &=&C
\end{eqnarray*}
\end{document}
but with the trademark extra spacing around the equals sign.

gmedina already suggested I could manually fix the horizontal spacing each time this appears, but that would be a right pain in the bottom.

Any suggestions how to do this automatically?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Aligning relation symbols in align*

Post by localghost »

I suggest to take a look at the "Math mode" document. It presents a solution to that issue.


Best regards and welcome to the board
Thorsten¹
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Aligning relation symbols in align*

Post by phi »

Use \stackrel to build a compound relational operator and \mathclap (from the mathtools package) to shrink the box:

Code: Select all

&\stackrel{\mathclap{\text{Lemma 1}}}{=}
If necessary, add manual space after the operator using \,, \:, \;, \quad or \qquad.
daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

Re: Aligning relation symbols in align*

Post by daleif »

it is a bad syntax for something written on paper anyway, might be fine on a blackboard, but does not belong in writing. Use text before or after instead, or use comments inside the align using \intertext or \shortintertext (mathtools)
crossdressingrodney
Posts: 2
Joined: Thu Feb 05, 2009 5:06 pm

Re: Aligning relation symbols in align*

Post by crossdressingrodney »

Thanks for the replies, and for the welcome.

In reply to localghost: I had looked through the section on align* and its friends already, but hadn't found a solution. I should probably add the Math Mode document to my badtime-reading list.

In reply to phi: Aha! A friend suggested trying \smash yesterday, and it looks like \mathclap with \stackrel is a better solution.

In reply to daleif: OK, I did wonder why I couldn't find this specific problem anywhere.

Thanks for all your help.

CDR
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Aligning relation symbols in align*

Post by localghost »

crossdressingrodney wrote:[...] I had looked through the section on align* and its friends already, but hadn't found a solution. I should probably add the Math Mode document to my badtime-reading list. [...]
The "Math mode" document also suggests the \mathclap command, but in the context of operators (Section 35 - Limits, p. 62ff).
Post Reply