Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

enter image description here

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

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.