Not enough space in table for fractions

Manually the spacing can be fixed by several methods:

  • \renewcommand*{\arraystretch}{2} (see Herbert's comment)
    However, this also affects the spacing of the other lines.

  • Adding a vertical space in the optional argument of \\, e.g.:

    \begin{tabular}{...}
      ...
      ...\\[2ex]
      ...\\[1.5ex]
      \bottomrule
    \end{tabular}
    
  • Adding an invisible rule in the line, e.g.:

    \begin{tabular}{...}
      ...
      \rule{0pt}{3.5ex}Direct care ...\\
      \rule[-2.5ex]{0pt}{7ex}Housekeeping ...\\
      \bottomrule
    \end{tabular}
    

I'll add three other methods.

First, since you load booktabs, you can add \addlinespace between the second and third rows.

Second, you can use the cellspace package, which enables you to define minimal vertical spacings at the top and bottom of cells in columns with specifier prefixed with the letter S (or C if you use siunitx). This way, the contents is vertically centred in the cell, contrary to the use of \arraystretch.

Last, the makecell package, through its \setcellgapes and \makegapedcells commands, adds vertical spacing at the top and bottom of every cell. This can also be done for individual cells with the \Gaped command.

\documentclass{article}
\usepackage{amsmath,amsfonts}
\usepackage{booktabs}
\usepackage{cellspace}%
\setlength\cellspacetoplimit{3pt}
\setlength\cellspacebottomlimit{3pt}
\usepackage{makecell}
\setcellgapes{3pt}

\begin{document}

\begin{table}[!htbp]
  \centering
  \begin{tabular}{l*{4}{>{$}c<{$}}}
    \toprule
    \textbf{Care type} & \mathbb{P}(Pat ∩ H) & \mathbb{P}(Pat ∩ H') &  \mathbb{P}(Pat' ∩ H) & \mathbb{P}(Pat' ∩ H')  \\ \midrule
    Direct care & \dfrac{58}{197} & \dfrac{48}{197} & \dfrac{21}{197} * & 1-\dfrac{58}{197}  \\\addlinespace%
    Housekeeping & \dfrac{12}{17} & \dfrac{2}{17} &\dfrac{5}{17}* &  1- \dfrac{12}{17} \\ \bottomrule
  \end{tabular}
  \caption{Probabilities of hand hygiene given direct patient contact}
  \label{tab:handwash_given_pat}
\end{table}

\begin{table}[!htbp]
  \centering
  \begin{tabular}{l*{4}{>{$}Sc<{$}}}
    \toprule
    \textbf{Care type} &  \mathbb{P}(Pat ∩ H)$ & \mathbb{P}(Pat ∩ H') & \mathbb{P}(Pat' ∩ H)  &  \mathbb{P}(Pat' ∩ H') \\ \midrule
    Direct care & \dfrac{58}{197} & \dfrac{48}{197} & \dfrac{21}{197}* &  1-\dfrac{58}{197} \\%
    Housekeeping & \dfrac{12}{17} & \dfrac{2}{17} & \dfrac{5}{17}* &  1-\dfrac{12}{17} \\ \bottomrule
  \end{tabular}
  \caption{Probabilities of hand hygiene given direct patient contact}
  \label{tab:handwash_given_pat}
\end{table}

\begin{table}[!htbp]
  \centering\makegapedcells
  \begin{tabular}{l*{4}{c}}
    \toprule
    \textbf{Care type} & mathbb{P}(Pat ∩ H) & \mathbb{P}(Pat ∩ H') & \mathbb{P}(Pat' ∩ H) & \mathbb{P}(Pat' ∩ H') \\ \midrule
    Direct care & \dfrac{58}{197} & \dfrac{48}{197} & \dfrac{21}{197}$* & 1-\dfrac{58}{197} \\%
    Housekeeping & \dfrac{12}{17} &\dfrac{2}{17} & \dfrac{5}{17}$* & 1-\dfrac{12}{17} \\ \bottomrule
  \end{tabular}
  \caption{Probabilities of hand hygiene given direct patient contact}
  \label{tab:handwash_given_pat}
\end{table}

\end{document} 

enter image description here


Another option is to use the package units and then replace your \frac{a}{b} with \nicefrac{a}{b}. The numerator and denominator will be offset diagonally and they fit nicely into tables.

Tags:

Tables