2

I have something like this:

\begin{align}
 a &= b+c & d &=e+f & g &=h+i\\
 a &= b+c & d &=e+f & g &=h+i\\
 %%%%%
 a+h+q &= b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s+t\\
       &\quad +u+x+y+w+z
 %%%%%
 \\
 a &= b+c & d &=e+f & g &=h+i \\
 \end{align}

I am trying to align the third equation with each others at the first 'column' and to span it throught consecutive & as I do with \multicolumn in a tabular environment.

Some attempts

One

I have tried with tabular and multicolumn:

\begin{align}
\setlength{\tabcolsep}{0pt}
\begin{tabular}{>{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$}}
    \phantom{a+h+q}a &\,= b+c &\qquad d &\,=e+f &\qquad g &\,=h+i\\
    \phantom{a+h+q}a &\,= b+c &\qquad d &\,=e+f &\qquad g &\,=h+i\\
    \multicolumn{6}{>{$}l<{$}}{\,\,a+h+q = b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q}\\
      & \multicolumn{5}{>{$}l<{$}}{\quad +r+s+t+u+x+y+w+z}\\
    \phantom{a+h+q}a &\,= b+c &\qquad d &\,=e+f &\qquad g &\,=h+i  
\end{tabular} \notag\\
\end{align}

Figure 1

\begin{equation*}
\setlength{\tabcolsep}{0pt}
\begin{tabular}{>{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}r<{$}}
    \phantom{a+h+q}a &\,= b+c &\qquad d &\,=e+f &\qquad g &\,=h+i &\quad  (2)\\
    \phantom{a+h+q}a &\,= b+c &\qquad d &\,=e+f &\qquad g &\,=h+i &  \quad (3)\\
    \multicolumn{6}{>{$}l<{$}}{\,\,a+h+q = b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q}& \\
      & \multicolumn{5}{>{$}l<{$}}{\quad +r+s+t+u+x+y+w+z}  & \quad (4) \\
    \phantom{a+h+q}a &\,= b+c &\qquad d &\,=e+f &\qquad g &\,=h+i  & \quad (5)
\end{tabular}
\end{equation*}

Figure 2

Two

I have tried with TikZ and tikzlibrary fit and matrix:

\begin{equation*}
    \begin{tikzpicture}
    \matrix (table) [matrix of math nodes, nodes in empty cells, row sep=.25em, column sep=0em]{%
        \phantom{a+h+q}a  &=& b+c &\qquad d &=& e+f &\qquad g &=& h+1 &\node[xshift=8.5em]{(6)};\\
        \phantom{a+h+q}a  &=& b+c &\qquad d &=& e+f &\qquad g &=& h+1 & \node[xshift=8.5em]{(7)};\\
               \,\, a+h+q & &     &\qquad   & &     &\qquad   & &     & \\
                          & &     &\qquad   & &     &\qquad   & &     & \node[xshift=8.5em]{(8)};\\                
        \phantom{a+h+q}a  &=& b+c &\qquad d &=& e+f &\qquad g &=& h+1 & \node[xshift=8.5em]{(9)};\\
};
\node[yshift=0.95em,fit=(table-3-2)(table-3-3)(table-3-4)(table-3-5)(table-3-6)(table-3-7)(table-3-8)(table-3-9)]{$$=\,\,b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q$$};
\node[yshift=0.95em,xshift=-.9em,fit=(table-4-2)(table-4-3)(table-4-4)(table-4-5)(table-4-6)(table-4-7)(table-4-8)(table-4-9)]{$$+r+s+t+u+x+y+w+z$$};      
    \end{tikzpicture}
\end{equation*}

enter image description here


Is it possible to do this in math-mode, i.e. is there a suitable environment for doing this?

MWE

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}

\usepackage{tikz}
\usetikzlibrary{fit,matrix}

\begin{document}


Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
\begin{align}
\setlength{\tabcolsep}{0pt}
\begin{tabular}{>{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$}}
    \phantom{a+h+q}a &\,= b+c &\qquad d &\,=e+f &\qquad g &\,=h+i\\
    \phantom{a+h+q}a &\,= b+c &\qquad d &\,=e+f &\qquad g &\,=h+i\\
    \multicolumn{6}{>{$}l<{$}}{\,\,a+h+q = b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q}\\
      & \multicolumn{5}{>{$}l<{$}}{\quad +r+s+t+u+x+y+w+z}\\
    \phantom{a+h+q}a &\,= b+c &\qquad d &\,=e+f &\qquad g &\,=h+i  
