[Tex/LaTex] Center Equation

alignequationshorizontal alignment

Does anyone know how to center this equation?

\begin{align} 
r(P_i)=\sum\limits_{P_j \in B_{P_i}} \frac{r(P_j)}{|P_j|}
\label{eq:sum} 
\end{align}

Thanks in advance

Best Answer

aligned equations are typically centered by default, so without more information about your preamble it's hard to know for certain what the problem is.

That said, it's most likely that the problem arises from passing fleqn as an option to the document class. Removing this makes display math (including align environments) centered instead of left-aligned.

However, if you want to have some equations left-aligned and others centered, use the environment ceqn from the nccmath package, as so:

\documentclass[fleqn]{article}
\usepackage{amsmath}
\usepackage{nccmath}
\begin{document}
\noindent This is left-aligned:
\begin{align}
   \int \frac{1}{1+x^2}\, dx = \arctan x + C.
\end{align}
This is centered:
\begin{ceqn}
\begin{align}
   \int \frac{1}{1+x^2}\, dx = \arctan x + C.
\end{align}
\end{ceqn}
\end{document}

This is the output:

enter image description here

Source: this TeX.SX post.

Related Question