# array error Missing number, treated as zero. [b,a] Illegal unit of measure (pt inserted). [b,a] Missing = inserted for \ifdim. [b,a]

When i wrote

\begin{displaymath}

a\circ b = \left\{ \begin{array}{ll}

[a,b] & \textrm{if}~a<b \\

[b,a] & \textrm{if}~ b < a \\

\{a\} & \textrm{if}~a = b

\end{array}\right.

\end{displaymath}


I get the error messages below, respectively;

Missing number, treated as zero. [b,a]

Illegal unit of measure (pt inserted). [b,a]

Missing = inserted for \ifdim. [b,a]

Missing number, treated as zero. [b,a]

Illegal unit of measure (pt inserted). [b,a]

What is the reason for this? How can i solve it? Could you please anybody help me?

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Moriambar Jun 1 '17 at 18:48

## 2 Answers

I suggest you use the amsmath package and the cases environment. This will allow you to use $ to start the equivalent of displaymath/equation*; also they will allow you to use \text to insert text into math formulas (\mathrm I think it's best suited for single letters and symbols): \documentclass[12pt,oneside,a4paper]{article} \usepackage{amsmath} \begin{document} \[ a\circ b = \begin{cases} [a,b]&\qquad\text{if}~a<b\\ [b,a]&\qquad\text{if}~b<a\\ \{a\}&\qquad\text{if}~a=b \end{cases}$
\end{document}


producing

The reason for the error is that with the standard definition of \\

[a,b] & \textrm{if}~a<b \\
[b,a]


is the same as

[a,b] & \textrm{if}~a<b \\[b,a]


so the [b,a] is taken as the optional argument so should be a length like \\[5pt]. You can use

[a,b] & \textrm{if}~a<b \\ \relax
[b,a]


to hide the [ or (better) use the AMS alignments as shown in Moriambar's answer. amsmath locally uses a version of \\ which does not look past end of line when looking for an optional argument.