# Fixing spacing on table with cases within it?

I am trying to input a table of the type below, but I can't get the vertical spacing to work, especially for the 2nd and 3rd rows in the last column (where the cases environment is). I've tried arraystretching, vspace (which completely breaks it), and adding \\[10pt]. Any suggestions on how to fix it? I am looking specifically for suggestions that can be done within basic LaTeX (i.e. that don't require using a new package, as this will need to apply to multiple tables within a document I already have).

Thank you, have a nice day.

\begin{table}[h]
\centering

\begin{tabular}{|c|c|c|}
\hline
Function& Physical Space  & Fourier Space \\[5pt] \hline
Gaussian & $\displaystyle\frac{\pi}{\alpha}e^{-\frac{\pi^{2} (x^{2} + y^{2})}{\alpha}}$ & $e^{-\alpha (j^2+k^2)}$ \\[5pt] \hline
Box & $\begin{cases} h & -\omega_x<x<\omega_x, -\omega_y<y<\omega_y \\ 0 & \text{otherwise} \end{cases}$ & $\begin{cases} \displaystyle h\frac{\sin(2\pi j\omega_x)\sin(2\pi k\omega_y)}{\pi^2 (2\pi j)(2\pi k)} & k\neq 0\neq j \\ h\frac{\sin(2\pi j\omega_x)}{\pi^2 (2\pi j)} & j\neq 0=k \\ h\frac{\sin(2\pi k\omega_y)}{\pi^2 (2\pi k)} & k\neq 0=j \\ \frac{h}{\pi^2} & j=0=k \end{cases}$\\[5pt] \hline
Cylinder & $\begin{cases} h & \frac{x}{\omega_x}^2+\frac{y}{\omega_y}^2 \leq 1 \\ 0 & \text{otherwise} \end{cases}$&$\begin{cases} h\frac{J_1(2\pi\sqrt{(j\omega_x)^2+(k\omega_y)^2})}{\sqrt{(2\pi j)^2+(2\pi k)^2}}\sqrt{\frac{\omega_x}{2\pi}\frac{\omega_y}{2\pi}} & j\neq 0 \text{ or } k\neq 0 \\ h\pi\frac{\omega_x}{2\pi}\frac{\omega_y}{2\pi} & j=0=k \end{cases}$ \\[5pt] \hline

\end{tabular}
\end{table}


New contributor
FamisherCaterpillar is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

If you really want a caged table, enclose the tallest objects in a matrix where the first and third row are empty and you can reduce their alloted vertical space.

I suggest dcases to make the formulas readable (requires mathtools). It still overflows at standard text width, notwithstanding a couple of space saving tricks with array (see the code below), so I loaded geometry that uses wider lines.

\documentclass{article}
\usepackage{geometry}
\usepackage{amsmath,mathtools}

\begin{document}

\begin{table}[htp]
\centering

\begin{tabular}{|c|c|c|}
\hline
Function & Physical Space  & Fourier Space \\
\hline
Gaussian &
$\dfrac{\pi}{\alpha}e^{-\frac{\pi^{2} (x^{2} + y^{2})}{\alpha}}$ &
$\begin{matrix} \phantom{0} \\[-1ex] e^{-\alpha (j^2+k^2)} \\[-1ex] \phantom{0} \end{matrix}$ \\
\hline
Box &
$\begin{dcases} h & \begin{array}{@{}l@{}} -\omega_x<x<\omega_x,\\ -\omega_y<y<\omega_y \end{array} \\[1ex] 0 & \text{otherwise} \end{dcases}$ &
$\begin{matrix} \phantom{0} \\[-1ex] \begin{dcases} h\frac{\sin(2\pi j\omega_x)\sin(2\pi k\omega_y)}{\pi^2 (2\pi j)(2\pi k)} & k\neq 0\neq j \\ h\frac{\sin(2\pi j\omega_x)}{\pi^2 (2\pi j)} & j\neq 0=k \\ h\frac{\sin(2\pi k\omega_y)}{\pi^2 (2\pi k)} & k\neq 0=j \\ \frac{h}{\pi^2} & j=0=k \end{dcases} \\[-1ex] \phantom{0} \end{matrix}$ \\
\hline
Cylinder &
$\begin{dcases} h & \left(\frac{x}{\omega_x}\right)^{\!2}+\left(\frac{y}{\omega_y}\right)^{\!2} \leq 1 \\ 0 & \text{otherwise} \end{dcases}$ &
$\begin{matrix} \phantom{0} \\[-1ex] \begin{dcases} h\frac{J_1(2\pi\sqrt{(j\omega_x)^2+(k\omega_y)^2})} {\sqrt{(2\pi j)^2+(2\pi k)^2}} \sqrt{\frac{\omega_x}{2\pi}\frac{\omega_y}{2\pi}} & \begin{array}{@{}l@{}} j\neq 0 \text{ or} \\ k\neq 0 \end{array} \\[1ex] h\pi\frac{\omega_x}{2\pi}\frac{\omega_y}{2\pi} & j=0=k \end{dcases} \\[-1ex] \phantom{0} \end{matrix}$ \\
\hline
\end{tabular}

\caption{Some caption}\label{somelabel}

\end{table}

\end{document}


A different realization that you might find appealing.

\documentclass{article}
\usepackage{geometry}
\usepackage{amsmath,mathtools}
\usepackage{booktabs}

\begin{document}

\begin{table}[htp]
\centering

%% local settings
\setlength{\aboverulesep}{0.8ex}
\setlength{\belowrulesep}{0.8ex}

\begin{tabular}{@{}lll@{}}
\toprule
Function & \multicolumn{1}{c}{Physical Space} & \multicolumn{1}{c@{}}{Fourier Space} \\
\midrule
Gaussian &
\quad $\dfrac{\pi}{\alpha}e^{-\frac{\pi^{2} (x^{2} + y^{2})}{\alpha}}$ &
\quad $e^{-\alpha (j^2+k^2)}$ \\
\midrule
Box &
$\begin{dcases} h & \begin{array}{@{}l@{}} -\omega_x<x<\omega_x,\\ -\omega_y<y<\omega_y \end{array} \\[1ex] 0 & \text{otherwise} \end{dcases}$ &
$\begin{dcases} h\frac{\sin(2\pi j\omega_x)\sin(2\pi k\omega_y)}{\pi^2 (2\pi j)(2\pi k)} & k\neq 0\neq j \\ h\frac{\sin(2\pi j\omega_x)}{\pi^2 (2\pi j)} & j\neq 0=k \\ h\frac{\sin(2\pi k\omega_y)}{\pi^2 (2\pi k)} & k\neq 0=j \\ \frac{h}{\pi^2} & j=0=k \end{dcases}$ \\
\midrule
Cylinder &
$\begin{dcases} h & \left(\frac{x}{\omega_x}\right)^{\!2}+\left(\frac{y}{\omega_y}\right)^{\!2} \leq 1 \\ 0 & \text{otherwise} \end{dcases}$ &
$\begin{dcases} h\frac{J_1(2\pi\sqrt{(j\omega_x)^2+(k\omega_y)^2})} {\sqrt{(2\pi j)^2+(2\pi k)^2}} \sqrt{\frac{\omega_x}{2\pi}\frac{\omega_y}{2\pi}} & \begin{array}{@{}l@{}} j\neq 0 \text{ or} \\ k\neq 0 \end{array} \\[1ex] h\pi\frac{\omega_x}{2\pi}\frac{\omega_y}{2\pi} & j=0=k \end{dcases}$ \\
\bottomrule
\end{tabular}

\caption{Some caption}\label{somelabel}

\end{table}

\end{document}


Sometimes, the simplest method for keeping math material from coming too close to horizontal lines in a tabular-like environment is not to draw the horizontal lines to begin with.

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry} % set page parameters as needed
\usepackage{mathtools} % for 'dcases' environment
\usepackage{array}     % for '\newcolyumntype' macro
\newcolumntype{L}{>{$\displaystyle}l<{$}}
\usepackage{booktabs}  % for well-spaced horizontal rules ('\toprule', etc)

