# Centering split equation

I am quite new to TeX. I want that each line in the following equation be centered, but I cannot find how to do it.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$$\begin{split} a & = \frac{M_{20}}{M_{00}} - x^{2}_{c}, \;\;\; b = 2(\frac{M_{11}}{M_{00}} - x_{c}y_{c}), \;\;\; c = \frac{M_{02}}{M_{00}} - y^{2}_{c}, \\ &\quad x_{c} = \frac{M_{10}}{M_{00}}, \;\;\; y_{c} = \frac{M_{01}}{M_{00}}, \\ &\quad M_{ij} = \displaystyle\sum\limits_{x} \displaystyle\sum\limits_{y} x^i y^j I(x,y) \end{split}$$
\end{document}


Also, it would be awesome if I could write "and" after the first line ;)

-
It's always best to have compilable code. –  Hendrik Vogt Jan 19 '11 at 10:39
@Hendrik: Thanks, I will remember that ;) –  nacho4d Jan 19 '11 at 11:43
Check out Philipp's answer. Embedding of gathered in equation puts one centered equation number nexts to centered equations. The accepted answer forces the equation number onto the last line and a large number of \notag commands. –  Argyll May 2 '14 at 11:51

\documentclass{minimal}
\usepackage{amsmath}

\begin{document}

\begin{gather}
c = \frac{M_{02}}{M_{00}} - y^{2}_{c},\nonumber\\[1ex]
\text{and}\nonumber\\[1ex]
y_{c} = \frac{M_{01}}{M_{00}}, \nonumber\\
M_{ij} = \displaystyle\sum\limits_{x} \displaystyle\sum\limits_{y} x^i y^j I(x,y)
\end{gather}

\end{document}


-
Instead of \displaystyle\sum\limits_{x} you can write \sum_{x} –  Bruno Le Floch Jan 19 '11 at 11:07
or \sum_x... :-) –  Herbert Jan 19 '11 at 11:17
I used '\displaystyle\sum\limits_{x}' since the position of limit is a little bit different from '\sum_{x}'. With '\displaystyle\sum\limits_{x}' it actually goes below '\sum'. –  nacho4d Jan 19 '11 at 12:11
Inside an equation environment it is already at displaystyle, and the subscript will be placed below. amsmath also defined the \intertext{} command which is made for exactly for inserting a short text between equations like this. –  Mikael Öhman Jan 19 '11 at 12:41

Just replace the split environment by gathered, then you don't have to suppress spurious equation numbers:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$$\begin{gathered} a = \frac{M_{20}}{M_{00}} - x^{2}_{c}, \;\;\; b = 2(\frac{M_{11}}{M_{00}} - x_{c}y_{c}), \;\;\; c = \frac{M_{02}}{M_{00}} - y^{2}_{c}, \\ \quad x_{c} = \frac{M_{10}}{M_{00}}, \;\;\; y_{c} = \frac{M_{01}}{M_{00}}, \\ \quad M_{ij} = \displaystyle\sum\limits_{x} \displaystyle\sum\limits_{y} x^i y^j I(x,y) \end{gathered}$$
\end{document}

-

The code below is not exactly what you asked for, but it has some alternatives that you might want consider.

• Use \left and \right to fix the size of the parenthesis
• Use \intertext to put words between equations
• Use & to get better control of alignment

You mentioned you are new. You might want to read the mathtools document.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
a &= \frac {M_{20} } {M_{00} } - x^{2}_{c} , &
b &= 2 \left (  \frac {M_{11} } {M_{00} } - x_{c} y_{c}  \right )  , & %NOTE THE \LEFT AND \RIGHT
c &= \frac {M_{02} } {M_{00} } - y^{2}_{c} , \\
\intertext {and} % NOTE THE 'CORRECT' USAGE OF INTERTEXT TO WRITE IN BETWEEN EQUATIONS
&& \quad x_{c} &= \frac {M_{10} } {M_{00} } , & % NOTE THE DOUBLE && TO ALIGN TO THE SECOND COLUMN
y_{c} &= \frac {M_{01} } {M_{00} } , \\
\intertext {Some text}
&& \quad M_{ij} &= \sum \limits_{x} \sum \limits_{y} x^i y^j I( x, y )
\end{align}
\end{document}

-
\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{gather}
a = \frac{M_{20}}{M_{00}} - x^{2}_{c}, \;\;\;
b = 2\left(\frac{M_{11}}{M_{00}} - x_{c}y_{c}\right), \;\;\;
c = \frac{M_{02}}{M_{00}} - y^{2}_{c}, \nonumber\    x_{c} = \frac{M_{10}}{M_{00}}, \;\;\; y_{c} = \frac{M_{01}}{M_{00}}, \    M_{ij} = \sum_x\sum_y x^i y^j I(x,y)\nonumber
\end{gather}

\end{document}

-