Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The table that I'd like to make does not display fractions with enough space between lines. What's the reasoning for this? (Not enough rep to be able to post a picture yet unfortunately.)

\documentclass{article}
\usepackage{amsmath,amsfonts}
\usepackage{booktabs}

\begin{document}
\begin{table}
\centering
\begin{tabular}{lcccc}
\toprule
\textbf{Care type} & $\mathbb{P}(Pat \cap H)$ & $\mathbb{P}(Pat \cap H')$ & $\mathbb{P}(Pat' \cap H)$ & $\mathbb{P}(Pat' \cap H')$\\
\midrule
Direct care  &$\displaystyle \dfrac{58}{197}$  &  $\displaystyle \dfrac{48}{197}$  & $\displaystyle \dfrac{21}{197}$* &$1-\displaystyle \dfrac{58}{197}$ \\
Housekeeping &$\displaystyle \dfrac{12}{17}$  &  $\displaystyle \dfrac{2}{17}$  & $\displaystyle \dfrac{5}{17}$* &$1-\displaystyle \dfrac{12}{17}$\\
\bottomrule
\end{tabular}
\caption{Probabilities of hand hygiene given direct patient contact}
\label{tab:handwash_given_pat}
\end{table}
\end{document}

Edit: Image added and MWE completed.

Table with too narrow rows

share|improve this question
    
write before the tabular environment \def\arraystretch{1.5} –  Herbert Aug 14 '12 at 8:49
    
This also changes the spacing in the head line. –  Heiko Oberdiek Aug 14 '12 at 8:52
    
Thanks! I tried \def\arraystretch{2}, which is just about acceptable. Is this the best workaround? –  HCAI Aug 14 '12 at 8:59
    
Two suggestions. (1) Why not write 58/197 and so on? (2) All fractions are integral multiples of 1/197, so you could write everything in multiples of 1/197l this would make it easier to compare the probabilities in the same columns. –  Marc van Dongen 2 days ago

2 Answers 2

up vote 7 down vote accepted

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}
    
share|improve this answer
    
Thank you Heiko, this is very useful! :) Somehow it seems that LaTex doesn't deal with deep table cells well. Why do you think this is? –  HCAI Aug 14 '12 at 9:12
1  
In the tables array struts are automatically added, kind of invisible rules with .7\baselineskip height and .3\baselineskip depth. The total amount is changed by \arraystretch. Package array allows the addition of \extrarowheight. The strut stuff works with normal text, but the method is limited if large objects are used. –  Heiko Oberdiek Aug 14 '12 at 10:11
    
Thanks! The "invisible rule" trick is awesome. Exactly what I was looking for ;) –  citronas Apr 21 '13 at 10:49

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.

share|improve this answer
1  
You should probably also mention that if one pursues this route, the numbers will be typeset in scriptstyle mode, with a font size that's reduced by 30 percent relative to textstyle mode used in the OP's code. –  Mico 2 days ago
    
Welcome to TeX.SX! –  Andrew Swann 2 days ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.