6

I'm trying to split the condition in a set of equations; see figure.

enter image description here

This is my code:

\begin{align*}
\rho(X,Y)&=1&
\begin{split}
\text{if and only if }\mathbb P(Y=\alpha X+\beta)=1\\
\text{for some real $\alpha$ and $\beta$ with }\alpha>0,
\end{split}\\
\rho(X,Y)&=-1&
\begin{split}
\text{if and only if }\mathbb P(Y=\alpha X+\beta)=1\\
\text{for some real $\alpha$ and $\beta$ with }\alpha<0.
\end{split}
\end{align*}

However, the first line of the condition isn't at the same level as the equation. I don't like it how the conditions are aligned.

Does anyone know how to fix this, or what other environment to use?

4

Please post full documents not fragments, I'd use parbox or aligned

enter image description here

\documentclass{article}

\usepackage{amsmath,amsfonts}

\begin{document}

a
\begin{align*}
\rho(X,Y)&=1&&
\parbox[t]{5cm}{
if and only if $\mathbb P(Y=\alpha X+\beta)=1$\\
for some real $\alpha$ and $\beta$ with $\alpha>0$,}
\\[\jot]
\rho(X,Y)&=-1&&
\parbox[t]{5cm}{if and only if $\mathbb P(Y=\alpha X+\beta)=1$\\
for some real $\alpha$ and $\beta$ with $\alpha<0$.}
\end{align*}

or
\begin{align*}
\rho(X,Y)&=1&&
\begin{aligned}[t]\text{if and only if }\mathbb P(Y=\alpha X+\beta)=1\\
\text{for some real $\alpha$ and $\beta$ with }\alpha>0,
\end{aligned}\\[\jot]
\rho(X,Y)&=-1&&
\begin{aligned}[t]\text{if and only if }\mathbb P(Y=\alpha X+\beta)=1\\
\text{for some real $\alpha$ and $\beta$ with }\alpha<0.
\end{aligned}
\end{align*}
\end{document}
|improve this answer|||||
5

How about the amsmath environment cases? Like this:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}

\begin{equation*}
\rho(X,Y)=
\begin{cases}
\phantom{-}1 & \text{if and only if $\mathbb{P}(Y=\alpha X+\beta)=1$}
       \\
       &\text{for some real $\alpha$ and $\beta$ with $\alpha >0$,}
\\[4pt]
    -1 & \text{if and only if $\mathbb{P}(Y=\alpha X+\beta)=1$}
       \\
       &\text{for some real $\alpha$ and $\beta$ with $\alpha < 0$.}
\end{cases}
\end{equation*}

\end{document}

Multiline conditions with cases

If desired, the line spacing between the pair of lines in each two-line condition could be tightened up a bit by using, say, \\[-2pt] in place of the first and third instance of \\

|improve this answer|||||
  • Right! (Just forgot I was already in math mode. Edit made. – murray Jan 30 '17 at 22:29
3

A variant not mentioned in other answers, which uses tabular.

It has the advantage that you don't need to guess the width of the \parbox and avoids clumsy \text macros. The specifier @{}l@{} means one left aligned column with no padding on either side.

With alignat you have finer control over the space between the two parts.

\documentclass{article}
\usepackage{amsmath,amssymb}

\renewcommand{\Pr}{\operatorname{\mathbb{P}}} % probability operator

\begin{document}

\begin{alignat*}{2}
\rho(X,Y) &= 1  &\qquad& \begin{tabular}[t]{@{}l@{}}
                         if and only if $\Pr(Y=\alpha X+\beta)=1$ \\
                         for some real $\alpha$ and $\beta$ with $\alpha>0$,
                         \end{tabular}
\\[1ex]
\rho(X,Y) &= -1 &&       \begin{tabular}[t]{@{}l@{}}
                         if and only if $\Pr(Y=\alpha X+\beta)=1$ \\
                         for some real $\alpha$ and $\beta$ with $\alpha<0$.
                         \end{tabular}
\end{alignat*}

\end{document}

enter image description here

|improve this answer|||||
2

Use the aligned environment, with the optional [t] argument. Don't forget that align requires 3 ampersands for 2 alignment points. I'd recommend using alignat{2} to have control on the horizontal spacing of the two columns:

\documentclass{article}
\usepackage[utf8]{inputenc}%
\usepackage{mathtools, amssymb}

\begin{document}

\begin{alignat*}{2}
  ρ(X,Y) & =1 & \quad & \begin{aligned}[t]
  & \text{if and only if }\mathbb P(Y=αX+β)=1\\
  & \text{for some real $\alpha$ and $\beta$ with }\alpha>0,
  \end{aligned}\\[1ex]
  ρ(X,Y) & =-1 & \quad & \begin{aligned}[t]
  & \text{if and only if }\mathbb P(Y=αX+β)=1\\
  & \text{for some real $\alpha$ and $\beta$ with }\alpha<0.
  \end{aligned}
\end{alignat*}

\end{document} 

enter image description here

|improve this answer|||||
2

I would like to suggest that you use a dcases environment (courtesy of the mathtools package) and use \parboxes to house the conditioning information.

enter image description here

If you would rather have the parboxes top-aligned, simply add [t] ("top") positioning specifiers:

enter image description here


\documentclass{article}
\usepackage{amsfonts,mathtools}
\let\Pr\relax
\DeclareMathOperator{\Pr}{\mathbb{P}} % probability operator
\begin{document}
\[
\rho(X,Y) =
\begin{dcases} % optional: '[t]' ("top") specifiers for the parboxes
1 & \parbox[t]{5.5cm}{if and only if $\Pr(Y=\alpha X+\beta)=1$ for some real $\alpha$ and $\beta$ with $\alpha>0$,}\\[1ex]
-1 & \parbox[t]{5.5cm}{if and only if $\Pr(Y=\alpha X+\beta)=1$ for some real $\alpha$ and $\beta$ with $\alpha<0$.}
\end{dcases}
\]
\end{document}
|improve this answer|||||
  • How did you choose the width? – egreg Jan 30 '17 at 22:16
  • @egreg - I eyeballed the OP's work and tried 5cm, but that looked a bit too tight. So I selected 5.5cm, and that looked about right. :-) I guess I could have been a bit more systematic and measured the width of if and only if $\Pr(Y=\alpha X+\beta)=1$... – Mico Jan 30 '17 at 22:33

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.