90

I'm trying to create a pmatrix whose components are rather complicated fractions (Christoffel symbols), and the line spacing is too small making the whole thing a bit cramped and hard to read.

Is there any easy way to increase the spacing (about 1.5 the default would be perfect)?

3 Answers 3

120

You could redefine \arraystretch. This can be made locally, within a group or environment. For example:

\begingroup
\renewcommand*{\arraystretch}{1.5}
% your pmatrix expression
\endgroup

But you could do it in the preamble too, then it would have effect on all matrices and arrays.

Here's a redefinition of an internal amsmath LaTeX macro for customizing line spacing in specific matrices arbitrarily as desired:

\makeatletter
\renewcommand*\env@matrix[1][\arraystretch]{%
  \edef\arraystretch{#1}%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{*\c@MaxMatrixCols c}}
\makeatother

After putting this in your preamble, you can write

\begin{pmatrix}[1.5]
...

vary the value as you like, with pmatrix, vmatrix, bmatrix and alike, or use it without the optional argument as usually.

I used it similar in my blog some years ago.

Complete small example to show the difference:

\documentclass{article}
\usepackage{amsmath}
\makeatletter
\renewcommand*\env@matrix[1][\arraystretch]{%
  \edef\arraystretch{#1}%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{*\c@MaxMatrixCols c}}
\makeatother
\begin{document}
\[
  \begin{pmatrix}
    1 & 0 \\
    0 & 1
  \end{pmatrix}
  =
  \begin{pmatrix}[1.5]
    1 & 0 \\
    0 & 1
  \end{pmatrix}
\]
\end{document}

matrices in two sizes

2
  • How can one change the stretching in the preamble and have it done? Do one have to write \begin{pmatrix}[1.5] to stretch it?: EDIT: OK I found it: just add "\renewcommand*{\arraystretch}{1.5}" in the preamble and you're good to go. May 1, 2014 at 18:14
  • How would I use this along with say left or right align in the matrix?
    – D.R
    Nov 4, 2021 at 6:49
61

By redefining \arraystretch you can change the vertical space between the all rows; using the optional argument for \\ you can control the vertical space for individual lines:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
\begin{pmatrix}
  \dfrac{a}{b} & c\\
  \dfrac{a}{b} & d\\
  \dfrac{a}{b} & e
\end{pmatrix}
\]

\[
\renewcommand\arraystretch{2}
\begin{pmatrix}
  \dfrac{a}{b} & c\\
  \dfrac{a}{b} & d\\
  \dfrac{a}{b} & e
\end{pmatrix}
\]

\[
\begin{pmatrix}
  \dfrac{a}{b} & c \\[1em]
  \dfrac{a}{b} & d\\[2em]
  \dfrac{a}{b} & e
\end{pmatrix}
\]

\end{document}

enter image description here

3
  • 14
    \[1em] This is very helpful, thanks. May 21, 2014 at 19:25
  • 12
    +1 for \\[1em]
    – Wauzl
    Nov 25, 2015 at 8:44
  • Perfect, just used [1em] for a normal matrix and it works! \begin{matrix} a & b \[1em] c & d \end{matrix}
    – Torben.
    Oct 21, 2022 at 19:14
1

Individual veritcal spaces can be done with \\[3pt] option, horizontal by \, or \!

\[
  \begin{pmatrix}
    1 & 0 \\
    0 & 1
  \end{pmatrix},
  \begin{pmatrix}
    1 & 0 \\[3pt]
    0 & 1
  \end{pmatrix},
  \begin{pmatrix}
    1 & \!\!\!\! 0 \\
    0 & \!\!\!\! 1
  \end{pmatrix}
\]

You must log in to answer this question.

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