Vertical cell padding in the bottom of each cell in tabular with equations and listings is too large in cells containing one or more equations or listings. How do I get rid of this extra space?
Apparently, I can add \vspace{-1em} to the problematic cells, but is there a more general way, e.g., a command in the header of the tabular environment?
I have been trying various combinations of belowskip (the parameter of \lstset) and \belowdisplayskip. They have an unfortunate effect if there are multiple equations or listings in the cells. \arraystretch also seems to have an unfortunate effect within the cell for the various combination I have tried.
I would also like to have it working for the longtable environment. For the combinations I have tried it seems to behave similar to tabular wrt. my problem.
\documentclass{article}
\usepackage{amsmath,listings}
\begin{document}
\lstset{belowskip=0em}
\setlength{\belowdisplayskip}{0pt}
\begin{tabular}{ p{3.5cm} | p{3.5cm} }
\hline
Equation
\begin{equation*}
\begin{bmatrix}
1 \\
2 \\
\end{bmatrix}
\end{equation*}
&
Some code
\begin{lstlisting}
a = 1 + 2
\end{lstlisting}
Add
\begin{lstlisting}
a = a + 2
\end{lstlisting}
% \vspace{-1em}
\\
\hline
\end{tabular}
\end{document}