Standard LaTeX does not have a matrix environment. For historical reasons the original version of LaTeX (LaTeX 2.09) contained a more or less full copy of plain TeX commands including a \matrix
command. Some of these plain TeX commands made little to no sense in LaTeX as they used quite different conventions (and some of them didn't even work at all with LaTeX such as \topinsert
or \beginsection
). Some made sense and they got documented in the LaTeX manual as "LaTeX commands".
So when LaTeX2e (the current version of LaTeX) was designed, we took those that did not work out. However, those that did work (even if not documented and with unusual syntax) have been kept for compatibility reasons, just in case somebody did use them in old documents. E.g.,
\maxtrix{5 & 6 & 7 \cr
4 & P & 0 \cr
3 & 2 & 1 \cr}
should work in plain TeX (and in fact in LaTeX). But neither \cr
nor \matrix
is a documented and official LaTeX command. And as you can see it is a command with one argument not an environment, which is why you get your error message.
In LaTeX it is best to load the amsmath
package that provides all kind of good math support including a matrix
environment that supports the syntax you used.
amsmath
package. Check out themathmode
documentation. Also, posting code fragments like this isn't the best way to get answers. See I've just been told I have to write a minimal example, what is that?. – Alan Munn May 28 '12 at 19:22\matrix
command? – Werner May 28 '12 at 19:31