# Vertical Alignment of Equations in a Table

I am writing up a university project, and I want to create a table with the left column containing Feynman diagrams (which I have drawn using the feynmp package) and the right column containing equations. When I do this, however, the equations are vertically aligned in the bottom of the cell, and I can’t figure out how to change this, so that they align with the centre of the diagram in the same row.

Here is some sample code which I hope demonstrates the problem without writing out my whole report.

\begin{table*}[t]
\centering
\begin{tabular}{|c|c|}
\hline
\textbf{feynmp diagram goes here}
&
\begin{aligned} I &= \\ &\frac{D}{4} \end{aligned}
\\
\hline
\end{tabular}
\end{table*}


You can use the m{width} option of tabular:

\documentclass{article}

\usepackage{array}
\usepackage{amsmath}

\begin{document}
\begin{table*}[t]
\centering
\begin{tabular}{|c|m{5cm}|}
\hline
\textbf{feynmp diagram goes here} \newline
&
\begin{aligned} I &= \\ &\frac{D}{4} \end{aligned}
\\
\hline
\end{tabular}
\end{table*}
\end{document}


You can keep c cells, without specifying their width, with a simple \raisebox[-\height} (plus a visual correction if necessary). I added some vertical padding with the cellspace package:

\documentclass{article}
\usepackage{graphicx}
\usepackage{array}
\usepackage{amsmath}
\usepackage{cellspace}
\setlength\cellspacetoplimit{6pt}
\setlength\cellspacebottomlimit{6pt}

\begin{document}

\begin{table*}[t]
\centering
\begin{tabular}{|Sc|c|}
\hline
\raisebox{\dimexpr-0.5\height+1ex\relax }{\fbox{\includegraphics[scale = 0.4]{Feynmann}}}
& \begin{aligned} I & = \\\hline &\frac{D}{4} \end{aligned} \\
\hline
\end{tabular}
\end{table*}

\end{document}


You can also use tikz-feynman (project page). In particular, it has the option inline which adjusts the baseline of the diagram (in the same way that baseline works in TikZ) and also makes the diagram a little smaller so that it fits nicely into equations, or in this case, tables.

\documentclass{article}

\usepackage[compat=1.1.0]{tikz-feynman}
\usepackage{booktabs}

\begin{document}
\begin{tabular}{cc}
\toprule
\multicolumn{2}{c}{\textbf{Feynman Rules}} \\
\midrule
\feynmandiagram[inline=(a), horizontal=i1 to a] {
i1 [particle=$$A_{\mu}$$] -- [photon] a -- [fermion] f1,
a -- [anti fermion] f2,
}; &
$$\displaystyle ig \gamma_{\mu}$$ \\
\feynmandiagram[inline=(a), horizontal=i1 to a] {
i1 [particle=$$W^{\pm}_{\mu}$$]-- [photon] a -- [fermion] f1,
a -- [anti fermion] f2,
}; &
$$\displaystyle \frac{ig}{\sqrt{2}} \gamma_{\mu} \frac{1 - \gamma_{5}}{2}$$ \\
\bottomrule
\end{tabular}
\end{document}


As I already wrote to your cross post at LaTeX-Community.org, you could use the adjustbox package or the stackengine package, such as demonstrated in this example using your code. So you don't need m columns which require a fixed width.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{amsmath}
\usepackage{stackengine}
\begin{document}
\begin{table*}[t]
\centering
\begin{tabular}{|c|c|}
\hline
\Centerstack{\includegraphics{diagram}}
&
\begin{aligned} I &= \\ &\frac{D}{4} \end{aligned}\\
\hline
\end{tabular}
\end{table*}
\end{document}


You could also change to top alignment this way:

  \belowbaseline[0pt]{\includegraphics{diagram}}
&
\belowbaseline[0pt]{\begin{aligned} I &= \\ &\frac{D}{4} \end{aligned}}\\


The diagram has the base line for vertical alignment at the bottom. The base line for the aligned math environment is at it's center (but can be changed to top or bottom line). In the table, the base lines are aligned next to each other. So you see the diagram going upwards above the base line, the math text at the base line stays low. It's base line alignment, not top alignment. Changing it to grow below the base line, like I did, gives top alignment. See also the LaTeX forum post for reference or further discussion.