# Type multiline equation in a table in LaTeX

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?

• use a p-column instead of c
– user2478
Jul 11, 2012 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, 2012 at 13:49

\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:

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.

• 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}. Aug 10, 2012 at 19:15

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}

• I don't think that \dfrac is standard LaTeX, is it? Aug 10, 2012 at 15:31
• \dfrac is the same thing as \displaystyle \frac{}{}. Aug 10, 2012 at 15:35
• @NormanGray -- \dfrac requires the use of the amsmath package. Aug 10, 2012 at 19:44