2
 \begin{eqnarray*}
  % \nonumber % Remove numbering (before each equation)
    (a, b) &=& \{ x \in X | a < x < b \} \\
    (a, b] &=& \{ x \in X | a < x \leq b \} \\
    [a, b) &=& \{ x \in X | a \leq x < b\} \\
    [a, b] &=& \{ x \in X | a \leq x \leq b \}.
  \end{eqnarray*}

What's error?

 Missing number, treated as zero.
<to be read again> 
                   a
l.281     [a, b]
                 &=& \{ x \in X \mid a \leq x \leq b \}.
egreg
  • 1,121,712
  • 1
    We've had this before, somewhere... the problem is the opening [ that immediately follows your line-breaking \\. Use {}[a, b) and {}[a, b] instead. Also something you should use instead is amsmath's align. See eqnarray vs align – Werner Dec 31 '18 at 17:44

1 Answers1

4

Your issue is similar in nature to:

...even though in this case you're using eqnarray. You'll have to avoid \\ grabbing the subsequent [ on the next line and thinking it's expecting an optional argument. Use \\relax or {}[a,b):

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align*}
  (a, b) &= \{ x \in X \mid a < x < b \}       \\
  (a, b] &= \{ x \in X \mid a < x \leq b \}    \\\relax
  [a, b) &= \{ x \in X \mid a \leq x < b\}     \\\relax
  [a, b] &= \{ x \in X \mid a \leq x \leq b \}.
\end{align*}

\end{document}

You could also use the interval package to specify intervals, which removes the verbatim use of [ around line-breaks \\, but instead sets the interval using a macro:

\documentclass{article}

\usepackage{amsmath,interval}

\intervalconfig{
  soft open fences % Uses ( and ) for open intervals, rather than ] and [
}

\begin{document}

\begin{align*}
  \interval[open left, open right]{a}{b} &= \{ x \in X \mid a < x < b \}        \\
              \interval[open left]{a}{b} &= \{ x \in X \mid a < x \leq b \}     \\
             \interval[open right]{a}{b} &= \{ x \in X \mid a \leq x < b\}      \\
                         \interval{a}{b} &= \{ x \in X \mid a \leq x \leq b \}.
\end{align*}

\end{document}
Werner
  • 603,163