4
\documentclass{article}
\usepackage{mathtools}

\begin{document}

\renewcommand{\arraystretch}{1.2}

\begin{table}[t]
\centering
\begin{tabular}{@{}c|ll|ll@{}}
\hline
A & B &  & C &  \\
\hline
D & $\begin{cases}
3 & \text{if } n = 1 \\
4 & \text{if } n\ge 1
\end{cases}$ &  & &  \\ \hline
E & F &  & G & \\ \hline
\end{tabular}
\end{table}

\end{document}

With this code, the cases bracket touches the upper and lower horizontal lines. I'd like to add a bit of space, both upper and lower. I tried increasing the \renewcommand{\arraystretch}, but that didn't help.

enter image description here

3 Answers 3

3

There are many different ways to add space. One of the simplest is to add vertical space around the cases environment within the table cell by using zero-width rules to adjust the height and depth of the cell.

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\renewcommand{\arraystretch}{1.2}

\begin{table}[t]
\centering
\begin{tabular}{@{}c|ll|ll@{}}
\hline
A & B &  & C &  \\
\hline
D & $\rule{0pt}{4.5ex}% Add space above
   \begin{cases}
   3 & \text{if } n = 1 \\
   4 & \text{if } n\ge 1
   \end{cases}
   \rule[-3.5ex]{0pt}{0pt}$% Add space below
   &  & &  \\ \hline
E & F &  & G & \\ \hline
\end{tabular}
\end{table}

\end{document}

enter image description here

5

The booktabs package comes particularly handy in such cases (if you'll forgive the pun). In the following, I made no changes to your code other than replacing line commands, but the appearance is immediately improved (even without need for arraystretch). I will not comment on table design but should mention that booktabs philosophy discourages vertical lines.

\documentclass{article}
\usepackage{mathtools}
\usepackage{booktabs}

\begin{document}    
    
        \begin{table}[h]
        \centering
        \begin{tabular}{@{}c  ll  ll@{}}
            \toprule
            A & B &  & C &  \\
            \midrule
            D & $ 
            \begin{cases}
                3 & \text{if } n = 1 \\
                4 & \text{if } n\ge 1
            \end{cases} $ &  &  &  \\ \midrule 
            E & F &  & G & \\ \bottomrule
        \end{tabular}
    \end{table}
    
\end{document}

enter image description here

3

With {NiceTabular} of nicematrix and its key cell-space-limits.

\documentclass{article}
\usepackage{mathtools}
\usepackage{nicematrix}

\begin{document}

\renewcommand{\arraystretch}{1.2}

\begin{table}[t]
\centering
\begin{NiceTabular}{@{}c|ll|ll@{}}[cell-space-limits=5pt]
\hline
A & B &  & C &  \\
\hline
D & $\begin{cases}
3 & \text{if } n = 1 \\
4 & \text{if } n\ge 1
\end{cases}$ &  & &  \\ \hline
E & F &  & G & \\ \hline
\end{NiceTabular}
\end{table}

\end{document}

OUtput of the above code

1
  • However, I recommend a tabular with booktabs in the spirit of booktabs (without vertical rules). Commented Mar 24 at 11:37

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.