# Vertically Centering Math and Text in Array?

One problem I've always had is trying to make text and/or math text vertically centered in either the tabular or array environments.

Take this for example:

\documentclass{article}
\usepackage{amsmath}
\newcommand{\firstpartial}[1]{\dfrac{\partial}{\partial {#1}}}
\begin{document}
$\begin{array}{|l|l|} \hline \firstpartial{x}\left[f(x,y)\right] = 2xy & \text{Differentiate with respect to }x\text{, treating }y \text{ as a constant.}\\[4ex] \hline \end{array}$
\end{document}


I would like to vertically center both the math and the text in both columns. How can I do this?

-
\end{document}

-

At least in this case, \addstackgap from the stackengine package can add a symmetric gap above and below an object. If the gap to be added is asymmetric (more above than below, for example), the \addvbuffer macro of the verbatimbox package allows for that.

Here is the \addstackgap fix:

\documentclass{article}
\usepackage{amsmath}
\usepackage{stackengine}
\stackMath
\newcommand{\firstpartial}[1]{\dfrac{\partial}{\partial {#1}}}
\begin{document}
$\begin{array}{|l|l|} \hline \addstackgap[3pt]{\firstpartial{x}\left[f(x,y)\right] = 2xy} & \text{Differentiate with respect to }x\text{, treating }y \text{ as a constant.}\\ \hline \end{array}$
\end{document}


-