# Alignment in equation environment

I am not able to align equations within a curly bracket. My code is the following:

\documentclass[12pt, A4paper]{article}
\begin{document}
Consider the following:
$P\Big[\frac{1}{2}+\mu \Big ]=\left\{ \begin{array}{l} \displaystyle{0\hspace{1cm}\mathrm{if}\quad \mu <-\frac{1}{2}} \\ \displaystyle{\frac{1}{2}+\mu \hspace{0.3cm}\mathrm{if}\quad -\frac{1}{2}% \leq \mu \leq \frac{1}{2}} \\ \displaystyle{1\hspace{1cm}\mathrm{if}\quad \mu >\frac{1}{2}}% \end{array} \right.$
\end{document}

This produce the following:

As you may notice, the "if" are not aligned and so the "=" are. In addition, I would like to increase a little bit the space between rows to avoid that the "1" in the last fraction is "attached" to the "2" in the second raw. How can I fix this? Thanks for your help.

• Use two columns in the array. Even better use the cases env, it already incluse a two column array and the brace (much cleaner code). And remove the hspace – daleif Jun 28 '16 at 19:57
• If you want to force it into displaystyle, use the mathtools package, and its dcases env – daleif Jun 28 '16 at 19:58
• @daleif. Thanks for your reply. I do not need to use displaystyle. I tried with cases, but apparently everything goes into a single row, rather than in 3. – Dario Jun 28 '16 at 20:01
• Please update your code, you of course need \\ to switch row, and & to switch columns – daleif Jun 28 '16 at 20:05

Here's a solution that aligns three columns, adapted from this answer.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
Consider the following:
$P\Big[\frac{1}{2}+\mu \Big] = \setlength{\arraycolsep}{0pt} \renewcommand{\arraystretch}{2} \left\{ \begin{array}{l @{\quad} l r l} 0 & \text{if } & \mu &{}< -\dfrac{1}{2}\\ \dfrac{1}{2} & \text{if } & -\dfrac{1}{2} &{}< \mu < \dfrac{1}{2}\\ 1 & \text{if } & \mu &{}> \dfrac{1}{2}. \end{array} \right.$
\end{document}

I made a couple simplifications: you can use \dfrac rather than carrying around \displaystyle all the time, and \text behaves better than \mathrm (though it does require you to use amsmath). The \arraystretch line sets the vertical spacing, preventing collisions.

• This is even better! I will use this indeed, since it also align the ">" and "<" symbols. – Dario Jun 28 '16 at 20:15

I'd forego the use of \displaystyle, setting the entire construction using amsmath's cases:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

Consider the following:
$P\bigl[ \tfrac{1}{2} +\mu \bigr] = \begin{cases} 0 & \text{if }\mu <-\tfrac{1}{2} \\ \tfrac{1}{2} + \mu & \text{if }-\tfrac{1}{2} \leq \mu \leq \tfrac{1}{2} \\ 1 & \text{if }\mu > \tfrac{1}{2} \end{cases}$

\end{document}

You can increase the gap between rows inside the cases environment using \$<len>], where you specify the length <len> (say 2\jot or 20pt, say). • Thanks I tried using cases env within an equation env and it worked. – Dario Jun 28 '16 at 20:12 Here's a solution that uses the dcases environment provided by the mathtools package. It works like cases, except that all contents are rendered in \displaystyle automatically. The screenshot also shows the output of the corresponding cases environment. \documentclass[12pt,a4paper]{article} \usepackage{mathtools} \begin{document} Consider the following: \[ P\Bigl[ \frac{1}{2}+\mu \Bigr]= \begin{dcases} 0 & \text{if}\quad\phantom{{-}\frac{1}{2}\leq{}}\mu <-\frac{1}{2} \\ \frac{1}{2}+\mu & \text{if}\quad{-}\frac{1}{2}\leq \mu \leq +\frac{1}{2} \\ 1 & \text{if}\quad{+}\frac{1}{2}<\mu \end{dcases}$

$P\bigl[ \tfrac{1}{2}+\mu \bigr]= \begin{cases} 0 & \text{if}\quad\phantom{{-}\frac{1}{2}\leq{}}\mu <-\frac{1}{2} \\ \frac{1}{2}+\mu & \text{if}\quad{-}\frac{1}{2}\leq \mu \leq +\frac{1}{2} \\ 1 & \text{if}\quad{+}\frac{1}{2}<\mu \end{cases}$
\end{document}