[Tex/LaTex] Sum within a fraction

math-mode

I'm trying to get a sum to display "properly" within a fraction. My input is:

\begin{equation}
    E = 1 - \dfrac{\sum_{i=1}^{n}(O_{i}-P_{i})^{2}}{\sum_{i=1}^{n}(O_{i}-\bar{O})^{2}}
\end{equation}

And the output looks like this: enter image description here

I want the indices to appear above and below the sum as opposed to the side. How can I go about doing this?

Best Answer

Use \limits just before _ and ^ in connection with \sum command, the same holds also for an integral \int\limits^{b}_{a} for example.

\documentclass[paper=a4,12pt]{book}


\usepackage{amsmath}
\begin{document}

\begin{equation}
    E = 1 - \dfrac{\sum\limits_{i=1}^{n}(O_{i}-P_{i})^{2}}{\sum\limits_{i=1}^{n}(O_{i}-\bar{O})^{2}}
\end{equation}

\end{document}

enter image description here

Related Question