12

I want to typeset a number of equations with some alignment constraints, but I want to partially ignore them on certain lines. An example formatted text might look like the following when it's formatted

really really really long equation = a
      a = b                      b = c
      c = d                      d = e

where the equals signs in each column are aligned, but the top line ignores the first column of alignment. This is essentially the same question as Ignoring alignment for certain lines in an alignat environment, but that question wasn't answered satisfactorily.

The two naive ways both produce undesirable results.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
  && \text{really really really long equation} &= a \\
  a &= b & b &= c
\end{align*}


or
\begin{align*}
  \text{really really really long equation} &= a \\
  a &= b & b &= c
\end{align*}

\end{document}
  • 1
    Welcome to TeX.SX! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Henri Menke May 21 '13 at 21:44
  • try \llap{...} possibly combined with $...$ as the contents of \llap is text mode add to the first align* attempt. – daleif May 21 '13 at 21:58
  • 1
    if you \usepackage{mathtools} you can use \mathllap{...}. it would work nicely in this situation. – barbara beeton May 21 '13 at 22:06
  • @barbarabeeton Madam, just to know is there any work to be done to incorporate mathtools like bundle into amsmath ?. – texenthusiast May 21 '13 at 22:14
  • 2
    @texenthusiast -- there are a number of items on the "to be considered" list for amsmath that come from mathtools. however, the much-needed upgrade of amsmath has been put off repeatedly, and is not yet firmly scheduled. other priorities have arisen, and the ams staff is not large enough to handle all the demands. – barbara beeton May 22 '13 at 14:32
13

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align}
&& \llap{$\displaystyle \sum_0^7 x-(1+2+3+4+5+6+7)$} &= 0\\
      a& = b &                     b &= c\\
      c& = d  &                    d &= e
\end{align}

\end{document}
  • 2
    If you want the equals sign on the left of the long expression, use \rlap instead of \llap. – wkschwartz Apr 11 '16 at 17:17
6

Use \span to merge cells. You need one \span per & you want to ignore. For example, your sample output could be produced like this:

\begin{align*}
  \text{really really really long equation} \span \span &= a \\ 
  a &= b & b &= c \\
  c &= d & d &= e
\end{align*}
  • Span produced some odd alignment when I tried it. It wasn't centered anymore, and the shorter equations were left aligned with the long one. – Erik Apr 28 '16 at 16:25

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.