# Sort of 'multicolumn' for align environment

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\\
%%%%%
\\
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<{$}}
\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}\\
\end{tabular} \notag\\
\end{align}

\begin{equation*}
\setlength{\tabcolsep}{0pt}
\begin{tabular}{>{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}l<{$} >{$}r<{$}}
\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) \\
\end{tabular}
\end{equation*}

## 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   & &     & \\
\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*}

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<{$}}
\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}\\
\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<{$}}
\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)\\
\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   & &     & \\
\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}
• 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

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]