tags:

views:

2479

answers:

3

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.

A: 

I think you will need to use the equation environment for that:

\begin{equation}
\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
\end{equation}
Lex
Hm, probably correct, but the WP Latex plug-in says that the formula does not parse. For some reason...
Svish
Hm, yeah, that could be. I didn't test is, just copied the formula given in the question...
Lex
You are half-right here - `\sum` defaults to limits on the side when inline, and limits above and below when not (equation environment, $$). Martin B's answer, using `\limits`, will force it to place them above and below independent of environment.
Jefromi
+6  A: 

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.

Martin B
Seems to work perfectly. Thanks =)
Svish
+3  A: 

A more general solution to force a formula that is appearing in inline style to appear in display style is to start the formula with a \displaystyle declaration, e.g.

$\displaystyle \sum_{k=1}^n k^2$

This will work for any expression that appears differently in inline and display environments, such as \frac, \int, \lim, etc. You can also control the scope of the \displaystyle command by enclosing the desired expression in braces. For example, if you want the sum in your example formula to appear in display style but not the fractions, you could use

${\displaystyle \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$
las3rjock
That probably works too, but the WordPress Latex plugin doesn't seem to support it. It says that I must stay in inline math mode. Maybe that's why the \begin{equation} stuff doesn't work either...
Svish
I'm pretty sure that the WordPress LaTeX plugin does support \displaystyle because I've used it on my blog on http://wordpress.com/ An example drawn directly from my blog is $latex \displaystyle \frac{n^2 - 1}{n^2 + 2} = \frac{4 \pi}{3} N \alpha_i$
las3rjock