\end{tabular} \notag\\
\end{align}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
\begin{equation*}
\setlength{\tabcolsep}{0pt}
\begin{tabular}{>{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}r<{$}}
    \phantom{a+h+q}a &\,= b+c &\qquad d &\,=e+f &\qquad g &\,=h+i &\quad  (2)\\
    \phantom{a+h+q}a &\,= b+c &\qquad d &\,=e+f &\qquad g &\,=h+i &  \quad (3)\\
    \multicolumn{6}{>{$}l<{$}}{\,\,a+h+q = b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q}& \\
      & \multicolumn{5}{>{$}l<{$}}{\quad +r+s+t+u+x+y+w+z}  & \quad (4)\\
    \phantom{a+h+q}a &\,= b+c &\qquad d &\,=e+f &\qquad g &\,=h+i  & \quad (5)
\end{tabular}
\end{equation*}


Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
\begin{equation*}
\begin{tikzpicture}
\matrix (table) [matrix of math nodes, nodes in empty cells, row sep=.25em, column sep=0em]{%
    \phantom{a+h+q}a  &=& b+c &\qquad d &=& e+f &\qquad g &=& h+1 &\node[xshift=8.5em]{(6)};\\
    \phantom{a+h+q}a  &=& b+c &\qquad d &=& e+f &\qquad g &=& h+1 & \node[xshift=8.5em]{(7)};\\
           \,\, a+h+q & &     &\qquad   & &     &\qquad   & &     & \\
                      & &     &\qquad   & &     &\qquad   & &     & \node[xshift=8.5em]{(8)};\\                
    \phantom{a+h+q}a  &=& b+c &\qquad d &=& e+f &\qquad g &=& h+1 & \node[xshift=8.5em]{(9)};\\
    };
    \node[yshift=0.95em,fit=(table-3-2)(table-3-3)(table-3-4)(table-3-5)(table-3-6)(table-3-7)(table-3-8)(table-3-9)]{$$=\,\,b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q$$};
    \node[yshift=0.95em,xshift=-.9em,fit=(table-4-2)(table-4-3)(table-4-4)(table-4-5)(table-4-6)(table-4-7)(table-4-8)(table-4-9)]{$$+r+s+t+u+x+y+w+z$$};      
\end{tikzpicture}
\end{equation*}

\end{document}
  • 1
    What sort of geometry are you using, since the long equation will not fit into a default \textwidth? – John Kormylo Oct 19 '15 at 16:07
  • i'd simply use \rlap{...} to make the long right-hand side "invisible" to the alignment. (you'll still have to break it manually if it's too long, and maybe add a negative vertical adjustment after the \\ ending the first line.) – barbara beeton Oct 19 '15 at 16:17
  • @JohnKormylo I did not understood yuor question, sorry... I'm using standard geometry of article class, but this is clear for my MWE and then I think this is not your doubt... – Onner Irotsab Oct 19 '15 at 16:18
  • @barbarabeeton Thank you very much! It works with some adjustments :-) – Onner Irotsab Oct 19 '15 at 16:41
  • What's wrong with your current approaches? – Werner Oct 19 '15 at 16:53
3

There are two problems: First, ignoring the long equation while aligning the others. Second, centering the long equation into the display area. The first is achieved by \mathrlap (from mathtools} and the second by using flalign and \hspace.

\documentclass{article}
\usepackage{showframe}
\usepackage{mathtools}

\newlength{\tempdima}
\begin{document}

\settowidth{\tempdima}{$\displaystyle a+h+q = b+c+d+e+f+g+h+i+j+k+l+m+n+o+p$}%
\setlength{\tempdima}{\dimexpr 0.5\textwidth - 0.5\tempdima}%

\begin{flalign}
 a &= b+c & d &=e+f & g &=h+i &\\
 a &= b+c & d &=e+f & g &=h+i \\
\hspace{\tempdima}
 a+h+q &= \mathrlap{b+c+d+e+f+g+h+i+j+k+l+m+n+o+p}\notag\\[-1ex]
       &\quad \mathrlap{{}+u+x+y+w+z}\\
 a &= b+c & d &=e+f & g &=h+i
 \end{flalign}

\end{document}

overlapped equations

  • @JohnKormylo Than you very much! I have tried with \rlap and alignat, but I have had to put some \qquad at the end of the first line to avoid 'overfulls'... – Onner Irotsab Oct 19 '15 at 16:55
  • the vertical space between the long line and its continuation should really be tighter than the other between-equation spaces. it would also be a good idea to make the break sooner, so that the long line doesn't overlap the space "reserved" for the equation numbers. – barbara beeton Oct 19 '15 at 17:04
  • @barbara benson - You guys are going to make me work for this one. – John Kormylo Oct 19 '15 at 17:20
  • @JohnKormylo -- but the result looks much nicer. thanks. (by the way, it's "beeton", not "benson".) – barbara beeton Oct 19 '15 at 19:12

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.