16

I tried this and that, but could not solve this problem. Here is the code that produces this error:

\begin{equation}
o=g(h)=\left\{\begin{array}{rcl}
    1 & if & h <   0 \\
    0 & if & h \le 0 
\end{array}\right
\end{equation}

The error is given on the line \end{equation} resides. Thanks.

4
  • 5
    Put a . after \right like \right.
    – user11232
    Feb 27, 2014 at 13:21
  • Yes, this solved. But why the "."?
    – ozi
    Feb 27, 2014 at 13:31
  • 1
    \right requires a following token to say what delimiter to stretch, or . to specify a null delimiter. But your setting is wrong if is a multi letter word so should not be using the math italic font use \mathrm{if} or (much) better use the cases environment from the amsmath package. Feb 27, 2014 at 13:32
  • BTW, if h < 0, then g(h) has two values 1 and 0? And g(h) is undefined for h > 0? Feb 27, 2014 at 13:50

2 Answers 2

14

\left\{ must be balanced by a \right\} in the same line. Since you don't want the right delimiter, and since the closing pair is needed, you have to put a null delimiter by \right.

\documentclass{article}
\begin{document}
  \begin{equation}
    o=g(h)=\left\{\begin{array}{rcl}
                     1 & if & h <   0 \\
                     0 & if & h \le 0
\end{array}\right.  %% <--here
\end{equation}
\end{document}

enter image description here

But for this amsmath provides cases environment. I suggest you to use this. A sample will be:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
  \begin{equation}
    o=g(h)=\begin{cases}
              1 & \text{if $ h < 0 $}\\
              0 & \text{if $ h \le 0$}
\end{cases}
\end{equation}
\end{document}

enter image description here

Note the use of \text macro which is also provided by amsmath.

1
\begin{numcases}{|x|=} 
x, & for $x \geq 0$ \label{eq:4}
\\ -x, & for$x < 0$ \label{eq:5} 
\end{numcases}

You have to use

\usepackage{cases}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .