# Multiline equation is not working

I have a multiline equation as below:

$$l_{t i}\left(v_{t} j\right)=\left\{\begin{array}{ll} \\\ 0 & \text { if } r_{j}=r_{i} \\\ 1 & \text { if } r_{j}<r_{i} \\\ 2 & \text { if } r_{j}>r_{i}$$


but I get this error:

! You can't use \eqno' in math mode.
\endmathdisplay@a ...\df@tag \@empty \else \veqno
\alt@tag \df@tag \fi \ifx ...
l.264


and when I move the line breaks, I get this instead:

! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate

l.262 1 &
\text { if } r_{j}<r_{i}
?


I am not sure what is wrong.

• Do you have blank lines in your real equation? – Bernard May 10 at 21:50
• oh wow thank, I didn't know the blank lines would affect the tag. However, I have another error now (will edit my original question) – dusa May 10 at 21:52
• A blank line starts a new paragraph, and it is incompatible with math mode. – Bernard May 10 at 21:55

## 1 Answer

Simply use the cases environment, like this, without any blank line:

$$l_{t i} (v_{t} j)=\begin{cases} 0 & \text { if } r_{j}=r_{i} \\ 1 & \text { if } r_{j}r_{i} \end{cases}$$
`