[Tex/LaTex] piecewise function

math-mode

So this is a piecewise defined function I have that I need to talk about:

   f(a,b) = \left\{
     \begin{array}{lr}
       \text{open} & : \text{RMSD}_\text{s-open}\ge6, \text{RMSD}_\text{closed}\ge6\\
       \text{closed} & : \text{RMSD}_\text{closed}\le2 \\
       \text{semiopen} & : \text{RMSD}_\text{s-open}\le2\\
       \text{transition} & :f(a,b)\notin\{\text{open}, \text{closed}, \text{semiopen}\} \\

     \end{array}
   \right.

So what's the way to align up the colons (conditions) so that it looks all nice and pretty?

Also, if I want to describe transition to be the value of the function when none of the conditions of the previous 3 are satisfied, is the way I wrote it out with f(a,b) not belonging to the set {open,closed,semiopen} a good way of writing it? seems really unprofessional…

Best Answer

You can use the cases environment from amsmath:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[   
f(a,b) = 
     \begin{cases}
       \text{open,} &\quad\text{if RMSD}_\text{s-open}\ge6, \text{RMSD}_\text{closed}\ge6\\
       \text{closed,} &\quad\text{if RMSD}_\text{closed}\le2 \\
       \text{semiopen,} &\quad\text{if RMSD}_\text{s-open}\le2\\
       \text{transition,} &\quad\text{otherwise.} \\ 
     \end{cases}
\]

\end{document}

enter image description here

Regarding the other issue, it is usual to write "otherwise".