Math & ScienceDistance between Matrix Rows with Fractions

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Hrs
Posts: 16
Joined: Sat May 12, 2012 3:13 pm

Distance between Matrix Rows with Fractions

Post by Hrs »

Hi all!

When I compile that:

Code: Select all

\documentclass[a4paper,14pt]{article}
\usepackage{amsmath}

\begin{document}
  \begin{equation}
    \begin{pmatrix}
      {1\over2}&{1\over2}\\
      {1\over2}&{1\over2}
    \end{pmatrix}
  \end{equation}
  \begin{equation}
    \begin{pmatrix}
      \frac{1}{2}&\frac{1}{2}\\
      \frac{1}{2}&\frac{1}{2}
    \end{pmatrix}
  \end{equation}
  $$
    \begin{pmatrix}
      \frac{1}{2}&\frac{1}{2}\\
      \frac{1}{2}&\frac{1}{2}
    \end{pmatrix}
  $$
\end{document}
the distance between rows are very small. How can I easily fix it?

Thank you in advance!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Distance between Matrix Rows with Fractions

Post by localghost »

You can stretch the row height.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage{amsmath}

\begin{document}
  \begin{equation*}
    \renewcommand*{\arraystretch}{1.2}
    \begin{pmatrix}
      \frac{1}{2}&\frac{1}{2}\\
      \frac{1}{2}&\frac{1}{2}
    \end{pmatrix}
  \end{equation*}
\end{document}
If you do this globally in the preamble, this will also affect present {array} and {tabular} environments (and perhaps others, too).


Remarks:
  • The document class option 14pt is invalid. You should get a corresponding warning. Valid font sizes are 10pt (default), 11pt or 12pt.
  • Never ever use $$ … $$ to introduce unnumbered displayed equations. This is TeX syntax and should be replace by \[ … \], which is the correct LaTeX syntax. Furthermore such equations are not affected by the fleqn option for the document class and cause bad spacing (and perhaps other unwanted effects).
  • Do not use \over to typeset fractions. This is also TeX syntax and you should receive complaints from amsmath in the log file (*.log). The correct LaTeX2e syntax \frac{}{} is the only way to go.

Further reading:

Thorsten
Hrs
Posts: 16
Joined: Sat May 12, 2012 3:13 pm

Distance between Matrix Rows with Fractions

Post by Hrs »

The document class option 14pt is invalid.
Oh, yeah. I just used extsizes package and forgot to change value.

Thanks for this method, but perhaps there is a more neat way to solve this problem?

What if I want to use fraction in fraction? It will be better to "teach" \LaTeX automaticly change height of row depending to size of it's content...

Maybe there is some package to do that?
Post Reply