# 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.

• What if you want the equation numbering? Mar 24, 2016 at 15:27
• If you want a numbered equatiob insid a table, you do something wrong.
– yo'
Mar 24, 2016 at 18:58
• Dear downvoter, please, tell me what's wrong with the answer. Thanks.
– yo'
May 18, 2017 at 10:13

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...) Oct 10, 2012 at 16:57
• @haunted85 if it's in a table environment. have a look at the not so short guide to latex Oct 10, 2012 at 18:25
• But how do I know what size to give it? I am not specifying a fixed size in \begin{tabular}. Mar 25, 2016 at 15:54