14

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 & \begin{equation} \sum_{n=1}\nolimits' C_n \end{equation} & $2$ & $2(n+1)$ \\
\hline  
\end{tabular}
16

You cannot use \begin{equation}...\end{equation} 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? – Raffi Khatchadourian Mar 24 '16 at 15:27
  • 4
    If you want a numbered equatiob insid a table, you do something wrong. – yo' Mar 24 '16 at 18:58
  • 1
    Dear downvoter, please, tell me what's wrong with the answer. Thanks. – yo' May 18 '17 at 10:13
14

You can actually put \begin{equation}...\end{equation} 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{\begin{equation} \sum_{n=1}\nolimits' C_n \end{equation}} & $2$ & $2(n+1)$ \\
4 & \parbox{3cm}{\begin{equation} \sum_{n=1}\nolimits' C_n \end{equation}} & $2$ & $2(n+1)$ \\
5 & \begin{minipage}{4cm}\begin{equation} \sum_{n=1}\nolimits' C_n \end{equation}\end{minipage} & $2$ & $2(n+1)$ \
  • 2
    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
  • But how do I know what size to give it? I am not specifying a fixed size in \begin{tabular}. – Raffi Khatchadourian Mar 25 '16 at 15:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.