1

Why does this code show errors? enter image description here

For this equation I used the code:

\begin{equation}
Y_k\big(p+1\big) = 
   \begin{cases}
       +1 \;\;\; if W_k  $>$ 0 \\
       -1 \;\;\; if W_k  $<$ = 0
   \end{cases}
\end{equation}

The errors that appear are:

enter image description here

1
  • Neverhave blank lines in equations.
    – Bernard
    May 1 '19 at 22:00
7

There are several errors in your code.

  1. There must be no blank line inside an equation environment.
  2. You're already in math mode, so $>$ and $<$ are misplaced.
  3. “if” should not be treated as math.
  4. You're missing the alignment point.
  5. <= should be \leq.

As a stylistic remark, there's no need for \big. If you really want it, it should be \bigl(p+1\bigr).

\begin{equation}
Y_k(p+1) = 
\begin{cases}
    +1 & \text{if } W_k > 0 \\
    -1 & \text{if } W_k \leq 0
\end{cases}
\end{equation}

enter image description here

2
  • I would go for &\text{if \(W_k>0\)}\\..., but that's fine, too.
    – manooooh
    May 1 '19 at 22:17
  • 2
    @manooooh I too, but it's perhaps too advanced for the OP.
    – egreg
    May 1 '19 at 22:40

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.