\begin{document}
\begin{table}[h]
\centering

\begin{tabular}{@{} l LL @{}}
\toprule
Function & \text{Physical Space} & \text{Fourier Space} \\
\midrule
Gaussian &
\frac{\pi}{\alpha}\exp[-\pi^2 (x^2 + y^2)/\alpha] &
\exp[-\alpha (j^2+k^2)] \\
Box &
\begin{dcases}
h & -\omega_x<x<\omega_x,\ -\omega_y<y<\omega_y \\
0 & \text{otherwise}
\end{dcases} &
\begin{dcases}
\frac{h}{\pi^2}\frac{\sin(2\pi j\omega_x)\sin(2\pi k\omega_y)}{2\pi j\,2\pi k} & k\neq 0\neq j \\[\jot]
\frac{h}{\pi^2}\frac{\sin(2\pi j\omega_x)}{2\pi j} & j\neq 0=k \\[\jot]
\frac{h}{\pi^2}\frac{\sin(2\pi k\omega_y)}{2\pi k} & k\neq 0=j \\[\jot]
\frac{h}{\pi^2\mathstrut} & j=0=k
\end{dcases}\\
Cylinder &
\begin{dcases}
h & \frac{x}{\omega_x}^2+\frac{y}{\omega_y}^2 \leq 1 \\
0 & \text{otherwise}
\end{dcases}&
\begin{dcases}
h\frac{J_1[2\pi\sqrt{(j\omega_x)^2+(k\omega_y)^2}\,]}{\sqrt{(2\pi j)^2+(2\pi k)^2}} \sqrt{\frac{\omega_x\mathstrut}{2\pi}\frac{\omega_y}{2\pi}} & j\neq 0 \text{ or } k\neq 0 \\[\jot]
h\pi\frac{\omega_x}{2\pi\mathstrut}\frac{\omega_y}{2\pi\mathstrut} & j=0=k
\end{dcases} \\
\bottomrule

