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?

5
  • 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. Commented Nov 2, 2011 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? Commented Nov 2, 2011 at 23:37
  • 1
  • @Quinn: MWEs are always welcome and definitely encouraged, since subjective views may interpret questions differently.
    – Werner
    Commented Nov 2, 2011 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. Commented Nov 3, 2011 at 0:09

3 Answers 3

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

9
  • 4
    Note that the OP wanted to avoid this approach
    – cmhughes
    Commented Nov 3, 2011 at 2:12
  • @cmhughes: Hm, I didn't see that in the post. Where was it stated?
    – jtbandes
    Commented Nov 3, 2011 at 4:26
  • Wikibooks recommends using the \em command, but this seems like an inelegant solution. No big deal though, it gets the job done :)
    – cmhughes
    Commented Nov 3, 2011 at 4:48
  • OK, I did see that, so I guess my question is... is \em equivalent to \\?
    – jtbandes
    Commented Nov 3, 2011 at 4:54
  • 1
    The Wikibooks link recommends using \\[0.3em] and you used \\[6pt]. The similarity (in my mind) is that both are manual approaches.
    – cmhughes
    Commented Nov 3, 2011 at 5:14
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}
3
  • But isn't this bad because it used array where matrix is more appropriate? Commented Nov 4, 2011 at 15:37
  • @Quinn: that's up to you! If you'd prefer to use matrix then have a look at the links that people have posted as comments
    – cmhughes
    Commented Nov 4, 2011 at 15:46
  • This works for more than two lines as it centers the middle lines.
    – Yvon
    Commented Mar 17, 2021 at 20:27
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)

2
  • I use LaTeX, not plain-TeX. Will this still work? Is there an analogous solution for LaTeX? Commented Nov 4, 2011 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
    Commented Nov 4, 2011 at 15:48

Not the answer you're looking for? Browse other questions tagged .