# 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. Jan 19, 2011 at 10:39
• 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. May 2, 2014 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} Jan 19, 2011 at 11:07
• or \sum_x... :-)
– user2478
Jan 19, 2011 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'. Jan 19, 2011 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. Jan 19, 2011 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}

• This should be definitely the right answer... Aug 5, 2017 at 10:17
• @GiuTeX why? Is it significantly different from the accepted answer? Dec 5, 2021 at 22:34
• @Nathan gotta be honest with you I don't remember at all why I wrote that. Looking now at the accepted answer I can't say there are substantial differences... Dec 7, 2021 at 10:53
• @GiuTeX other voters seem to agree with you, though. I suppose the abstracting-away of other subtleties and just leaving the votes to speak probably mean you're right Dec 7, 2021 at 21:52

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}