0

When I type

$$ A_n\ =\ \left\{\begin{array}{ccc}
[\hskip.017in 0,1\hskip.017in] & {} & n\ {\rm is\ even} \\
[\hskip.017in -1,0\hskip.017in] & {} & n\ {\rm is\ odd} \\
\end{array}\right.\ , $$

I get an error message claiming "illegal unit of measure" and "missing number." I can't find anything wrong with the code. What am I missing?

1

2 Answers 2

3

The problem is that the first [ follows \\ and is mistaken for introducing the optional argument. Use \relax or, better, use the proper tool.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$$ A_n\ =\ \left\{\begin{array}{ccc}
[\hskip.017in 0,1\hskip.017in] & {} & n\ {\rm is\ even} \\ \relax
[\hskip.017in -1,0\hskip.017in] & {} & n\ {\rm is\ odd} \\
\end{array}\right.\ , $$

\[
A_n=\begin{cases}
[0,1]  & \text{$n$ is even,} \\
[-1,0] & \text{$n$ is odd,}
\end{cases}
\]

\end{document}

enter image description here

I have little doubts about which rendering is better both for input and output. If you want to align the two intervals to the right, add \hphantom{-}:

\[
A_n=\begin{cases}
\hphantom{-}[0,1]  & \text{$n$ is even,} \\
[-1,0] & \text{$n$ is odd,}
\end{cases}
\]

enter image description here

I'd avoid the comma hanging from nowhere.

Note that \rm has been deprecated for about 30 years and $$ since LaTeX version 1, about 40 years ago.

4
  • You might want to use \textup, just in case this is used within an italic environment like a theorem. Jun 16 at 23:21
  • @barbarabeeton I'm not sure why the text should be different from the context.
    – egreg
    Jun 16 at 23:21
  • Okay, but it's nice to know that \text, all by itselt, follows the style of the surrounding environment. Jun 16 at 23:24
  • Another option would be [\hphantom{-}0,1], so that the left brackets align. I don't know if that would be better.
    – Teepeemm
    Jun 17 at 13:39
2

the [is being seen as an optional argument, which takes a length, \\[5pt] so use

....\\ \relax
[....]

to hide the [ from \\

Note $$ and\hskip are TeX primitives that should not be used in LaTeX, use \[ and \hspace (but avoid \hspacein math) \rm has not been defined by default in latex since 1993, use \textrm{ is odd}

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.