# How to put a formula into a table cell

I need to insert into a table cell a formula that requires the summation sign and I apparently do something wrong and the compiler just throws me back errors and I really don't know how to solve this.

\begin{tabular}{ c || c c c }
\hline
Linea & Costo & Esecuzioni & Totale \\ \hline
1 & $1$ & $1$ & $1$ \\
2 & $n+1$ & $2$ & $2(n+1)$ \\
3 & $$\sum_{n=1}\nolimits' C_n$$ & $2$ & $2(n+1)$ \\
\hline
\end{tabular}

-

You cannot use $$...$$ inside a table cell. If you want it to look like a displayed equation, you can do this:

3 & $$\displaystyle \sum_{n=1}\nolimits' C_n$$ & $2$ & $2(n+1)$ \\


Here, $$...$$ is inline math (more-or-less equivalent to $...$), and \displaystyle is self-explanatory: it typesets the equation in the style as it was a displayed math.

-

You can actually put $$...$$ in a tabular cell, but you need to box it up first, either using a vbox, minipage, parbox, or something similar.

Whether or not that's a good idea is another issue; if your tabular is floating then it's almost certainly a bad idea (as the numbering might get messed up)

3 & \vbox{$$\sum_{n=1}\nolimits' C_n$$} & $2$ & $2(n+1)$ \\
4 & \parbox{3cm}{$$\sum_{n=1}\nolimits' C_n$$} & $2$ & $2(n+1)$ \\
5 & \begin{minipage}{4cm}$$\sum_{n=1}\nolimits' C_n$$\end{minipage} & $2$ & $2(n+1)$ \\

-
how do I know if my tabular is floating? (sorry for this basic question, but I'm a rookie and I'm learning by doing...) –  haunted85 Oct 10 '12 at 16:57
@haunted85 if it's in a table environment. have a look at the not so short guide to latex –  cmhughes Oct 10 '12 at 18:25