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.

I'm making a table using booktabs. One of the columns contains a series of fractions.

\documentclass[12pt, letterpaper]{article}
    \usepackage{nag}
    \usepackage[margin=1.0in]{geometry}

    \usepackage{amsmath}

    \usepackage{booktabs}
    \usepackage[tableposition=top]{caption}

\begin{document}

\begin{table}[htbp]
\centering
\caption{Test}
\begin{tabular}{llll}
    \toprule
    A & B & C & D \\
    \midrule
    A: $\frac{6}{16}$ B: $\frac{5}{16}$ C: $\frac{3}{16}$ D: $\frac{2}{16}$ & 1.9375919592 & 1.88285606369 & 0.0547358955059 \\
    A: $\frac{6}{16}$ B: $\frac{5}{16}$ C: $\frac{4}{16}$ D: $\frac{1}{16}$ & 1.94014431443 & 1.80503653258 & 0.135107781856 \\
    A: $\frac{6}{16}$ B: $\frac{6}{16}$ C: $\frac{2}{16}$ D: $\frac{2}{16}$ & 1.87649654966 & 1.81127812446 & 0.0652184251977 \\
    A: $\frac{6}{16}$ B: $\frac{6}{16}$ C: $\frac{3}{16}$ D: $\frac{1}{16}$ & 1.87992559246 & 1.76409765557 & 0.115827936888 \\
    A: $\frac{7}{16}$ B: $\frac{3}{16}$ C: $\frac{3}{16}$ D: $\frac{3}{16}$ & 1.93245604561 & 1.88024081494 & 0.0522152306624 \\
    A: $\frac{7}{16}$ B: $\frac{4}{16}$ C: $\frac{3}{16}$ D: $\frac{2}{16}$ & 1.86806360636 & 1.84960175271 & 0.0184618536479 \\
    A: $\frac{7}{16}$ B: $\frac{4}{16}$ C: $\frac{4}{16}$ D: $\frac{1}{16}$ & 1.87194209421 & 1.7717822216 & 0.100159872612 \\
    A: $\frac{7}{16}$ B: $\frac{5}{16}$ C: $\frac{2}{16}$ D: $\frac{2}{16}$ & 1.81500630063 & 1.79617969195 & 0.0188266086843 \\
    A: $\frac{7}{16}$ B: $\frac{5}{16}$ C: $\frac{3}{16}$ D: $\frac{1}{16}$ & 1.81178637864 & 1.74899922306 & 0.0627871555774 \\
    \bottomrule
\end{tabular}
\end{table}

\end{document}

This is what is looks like:

table

The height of each row is just a tad too small -- the fractions are uncomfortably squished. Is there any way I can increase the row height so the fractions fit more comfortably?

If possible, I'd also like to avoid making any changes to other tables that I might add to my document.

share|improve this question
    
Welcome to TeX.SE. –  Peter Grill Nov 2 '12 at 5:42

6 Answers 6

up vote 14 down vote accepted

For single lines booktabs provides \addlinespace:

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}\centering
\begin{tabular}{lrc} 
\toprule[2pt]
a & b & c \\ 
\cmidrule[1pt](rl){1-3}
d & e & f \\ 
j & k & l \\ 
\addlinespace[0.5em]
g & h & i \\ 
\bottomrule[2pt] 
\end{tabular}\caption{abcde}
\end{table}
\end{document}

screenshot taken from Beamer document

share|improve this answer
    
Though your output more looks like beamer (no Table number, sans serif font) and you definetly defined a german package - the addlinespace is the “right” way to do it, which is provided by booktabs –  Ronny Nov 2 '12 at 8:38

The easiest here would be to adjust the value of \arraystretch. For example,

\renewcommand{\arraystretch}{2}

Here's a view on the difference:

enter image description here

