Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Who knows the way to write a multiline equation in a table? I am using the code below:

\begin{table} 
\centering 
\begin{tabular}{|c| c| c|}
\hline %inserts horizontal line

&f1& f2 \\ [0.5ex] 
\hline 
a& b& c\\ \hline 
d& e & f  \hline 
\end{tabular}
\label{label 1}
\end{table}

But b and e are two or maybe three line equations. How can I write them in my table?

share|improve this question
    
use a p-column instead of c –  Herbert Jul 11 '12 at 11:11
    
Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. –  Werner Jul 11 '12 at 13:49
add comment

migrated from stackoverflow.com Jul 11 '12 at 11:11

This question came from our site for professional and enthusiast programmers.

2 Answers

\documentclass[letterpaper]{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{table} 
\centering 
\renewcommand{\arraystretch}{1.3}
\begin{tabular}{|c| c| c|}
\hline %inserts horizontal line
&f1& f2 \\[0.5ex] 
\hline 
a& $\begin{array} {lcl} f(x) & = & (a+b)^2 \\ & = & a^2+2ab+b^2 \end{array}$ & c\\ 
\hline 
d& $\begin{array} {r@{}l@{}} f(x) & {}= (a+b)^2 \\ & {}= a^2+2ab+b^2 \end{array}$ & f\\    \hline 
g& $\begin{aligned} f(x) & = (a+b)^2 \\ & = a^2+2ab+b^2 \end{aligned}$ &h \\ \hline 
\end{tabular}
\label{label 1}
\end{table}
\end{document}

The above code yields:

enter image description here

I know it is not the best but I hope it answers your question. I edited the answer as per Peter Grill's suggestion. It is a better math display.

share|improve this answer
3  
You can obtain proper math spacing with $\begin{array} {r@{}l@{}} f(x) & {}= (a+b)^2 \\ & {}= a^2+2ab+b^2 \end{array}$, or just $\begin{aligned} f(x) & = (a+b)^2 \\ & = a^2+2ab+b^2 \end{aligned}$. –  Peter Grill Aug 10 '12 at 19:15
add comment

I think that \displaystyle is what you're looking for:

\documentclass{article}
\begin{document}

\begin{tabular}{|c|c|c|}
a& b& c\\
$v=mv^2/2$ & $\frac{mv^2}{2}$ & $\displaystyle \frac{mv^2}{2}$
\end{tabular}

\end{document}
share|improve this answer
    
I don't think that \dfrac is standard LaTeX, is it? –  Norman Gray Aug 10 '12 at 15:31
1  
\dfrac is the same thing as \displaystyle \frac{}{}. –  azetina Aug 10 '12 at 15:35
    
@NormanGray -- \dfrac requires the use of the amsmath package. –  barbara beeton Aug 10 '12 at 19:44
add comment

Your Answer

 
discard

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