36

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?

justin.dong
  • 1,249

1 Answers1

46

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

  • But shouldn't \dfrac make both numerator and denominator in \displaystyle mode? – Manuel Jun 09 '14 at 13:23
  • @Manuel: Yes, that is true, see http://tex.stackexchange.com/questions/135389/what-is-the-difference-between-dfrac-and-frac, but as far as I know \displaystyle mode has no effect on the positioning of limits of sum or integral symbols –  Jun 09 '14 at 13:35
  • 1
    No, in fact it doesn't have to make both of them \displaystyle. If I'm not mistaken it just makes the whole fraction \displaystyle (therefore, the two parts are \textstyle). – Manuel Jun 09 '14 at 13:43
  • 1
    There is no need for \dfrac; here, \frac suffice. – Svend Tveskæg Jun 11 '14 at 07:49
  • @SvendTveskæg: I just used it from the 'MWE' above –  Jun 11 '14 at 07:50