TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}
share|improve this question
up vote 4 down vote accepted

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.

share|improve this answer
    
What if you want the equation numbering? – Raffi Khatchadourian Mar 24 at 15:27
1  
If you want a numbered equatiob insid a table, you do something wrong. – yo' Mar 24 at 18:58

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)$ \\
share|improve this answer
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 at 15:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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