Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Look at the following example

\begin{align}
     & x \\
     \overset{\text{some long explanation}}= & foo \\
     & = bar
\end{align}

what is the best way to get the equal signs aligned? Now I have seen different solution such as adding \overset{\hphantom{\ţext{some long explanation}}}= to the beginning of every line, but I don't really think that is the best solution. Any better ideas?


UPDATE

I guess what i am actually after is

  1. aligning the first column of the align environment right
  2. aligning the equal sign under the overset text right
share|improve this question
1  
Please correct your current code snippet, since I assume you're after some horizontal alignment. You just mention "align" but provide a horizontally set align. At the moment it's not entire clear what you're after. –  Werner Jan 7 '12 at 15:50
    
yes. I guess what you mean where the missing \\s? –  niklasfi Jan 7 '12 at 16:18
    
If you modify \mathclap in Herbert's answer to \mathllap, you get something more in line with what you're after. If this is still not the case, could you include an ASCII art (or some other drawing/image) of the exact alignment you're after? –  Werner Jan 7 '12 at 17:09
add comment

2 Answers

\documentclass{article}
\usepackage{mathtools}
\begin{document}

\begin{align}
  x & \\
    &\overset{\mathclap{\strut\text{some long explanation}}}= foo\\
    & = bar
\end{align}

\end{document}
share|improve this answer
1  
this leads to some long text floating into the formula after the equal sign –  niklasfi Jan 7 '12 at 16:39
1  
I find \strut to be unrelated with the problem, plus it creates some unwanted vertical space. \mathclap alone seems to be sufficient to solve the issue. –  Raphael Oct 10 '13 at 14:40
    
You only want to ignore the left overlapping part of the some long text for the align environment while properly aligning the following text foo according to standard math-alignment rules. This has not been answered here. –  Jost Oct 17 '13 at 14:06
add comment

you say you don't want to repeat "some long explanation", but there really isn't any better way to do it that i know of.

is this what you're after?

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
 x &\overset{\text{some long explanation}}= foo \\
   &\overset{\phantom{\text{some long explanation}}}= bar
\end{align}
\end{document}
share|improve this answer
    
Thanks, this works for me, but it is not very neat. –  quapka yesterday
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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