\end{tabular}
\end{table}
\end{document}


See if this answer suits you.

%% Compile and read me!
\documentclass[a4paper,12pt]{article}
\pagestyle{empty}

\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{makecell}%To keep spacing of text in tables
\setcellgapes{5pt}%parameter for the spacing

\begin{document}

\begin{table}[h]
\makegapedcells
\centering
\begin{tabular}{|c|c|c|}

\hline
Function& Physical Space  & Fourier Space \\[5pt] \hline
Gaussian & $\displaystyle\frac{\pi}{\alpha}e^{-\frac{\pi^{2} (x^{2} + y^{2})}{\alpha}}$ & $e^{-\alpha (j^2+k^2)}$ \\[5pt] \hline
Box & $\begin{cases} h & -\omega_x<x<\omega_x, -\omega_y<y<\omega_y \\ 0 & \text{otherwise} \end{cases}$ & $\begin{cases} \displaystyle h\frac{\sin(2\pi j\omega_x)\sin(2\pi k\omega_y)}{\pi^2 (2\pi j)(2\pi k)} & k\neq 0\neq j \\ h\frac{\sin(2\pi j\omega_x)}{\pi^2 (2\pi j)} & j\neq 0=k \\ h\frac{\sin(2\pi k\omega_y)}{\pi^2 (2\pi k)} & k\neq 0=j \\ \frac{h}{\pi^2} & j=0=k \end{cases}$\\[5pt] \hline
Cylinder & $\begin{cases} h & \frac{x}{\omega_x}^2+\frac{y}{\omega_y}^2 \leq 1 \\ 0 & \text{otherwise} \end{cases}$&$\begin{cases} h\frac{J_1(2\pi\sqrt{(j\omega_x)^2+(k\omega_y)^2})}{\sqrt{(2\pi j)^2+(2\pi k)^2}}\sqrt{\frac{\omega_x}{2\pi}\frac{\omega_y}{2\pi}} & j\neq 0 \text{ or } k\neq 0 \\ h\pi\frac{\omega_x}{2\pi}\frac{\omega_y}{2\pi} & j=0=k \end{cases}$ \\[5pt] \hline

\end{tabular}
\end{table}

\end{document}


If not, let me know.

New contributor
cryptocrowin is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.