How to fit a math equation to the line width

I used the following two equations to implement a branch function:

\documentclass[conference]{IEEEtran}
\usepackage{amsmath}
\newcommand{\NC}{\mathrm{NC}}

\begin{document}

In Case A, \\

$$\Pr\{\mathrm{NC}|\alpha\}= \left\{ \begin{array}{ll} (1-p)^{n-1}(1-p+p(\alpha + \beta)^{2})^{n-1} & 0\leq \alpha \leq \beta \\ (1-p)^{n-1}(1-p+4p\alpha\beta)^{n-1} & \beta\leq \alpha \leq \beta-1\\ (1-p)^{n-1} (1-p(\alpha - \beta)^{2})^{n-1} & 1-\beta\leq \alpha \leq 1 \\ \end{array} \right.$$ \\

In Case B, \\

$$\Pr\{\mathrm{NC}|\alpha\}= \left\{ \begin{array}{ll} (1-p)^{n-1}(1-p+p(\alpha + \beta)^{2})^{n-1} & 0\leq \alpha \leq \beta \\ (1-p)^{n-1}(1-p+4p\alpha\beta)^{n-1} & \beta\leq \alpha \leq \beta-1\\ (1-p)^{n-1} (1-p(\alpha - \beta)^{2})^{n-1} & 1-\beta\leq \alpha \leq 1 \\ \end{array} \right.$$

\end{document}


But the equations exceeded the line width (9&10) or in other words the column words as seen here:

• Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Please, also consider that your example doesn't produces shown results. – Ignasi May 24 '16 at 15:14
• Partially done. The code corresponds to image, but I don't see any \documentclass, \usepackage or \end{document}. – Ignasi May 24 '16 at 15:49

Don't use \\ for ending lines, except where specifically needed (tabular, array or similar environments) and never leave a blank line before an equation.

Narrow columns and cases don't go along well, so you have only one possibility: splitting the lines, one part with the value, one with the condition. More generous vertical space will help the reader in understanding what refers to what.

\documentclass[twocolumn]{article}
\usepackage{amsmath}

\newcommand{\NC}{\mathrm{NC}}

\begin{document}

$$\Pr\{\NC|\alpha\}= \begin{cases} e^{-2\lambda+\lambda(\alpha+\beta)^{2}} \\ \qquad \text{for } 0\leq \alpha \leq 1-\beta \\[2ex] e^{-2\lambda+4\lambda\alpha\beta} \\ \qquad \text{for } 1-\beta\leq \alpha\leq \beta \\[2ex] e^{-\lambda-\lambda(\alpha-\beta)^{2}} \\ \qquad \text{for }\beta\leq \alpha\leq 1 \end{cases}$$
If $0.5 \leq \beta \leq 1$:
$$\Pr\{\NC|\alpha\}= \begin{cases} e^{-2\lambda+\lambda(\alpha+\beta)^{2}} \\ \qquad \text{for } 0\leq \alpha \leq \beta \\[2ex] e^{-2\lambda+4\lambda\alpha\beta} \\ \qquad \text{for } \beta\leq \alpha\leq 1-\beta \\[2ex] e^{-\lambda-\lambda(\alpha-\beta)^{2}} \\ \qquad \text{for } \beta-1\leq \alpha\leq 1 \end{cases}$$

\end{document}


The other set of equations poses more problems, because of the width, so with the standard page parameters the equation number will be shifted: don't worry about it.

\documentclass[twocolumn]{article}
\usepackage{amsmath}

\newcommand{\NC}{\mathrm{NC}}

\begin{document}

In Case A,
$$\Pr\{\NC|\alpha\}= \begin{cases} (1-p)^{n-1}(1-p+p(\alpha + \beta)^{2})^{n-1}\\ \qquad \text{for } 0\leq \alpha \leq \beta \\[2ex] (1-p)^{n-1}(1-p+4p\alpha\beta)^{n-1} \\ \qquad \text{for } \beta\leq \alpha \leq \beta-1 \\[2ex] (1-p)^{n-1} (1-p(\alpha - \beta)^{2})^{n-1} \\ \qquad \text{for } 1-\beta\leq \alpha \leq 1 \end{cases}$$
In Case B,
$$\Pr\{\mathrm{NC}|\alpha\}= \begin{cases} (1-p)^{n-1}(1-p+p(\alpha + \beta)^{2})^{n-1} \\ \qquad \text{for } 0\leq \alpha \leq \beta \\[2ex] (1-p)^{n-1}(1-p+4p\alpha\beta)^{n-1} \\ \qquad \text{for } \beta\leq \alpha \leq \beta-1 \\[2ex] (1-p)^{n-1} (1-p(\alpha - \beta)^{2})^{n-1} \\ \qquad \text{for } 1-\beta\leq \alpha \leq 1 \end{cases}$$


• could you please update your answer as the question has been updated – Hamm May 24 '16 at 15:34
• there's actually room in the area where the equation number would normally go, so you could fake this out by applying \mathrlap to the first line of each group. – barbara beeton May 24 '16 at 16:35