\documentclass[12pt, letterpaper]{article}
%\usepackage{amsmath}
%\usepackage{nag}
\usepackage[margin=1.0in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
%\usepackage[tableposition=top]{caption}

\newcommand{\mytable}{%
  \begin{tabular}{llll}
    \toprule
    A & B & C & D \\
    \midrule
    A: $\frac{6}{16}$ B: $\frac{5}{16}$ C: $\frac{3}{16}$ D: $\frac{2}{16}$ & 1.9375919592 & 1.88285606369 & 0.0547358955059 \\
    A: $\frac{6}{16}$ B: $\frac{5}{16}$ C: $\frac{4}{16}$ D: $\frac{1}{16}$ & 1.94014431443 & 1.80503653258 & 0.135107781856 \\
    A: $\frac{6}{16}$ B: $\frac{6}{16}$ C: $\frac{2}{16}$ D: $\frac{2}{16}$ & 1.87649654966 & 1.81127812446 & 0.0652184251977 \\
    A: $\frac{6}{16}$ B: $\frac{6}{16}$ C: $\frac{3}{16}$ D: $\frac{1}{16}$ & 1.87992559246 & 1.76409765557 & 0.115827936888 \\
    A: $\frac{7}{16}$ B: $\frac{3}{16}$ C: $\frac{3}{16}$ D: $\frac{3}{16}$ & 1.93245604561 & 1.88024081494 & 0.0522152306624 \\
    A: $\frac{7}{16}$ B: $\frac{4}{16}$ C: $\frac{3}{16}$ D: $\frac{2}{16}$ & 1.86806360636 & 1.84960175271 & 0.0184618536479 \\
    A: $\frac{7}{16}$ B: $\frac{4}{16}$ C: $\frac{4}{16}$ D: $\frac{1}{16}$ & 1.87194209421 & 1.7717822216 & 0.100159872612 \\
    A: $\frac{7}{16}$ B: $\frac{5}{16}$ C: $\frac{2}{16}$ D: $\frac{2}{16}$ & 1.81500630063 & 1.79617969195 & 0.0188266086843 \\
    A: $\frac{7}{16}$ B: $\frac{5}{16}$ C: $\frac{3}{16}$ D: $\frac{1}{16}$ & 1.81178637864 & 1.74899922306 & 0.0627871555774 \\
    \bottomrule
\end{tabular}
}

\begin{document}

\begin{table}
  \centering
  \caption{Test}
  \mytable
\end{table}

\begin{table}
  \centering
  \caption{Test}
  \renewcommand{\arraystretch}{2}
  \mytable
\end{table}

\end{document}

Note that this affects the entire table. For more (including individual modifications), see Column padding in tables.

share|improve this answer
    
I don't recommend this since \arraystretch in conjunction with booktabs breaks the symmetry as you can clearly see above! –  smoneck Oct 13 at 17:10

This might seem complicated, but allows for fine tuning the output: since fractions are the culprits in this particular situation and changing \arraystretch would affect all table rows, I propose to use a different command for the fractions, so as to insert a strut next to them; this strut is larger than the normal one and computed from the fractions themselves.

\documentclass[12pt, letterpaper]{article}
\usepackage[margin=1.0in]{geometry}

\usepackage{amsmath}

\usepackage{booktabs}
\usepackage[tableposition=top]{caption}

\newcommand{\fracpadding}{}
\newcommand{\setfracpadding}[1][2pt]{%
  \sbox0{$\frac{1}{2}$}%
  \dimen0=\ht0 \advance\dimen0 #1\relax
  \dimen2=\dp0 \advance\dimen2 #1\relax
  \edef\fracpadding{\vrule width 0pt height \the\dimen0 depth \the\dimen2\relax}%
}
\newcommand{\afrac}[2]{\fracpadding\frac{#1}{#2}}


\begin{document}

\begin{table}[htbp]
\centering
\setfracpadding
\caption{Test}
\begin{tabular}{llll}
\toprule
A & B & C & D \\
\midrule
A: $\afrac{6}{16}$ B: $\afrac{5}{16}$ C: $\afrac{3}{16}$ D: $\afrac{2}{16}$ & 1.9375919592 & 1.88285606369 & 0.0547358955059 \\
A: $\afrac{6}{16}$ B: $\afrac{5}{16}$ C: $\afrac{4}{16}$ D: $\afrac{1}{16}$ & 1.94014431443 & 1.80503653258 & 0.135107781856 \\
A: $\afrac{6}{16}$ B: $\afrac{6}{16}$ C: $\afrac{2}{16}$ D: $\afrac{2}{16}$ & 1.87649654966 & 1.81127812446 & 0.0652184251977 \\
A: $\afrac{6}{16}$ B: $\afrac{6}{16}$ C: $\afrac{3}{16}$ D: $\afrac{1}{16}$ & 1.87992559246 & 1.76409765557 & 0.115827936888 \\
A: $\afrac{7}{16}$ B: $\afrac{3}{16}$ C: $\afrac{3}{16}$ D: $\afrac{3}{16}$ & 1.93245604561 & 1.88024081494 & 0.0522152306624 \\
A: $\afrac{7}{16}$ B: $\afrac{4}{16}$ C: $\afrac{3}{16}$ D: $\afrac{2}{16}$ & 1.86806360636 & 1.84960175271 & 0.0184618536479 \\
A: $\afrac{7}{16}$ B: $\afrac{4}{16}$ C: $\afrac{4}{16}$ D: $\afrac{1}{16}$ & 1.87194209421 & 1.7717822216 & 0.100159872612 \\
A: $\afrac{7}{16}$ B: $\afrac{5}{16}$ C: $\afrac{2}{16}$ D: $\afrac{2}{16}$ & 1.81500630063 & 1.79617969195 & 0.0188266086843 \\
A: $\afrac{7}{16}$ B: $\afrac{5}{16}$ C: $\afrac{3}{16}$ D: $\afrac{1}{16}$ & 1.81178637864 & 1.74899922306 & 0.0627871555774 \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

The default padding is 2pt above and below the fraction; one can also say \setfracpadding[3pt] or with another length. Instead of setting it globally, I suggest to set it where needed; so if you change your mind and decide to typeset a table with such fractions in smaller type, you can simply add the \small or \footnotesize declaration just before \setfracpadding.

enter image description here

share|improve this answer

This is not a robust way of doing what you want but just a rusty hack:

\documentclass[12pt, letterpaper]{article}
%\usepackage{amsmath}
%\usepackage{nag}
\usepackage[margin=1.0in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
%\usepackage[tableposition=top]{caption}

\newcommand{\vhtable}{\rule{0pt}{15pt}}% defines the separation and can be different if you so desire for each different row.
\begin{document}

  \begin{tabular}{llll}
    \toprule
    A & B & C & D \\
    \midrule
    \vhtable A: $\frac{6}{16}$ B: $\frac{5}{16}$ C: $\frac{3}{16}$ D: $\frac{2}{16}$ & 1.9375919592 & 1.88285606369 & 0.0547358955059 \\
    \vhtable A: $\frac{6}{16}$ B: $\frac{5}{16}$ C: $\frac{4}{16}$ D: $\frac{1}{16}$ & 1.94014431443 & 1.80503653258 & 0.135107781856 \\
    \vhtable A: $\frac{6}{16}$ B: $\frac{6}{16}$ C: $\frac{2}{16}$ D: $\frac{2}{16}$ & 1.87649654966 & 1.81127812446 & 0.0652184251977 \\
    \vhtable A: $\frac{6}{16}$ B: $\frac{6}{16}$ C: $\frac{3}{16}$ D: $\frac{1}{16}$ & 1.87992559246 & 1.76409765557 & 0.115827936888 \\
    \vhtable A: $\frac{7}{16}$ B: $\frac{3}{16}$ C: $\frac{3}{16}$ D: $\frac{3}{16}$ & 1.93245604561 & 1.88024081494 & 0.0522152306624 \\
    \vhtable A: $\frac{7}{16}$ B: $\frac{4}{16}$ C: $\frac{3}{16}$ D: $\frac{2}{16}$ & 1.86806360636 & 1.84960175271 & 0.0184618536479 \\
    \vhtable A: $\frac{7}{16}$ B: $\frac{4}{16}$ C: $\frac{4}{16}$ D: $\frac{1}{16}$ & 1.87194209421 & 1.7717822216 & 0.100159872612 \\
    \vhtable A: $\frac{7}{16}$ B: $\frac{5}{16}$ C: $\frac{2}{16}$ D: $\frac{2}{16}$ & 1.81500630063 & 1.79617969195 & 0.0188266086843 \\
    \vhtable A: $\frac{7}{16}$ B: $\frac{5}{16}$ C: $\frac{3}{16}$ D: $\frac{1}{16}$ & 1.81178637864 & 1.74899922306 & 0.0627871555774 \\
    \bottomrule
\end{tabular}

\end{document}

enter image description here

You can change the height of the rule, that is, change 15pt to whatever you feel should be the right height separation.

share|improve this answer
1  
this would be a bit nicer if the rule had its extent divided between height and depth. there's a bit more space than needed above the first row, and not enough after the last row. some experimentation is probably necessary, but i'd start at 10pt above and 5 below to keep the total 15 used in the example. –  barbara beeton Nov 2 '12 at 13:39
    
@barbarabeeton I agree. Will edit as soon as I have some time or if you can add it in, no problem. –  azetina Nov 2 '12 at 17:12

I'd avoid the problem by using slightly smaller in-line fractions with \nfrac{7}{16}. See also how to define \xfrac, another macro (and package) for in-line fractions.

\documentclass[12pt, letterpaper]{article}
\usepackage[margin=1.0in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{booktabs}% http://ctan.org/pkg/booktabs

\makeatletter
\def\nfrac#1#2{\check@mathfonts%
    \raise.5ex\hbox{\the\scriptfont0 #1}%
    \kern-.1em/\kern-.15em%
    \lower.25ex\hbox{\the\scriptfont0 #2}}
\makeatother

\newcommand{\mytable}{%
  \begin{tabular}{llll}
    \toprule
    A & B & C & D \\
    \midrule
    A: $\nfrac{6}{16}$ B: $\nfrac{5}{16}$ C: $\nfrac{3}{16}$ D: $\nfrac{2}{16}$ & 1.9375919592 & 1.88285606369 & 0.0547358955059 \\
    A: $\nfrac{6}{16}$ B: $\nfrac{5}{16}$ C: $\nfrac{4}{16}$ D: $\nfrac{1}{16}$ & 1.94014431443 & 1.80503653258 & 0.135107781856 \\
    A: $\nfrac{6}{16}$ B: $\nfrac{6}{16}$ C: $\nfrac{2}{16}$ D: $\nfrac{2}{16}$ & 1.87649654966 & 1.81127812446 & 0.0652184251977 \\
    A: $\nfrac{6}{16}$ B: $\nfrac{6}{16}$ C: $\nfrac{3}{16}$ D: $\nfrac{1}{16}$ & 1.87992559246 & 1.76409765557 & 0.115827936888 \\
    A: $\nfrac{7}{16}$ B: $\nfrac{3}{16}$ C: $\nfrac{3}{16}$ D: $\nfrac{3}{16}$ & 1.93245604561 & 1.88024081494 & 0.0522152306624 \\
    A: $\nfrac{7}{16}$ B: $\nfrac{4}{16}$ C: $\nfrac{3}{16}$ D: $\nfrac{2}{16}$ & 1.86806360636 & 1.84960175271 & 0.0184618536479 \\
    A: $\nfrac{7}{16}$ B: $\nfrac{4}{16}$ C: $\nfrac{4}{16}$ D: $\nfrac{1}{16}$ & 1.87194209421 & 1.7717822216 & 0.100159872612 \\
    A: $\nfrac{7}{16}$ B: $\nfrac{5}{16}$ C: $\nfrac{2}{16}$ D: $\nfrac{2}{16}$ & 1.81500630063 & 1.79617969195 & 0.0188266086843 \\
    A: $\nfrac{7}{16}$ B: $\nfrac{5}{16}$ C: $\nfrac{3}{16}$ D: $\nfrac{1}{16}$ & 1.81178637864 & 1.74899922306 & 0.0627871555774 \\
    \bottomrule
\end{tabular}
}

\begin{document}

\begin{table}
  \centering
  \caption{\strut Test}
  \mytable
\end{table}

\end{document}

Table using \nfrac

share|improve this answer

Whereas I would advice to arraystretch as in Werners answer, you can use the following macro TabV to make vertical room around a table entry. It's handy if you don't want to increase the spacing for all lines.

In the following example only the second and 6th line got more vertical space:

\documentclass[12pt,a4paper]{article}
\usepackage{booktabs}


\newcommand*{\TabV}[1]{%
  \setlength{\fboxrule}{0pt}\fbox{\hspace*{-\fboxsep}#1\hspace*{-\fboxsep}}}

\begin{document}

\begin{tabular}{llll}
    \toprule
    A & B & C & D \\
    \midrule
    A: $\frac{6}{16}$ B: $\frac{5}{16}$ C: $\frac{3}{16}$ D: $\frac{2}{16}$ & 1.9375919592 & 1.88285606369 & 0.0547358955059 \\
    A: \TabV{$\frac{6}{16}$} B: $\frac{5}{16}$ C: $\frac{4}{16}$ D: $\frac{1}{16}$ & 1.94014431443 & 1.80503653258 & 0.135107781856 \\
    A: $\frac{6}{16}$ B: $\frac{6}{16}$ C: $\frac{2}{16}$ D: $\frac{2}{16}$ & 1.87649654966 & 1.81127812446 & 0.0652184251977 \\
    A: $\frac{6}{16}$ B: $\frac{6}{16}$ C: $\frac{3}{16}$ D: $\frac{1}{16}$ & 1.87992559246 & 1.76409765557 & 0.115827936888 \\
    A: $\frac{7}{16}$ B: $\frac{3}{16}$ C: $\frac{3}{16}$ D: $\frac{3}{16}$ & 1.93245604561 & 1.88024081494 & 0.0522152306624 \\
    A: $\frac{7}{16}$ B: \TabV{$\frac{4}{16}$} C: $\frac{3}{16}$ D: $\frac{2}{16}$ & 1.86806360636 & 1.84960175271 & 0.0184618536479 \\
    A: $\frac{7}{16}$ B: $\frac{4}{16}$ C: $\frac{4}{16}$ D: $\frac{1}{16}$ & 1.87194209421 & 1.7717822216 & 0.100159872612 \\
    A: $\frac{7}{16}$ B: $\frac{5}{16}$ C: $\frac{2}{16}$ D: $\frac{2}{16}$ & 1.81500630063 & 1.79617969195 & 0.0188266086843 \\
    A: $\frac{7}{16}$ B: $\frac{5}{16}$ C: $\frac{3}{16}$ D: $\frac{1}{16}$ & 1.81178637864 & 1.74899922306 & 0.0627871555774 \\
    \bottomrule
\end{tabular}

\end{document}

enter image description here

share|improve this answer

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.