32

Possible Duplicate:
How can I increase the line spacing in a matrix?
Using display style fraction in a matrix environment
How to add extra spaces between rows in tabular environment?

When a fraction is used in a matrix environment, not enough vertical space is put between the rows. Wikibooks recommends using the \em command, but this seems like an inelegant solution. Is there an elegant solution?

  • It is always best to compose a MWE that illustrates the problem including the \documentclass so that those trying to help don't have to recreate it. – Peter Grill Nov 02 '11 at 23:30
  • @PeterGrill I would have, but this seems like such an obvious scenario that an MWE isn't necessary and actually clutters the question. Am I wrong? – Quinn Culver Nov 02 '11 at 23:37
  • 1
    Possible duplicates: http://tex.stackexchange.com/questions/26690/how-to-add-extra-spaces-between-rows-in-tabular-environment, http://tex.stackexchange.com/questions/31672/column-padding-in-tables – Werner Nov 02 '11 at 23:39
  • @Quinn: MWEs are always welcome and definitely encouraged, since subjective views may interpret questions differently. – Werner Nov 02 '11 at 23:41
  • Yeah I realize it is not that hard, but anyone who wants to provide a solution will have to create it to test it and if you provide one to start there is less chance of misinterpretations. – Peter Grill Nov 03 '11 at 00:09

3 Answers3

33

One approach is to add extra space between specific lines, with an optional argument to \\:

\left[\begin{matrix}
    \frac{1}{2} & \frac{3}{2} \\
    \frac{5}{2} & \frac{7}{2}
\end{matrix}\right]

produces

While

\left[\begin{matrix}
    \frac{1}{2} & \frac{3}{2} \\[6pt]
    \frac{5}{2} & \frac{7}{2}
\end{matrix}\right]

produces

jtbandes
  • 4,262
19

If you use an array environment then you can use the command

\renewcommand{\arraystretch}{2.5}

and tweak it to whatever you would like. I have loaded the amsmath package to use \dfrac

screenshot

\documentclass{article}
\usepackage{amsmath}

\begin{document}

Default:
\[
    \left[
         \begin{array}{ccc}
         \dfrac{5}{6} & \dfrac{1}{6} & 0           \\
         \dfrac{5}{6} & 0           & \dfrac{1}{6} \\
         0           & \dfrac{5}{6} & \dfrac{1}{6}
        \end{array}
    \right]
\]
\renewcommand{\arraystretch}{2.5}
Stretched:
\[
    \left[
         \begin{array}{ccc}
         \dfrac{5}{6} & \dfrac{1}{6} & 0           \\
         \dfrac{5}{6} & 0           & \dfrac{1}{6} \\
         0           & \dfrac{5}{6} & \dfrac{1}{6}
        \end{array}
    \right]
\]
\end{document}
cmhughes
  • 100,947
1

In plain-tex format at least, \matrix calls \normalbaselines, which resets the (base)lineskip(limit)'s to normal(base)lineskip(limit)'s. Plain also has a macro called \openup<dimen> which increases the (base)lineskip(limit)'s by given <dimen>.

So it would seem logical to define a macro \openupnormal, which would do the same as \openup, only for normal(base)lineskip(limit)'s:

\catcode`@=11
\def\openupnormal{\afterassignment\@penupnormal\dimen@=}
\def\@penupnormal{\advance\normallineskip\dimen@
  \advance\normalbaselineskip\dimen@
  \advance\normallineskiplimit\dimen@}
\catcode`@=12

so that one could do:

$$
  \left[
    \openupnormal1\jot\matrix{ % inside this group, increase the
                               % normal(base)lineskip(limit)'s by 1 jot
      {5\over6} & {1\over6} & 0 \cr
      {5\over6} & 0 & {1\over6} \cr
      0 & {5\over6} & {1\over6} \cr
    } % the group ends here, and so does the effect of \openupnormal
  \right]
  \quad
  \left[
    \matrix{
      {5\over6} & {1\over6} & 0 \cr
      {5\over6} & 0 & {1\over6} \cr
      0 & {5\over6} & {1\over6} \cr
    }
  \right]
$$
\bye

enter image description here

(Note that there is no \displaystyle in effect in the above fractions, unlike in \dfrac)

morbusg
  • 25,490
  • 4
  • 81
  • 162
  • I use LaTeX, not plain-TeX. Will this still work? Is there an analogous solution for LaTeX? – Quinn Culver Nov 04 '11 at 15:36
  • I tried it with LaTeX and no errors. But I suppose you'd write things differently with LaTeX (\makeatletter/\makeatother instead of \catcode's, \frac/\dfrac instead of {x\over y}, \\[/\\] instead of $$ etc. – morbusg Nov 04 '11 at 15:48