LaTeX: How to adjust how the Sum symbol turns out

latex

Not sure if LaTeX counts as programming, or if my question even makes sense, but I have this LaTeX expression (or what you call it):

\sum_{k=1}^n k^2 = 1+4+9+\ldots +n^2 =
\frac{1}{3}n^3 + \frac{1}{2}n^2 + \frac{1}{6}n

The problem is that the k=1 and n comes next to, i.e. after, the sum symbol, instead of above and below it. Is there a way I can change this? I have tried to show visually what I mean below. The sum symbol represented as Xs :

 n
XXX          XXX n
XXX    vs    XXX
XXX          XXX k=1
k=1

I want the first kind, but am getting the second.

Best Answer

Try

\sum\limits_{k=1}^n k^2

if you want the sum limits to appear above and below the sum sign in an inline equation.