# How can I flush text left in the cases environment?

I have the following code:

\documentclass{article}
\usepackage{amsmath, amssymb, amsthm, graphicx, textcomp}
\begin{document}
d^2(A,B)=\begin{cases}
(a_1-b_1)^2(1+m^2) &&\text{if $AB$ has slope $m$} \\
(a_2-b_2)^2 &&\text{if $AB$ is a vertical line}
\end{cases}
\end{document}


but I get this output:

Is there a way to get the text on the right after the formulas, so that there are only two lines? Thanks.

-

You are using two alignment characters on each row; only one of those can be used on each line of a cases environment; if you want to increase the separation between the math expressions and the annotations, you can use \quad, or \qquad, or \hspace with an appropriate value:

\documentclass{article}
\usepackage{amsmath, amssymb, amsthm, graphicx, textcomp}

\begin{document}

$d^2(A,B)= \begin{cases} (a_1-b_1)^2(1+m^2), &\text{if AB has slope m} \\ (a_2-b_2)^2, &\text{if AB is a vertical line} \end{cases}$

$d^2(A,B)= \begin{cases} (a_1-b_1)^2(1+m^2), &\qquad\text{if AB has slope m} \\ (a_2-b_2)^2, &\qquad\text{if AB is a vertical line} \end{cases}$

\end{document}

-