# Vertical spacing of a table cell

I want to tabulate formulas, but I find that the lines of the table cells are too close together, and this is aesthetically unsatisfactory. Example (formulae copied from wikipedia):

\begin{tabular}{|c|c|}
\hline
Cylindrical & $\displaystyle{{1 \over \rho}{\partial \over \partial\rho}\left(\rho {\partial f \over \partial \rho}\right) + {1 \over \rho^2}{\partial^2 f \over \partial \phi^2} + {\partial^2 f \over \partial z^2}}$\\\hline
Spherical & $\displaystyle{{1 \over r^2}{\partial \over \partial r}\!\left(r^2 {\partial f \over \partial r}\right) \!+\!{1 \over r^2\!\sin\theta}{\partial \over \partial \theta}\!\left(\sin\theta {\partial f \over \partial \theta}\right) \!+\!{1 \over r^2\!\sin^2\theta}{\partial^2 f \over \partial \phi^2}}$\\\hline
\end{tabular}


gives this

and you see that the top of the formulas are chopped by the lines. Suggestions?

-
See Column padding in tables on ways of adjusting both vertical and horizontal padding of cell entries in tabular or array. –  Werner Apr 1 '12 at 14:18
@Werner Since this is an answer, you should pose it as such. –  Limited Atonement Jul 4 '14 at 15:17

I have solved this in the past by modifying the value of \arraystretch

{\renewcommand{\arraystretch}{1.2} %<- modify value to suit your needs
\begin{tabular}{|c|c|}
...
\end{tabular}
}


Edit:

Actually having researched this a bit more it seems that having equations in the cells has unexpected behaviour, where the space is increase disproportionally at the top (value set to 3 to start getting the space at the bottom):

more recently I have started to use the tabu package to replace all tables (from tabular to tabularx to longtable). It also provide a few more controls. in this case the \tabulinesep has a much more appropirate effect on the results:

\documentclass[preview]{standalone}
\usepackage{tabu}
\begin{document}
{\tabulinesep=1.2mm
\begin{tabu} {|c|c|}
\hline
Cylindrical & $\displaystyle{{1 \over \rho}{\partial \over \partial\rho}\left(\rho {\partial f \over \partial \rho}\right) + {1 \over \rho^2}{\partial^2 f \over \partial \phi^2} + {\partial^2 f \over \partial z^2}}$\\\hline
Spherical & $\displaystyle{{1 \over r^2}{\partial \over \partial r}\!\left(r^2 {\partial f \over \partial r}\right) \!+\!{1 \over r^2\!\sin\theta}{\partial \over \partial \theta}\!\left(\sin\theta {\partial f \over \partial \theta}\right) \!+\!{1 \over r^2\!\sin^2\theta}{\partial^2 f \over \partial \phi^2}}$\\\hline
\end{tabu}}
\end{document}


which produces the following result:

-
Good advice! tabu is a really good package! –  Alberto Feb 26 '13 at 21:09

You may use a different table format, leaving out the vertical lines which are by no means necessary; you can also greatly simplify the input with a personal command for partial derivatives:

\documentclass{article}

\usepackage{booktabs,amsmath}

\newcommand{\dpder}[3][]{\dfrac{\partial^{#1}#2}{\partial #3}}

\begin{document}
\begin{tabular}{lc}
\toprule
Cartesian &
$\dpder[2]{f}{x^2}+\dpder[2]{f}{y^2}+\dpder[2]{f}{z^2}$
\\
\midrule
Cylindrical &
$\dfrac{1}{\rho} \dpder{}{\rho}{\left(\rho \dpder{f}{\rho}\right)} + \dfrac{1}{\rho^2} \dpder[2]{f}{\phi^2} + \dpder[2]{f}{z^2}$
\\
\midrule
Spherical &
$\dfrac{1}{r^2}\dpder{}{r}{\left(r^2 \dpder{f}{r}\right)} +\dfrac{1}{r^2\sin\theta}\dpder{}{\theta}{\left(\sin\theta \dpder{f}{\theta}\right)} +\dfrac{1}{r^2\sin^2\theta}\dpder[2]{f}{\phi^2}$
\\
\bottomrule
\end{tabular}
\end{document}


Notice how to avoid unwanted spaces in the "cylindrical" and "spherical" rows by using {\left(...\right)} (a couple of braces is sufficient instead of explicit backing up). Note also the usage of \dfrac in the definition of \dpder that avoids specifying \displaystyle (which is however not a command taking arguments, but a declaration).

With booktabs there's rarely the need to adjust the row spacing.

-
Thanks. I usually use macros but in this case I compiled a list of useful formulas for my students, and just copy-pasted it from wikipedia. Can you explain what the second (empty) square braces do in the definition of \dpder? –  yohbs Apr 1 '12 at 20:22
@yohbs With \newcommand{\dpder}[3][]{...} we say that the command has one optional argument and two mandatory ones; the default of the optional argument is empty (the exponent for the \partial in the numerator. –  egreg Apr 1 '12 at 20:43
I didn't knew about the spacingissue. Really nice, egreg! :)` –  Svend Tveskæg Nov 30 '13 at 15:36