# latex writes summation symbols in fractions, and the superscripts and subscripts of the summation symbols are misplaced [duplicate]

I'm trying to use the summation symbol in fractions, but I found that the superscript and subscript of the summation symbol go to the side, is this allowed mathematically? Or am I writing the Latex code wrong?

\begin{aligned} w = \frac{ \frac{1}{m} \sum_{i = 0}^{m} (-2x_1y_1) }{ 2\frac{1}{m} \sum_{i = 0}^{m} x_1^2 } \end{aligned}


I think this is allowed in maths. This is the inline mode which can be inserted in text if with only the denominator for example.

Consider the following code

\documentclass{article}

\begin{document}
$w = \frac{ \frac{1}{m} \sum_{i = 0}^{m} (-2x_1y_1) }{ 2\frac{1}{m} \sum_{i = 0}^{m} x_1^2 }$

$w = \frac{ \frac{1}{m} \sum\limits_{i = 0}^{m} (-2x_1y_1) }{ 2\frac{1}{m} \sum\limits_{i = 0}^{m} x_1^2 }$
\end{document}


which yields

Adding \limits after the \sum does the trick.

• @hair-splitter Oops indeed and I will make an edit. Thank you! Commented Mar 20, 2022 at 14:46
• Is there any difference between [...] and $$...$$ ? They seem to produce similar results. Commented Mar 20, 2022 at 14:46
• @aszswaz Please follow the link for details. In brief, it is more robust. Commented Mar 20, 2022 at 14:48