3

As the title says, when I am writing my code the fractions are a little too close to eah others.

\documentclass{article}
\usepackage{mathtools,amsmath,amssymb,amsfonts}
\begin{document}
\[
  \left(
  \begin{pmatrix}
    -1 \\ 
    -\frac{1}{3} \\ 
     \frac{1}{2\sqrt{2}} \\ 
     2
  \end{pmatrix}
  \right).
\]
\end{document}

EDIT : I don't why it doesn't show the matrix here.

  • 1
    You could add e.g. \renewcommand{\arraystretch}{1.2} before \begin{pmatrix}. Your code does not compile because \frac{2} misses a denominator. – Schrödinger's cat Oct 13 at 19:10
  • @Schrödinger'scat oops I have miswritten, it was \sqrt instead of \frac – Moh18 Oct 13 at 19:19
  • You also shouldn't encase a pmatrix environment in \left( ... \right). – Mico Oct 13 at 19:29
  • @Mico Normally, I have multiple vectors into this – Moh18 Oct 13 at 19:44
  • 1
    The reason the output of your example doesn't show up here is explained in Why doesn't maths render as maths? – barbara beeton Oct 13 at 20:15
2

Short of increasing the value of \arraystretch by a factor of two or more, here are two solutions to the problem of the denominator term of the upper fraction being too close to the numerator term of the lower fraction:

  • For a modest increase in vertical separation, insert a \mathstrut directive in the numerator of the lower fraction.

  • For a more pronounced increase in vertical separation, insert a \mathstrut directive in the denominator of the upper fraction.

Incidentally, the definition of \mathstrut is \vphantom{(}, i.e., it's a typographic strut that has the height and depth of the ( symbol.

The following screenshot shows first the original setup, then the first solution, then the second solution.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
  \begin{pmatrix}
    -\frac{1}{3} \\ 
     \frac{1}{2\sqrt{2}} 
  \end{pmatrix}
  \begin{pmatrix}
    -\frac{1}{3} \\ 
     \frac{1\mathstrut}{2\sqrt{2}} 
  \end{pmatrix}
  \begin{pmatrix}
    -\frac{1}{3\mathstrut} \\ 
     \frac{1}{2\sqrt{2}} 
  \end{pmatrix}
\]
\end{document}
2

You can add some additional vertical spacing manually, like this (approximately):

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
  \begin{pmatrix}
    -1 \\ 
    -\frac{1}{3} \\[.5ex] 
     \frac{1}{2\sqrt{2}} \\
     2
  \end{pmatrix}
\]
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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