Math & ScienceHow to stretch cases array?

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

How to stretch cases array?

Post by bkarpuz »

Dear friends,

I use the following code

Code: Select all

\begin{equation}
p(m,n):=
\begin{cases}
\displaystyle\frac{2}{9},&\mathrm{mod}(m,3)=0 \\
\displaystyle\frac{1}{9},&\text{otherwise}
\end{cases}\quad\text{for}\ (m,n)\in\mathbb{Z}_{0}^{2}.\notag
\end{equation}
But in this case, the rows of the cases array appear very closer to each other as in the following graphic.
cases-env.jpg
cases-env.jpg (6.15 KiB) Viewed 7702 times
I used to the following code in preambles to stretch the rows but it did not work. :!:

Code: Select all

\renewcommand{\arraystretch}{1.5}
If possible can you please let me know the right code for stretch the rows of the cases?

Thanks.

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

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

How to stretch cases array?

Post by localghost »

At first, please upload attachments to the forum server next time (reasons can be found in Section 2.5 of the Board Rules).

You can add some additional vertical space between the lines of the cases environment.

Code: Select all

\begin{equation*}
  p(m,n):=
  \begin{cases}
    \dfrac{2}{9},&\text{mod}(m,3)=0 \\[2\jot]
    \dfrac{1}{9},&\text{otherwise}
  \end{cases}\quad\text{for}\ (m,n)\in\mathbb{Z}_{0}^{2}.
\end{equation*}
As an alternative you could typeset the fractions with nicefrac.


Best regards
Thorsten
bkarpuz
Posts: 124
Joined: Thu Dec 18, 2008 4:53 pm

How to stretch cases array?

Post by bkarpuz »

Thanks localghost, it works good.
And I will use the forum's server for images next time.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

How to stretch cases array?

Post by Stefan Kottwitz »

Hi,
bkarpuz wrote: If possible can you please let me know the right code for stretch the rows of the cases?
here's another solution for the general problem: amsmath: cases and \arraystretch.

Stefan
LaTeX.org admin
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

How to stretch cases array?

Post by phi »

The mathtools package provides an easy solution:

Code: Select all

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\begin{document}
\begin{equation*}
  p(m,n) \coloneqq
  \begin{dcases}
    \frac{2}{9},&\bmod(m,3)=0 \\
    \frac{1}{9},&\text{otherwise}
  \end{dcases}
  \quad\text{for } (m,n)\in\mathbb{Z}_{0}^{2}.
\end{equation*}
\end{document}
Also note the use of the commands \coloneqq and \bmod.
Post Reply