# How to align five equations on three lines, e.g., 2-2-1, with the last equation centered?

I'm trying to use the alignat environment to arrange five equations on three lines as follows: two equations on the first line, two equations on the second line (aligned with those of the first line), and the fifth equation centered on the third line by itself. For what is worth, here's my failed attempt:

\begin{alignat}{3}
a ={}& b
c ={}& d
\\
e ={}&f
g ={}& h
\\
{\centering
i = j
}
\end{alignat}


Please note I don't want the equation i=j on the third row to be aligned to the left, nor to the right, nor aligned with any particular piece of the other four equations, I really want it by itself on the third row, and centered on that row. I can produce the first two lines with no problem (using either align or alignat), but I can't get the single equation on the third line to be centered!

-
Welcome to TeX.SE. I removed 'thanks' from your post since we omit this. Instead, you should up-vote and accept the answers, giving the answerer the site reputation. –  yo' Aug 26 '12 at 19:59

If you need each line to be numbered, then you can nest alignat inside gather:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather}
\begin{alignat}{2}
c &= d
\\
e &=f &
g &= h
\end{alignat}
\\
i = j
\end{gather}
\end{document}


Without numbers, here's the way:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{gather*}
\begin{alignedat}{2}
c &= d
\\
e &=f &
g &= h
\end{alignedat}
\\
i = j
\end{gather*}
\end{document}

-
Thanks a lot, this was very helpful! –  Jon Aug 26 '12 at 21:23

Well, something like this? And remark: & should be before =, not after it. This will as well automatically use the correct spacing.

\begin{gather*}
\begin{aligned}
a &= b
&
c &= d
\\
e &= f
&
g &= h
\end{aligned}
\\
i = j
\end{gather*}

-
Thanks a lot for the answer! –  Jon Aug 26 '12 at 22:38

A regular array would work, given that you provide some help in terms of spacing between the columns:

\documentclass{article}
\begin{document}
$\begin{array}{r@{{}={}}l@{\qquad}r@{{}={}}l} f(x) & ax^2 + bx + c & g(x) & mx + c \\[\jot] f_1(x) & 2x^2 + 3x - 4 & g_1(x) & 3x - 1 \\[\jot] \multicolumn{4}{c}{h(x)=ax^3 + bx^2 + cx + d} \end{array}$
\end{document}


The column specification @{{}={}} handles the equal signs between functions f and g, and separates them by \qquad, while \\[\jot] adds a little vertical space between the equations. The last equation is centred in the traditional way using \multicolumn{.}{c}{...}.

-
Thanks for the answer! –  Jon Aug 26 '12 at 21:24

Not perhaps relevant here, but this is how I would do it with plain TeX (I used Werner's example content):

\displaylines{ \eqalign{f(x)&=ax^2+bx+c\cr f_1(x)&=2x^2+3x-4} \qquad \eqalign{g(x)&=mx+c\cr g_1(x)&=3x-1} \cr\noalign{\kern\dp\strutbox} h(x)=ax^3+bx^2+cx+d }
\bye


-