I would like to write the following equation:

enter image description here

For that, I have the following snippet:

    s_i = \left\{\begin{matrix}
    \bar{1}, & \text{if } x < -\epsilon \\ 
    0, & \text{if } \left | x \right | \leq \epsilon \\ 
    1, & \text{if } x > \epsilon \

I get the following error when I compile:

Missing { inserted. \bar
Missing } inserted. \bar
Undefined control sequence. \bar{1}, \& \text
Misplaced alignment tab character &. 0, &
Undefined control sequence. 0, & \text
Misplaced alignment tab character &. 1, &
Undefined control sequence. 1, & \text

Can someone help me with solving this?


I have no error message when I complete the code. However, the ‘if’ in the third tow is not well aligned with the first two, for a reason I can't explain. This problem disappears using the cases environment, which furthermore has a simpler code:



s_i = \begin{cases}
\bar{1}, & \text{if } x < -\epsilon \\
0, & \text{if\,} \left | x \right | \leq \epsilon \\
1, & \text{if } x > \epsilon \


enter image description here

  • Thanks. That solved the issue. Basically, I just added the package \usepackage{mathtools}. – Nasser Jun 30 at 17:00
  • The cases is not defined by mathtools, but by amsmath(which is anyway loaded by mathtools, since it is a (very useful) extension of amsmath). – Bernard Jun 30 at 17:09
  • The reason the "if" in the third row is not aligned when matrix is used is that the columns are all defined to be centered for matrix and that element happens to be shorter than the others. – barbara beeton Jun 30 at 18:32
  • Oh! yes, of course. I had in mind it was a plain array environment, and mainly wondered why the O.P. didn't use cases. Thank you! – Bernard Jun 30 at 18:36

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.