2

I have a strange problem. It seems I cannot use any of the matrix environments (matrix, bmatrix, pmatrix etc.). The following code will not render on my machine

\documentclass[12pt]{article}
\usepackage{amsmath}

%%% BEGIN DOCUMENT
\begin{document}
\begin{bmatrix}
 U_{11} & U_{12}& U_{13}& \cdots& U_{1k}\\
 U_{21} & U_{22}& U_{23}& \cdots& U_{2k}\\
 \vdots & &\vdots & &\vdots             \\
 U_{N1} & U_{N2}& U_{N3}& \cdots& U_{Nk} \\
 \end{bmatrix}

\end{document}

However if I just put the bmatrix environment code into LaTeXiT, everything works fine. I have tried even just the simplest matrix examples using several matrix environments and none seem to work. Is my amsmath package hosed somehow?

I'm running OSX 10.7.4 and am using TexShop installed via MacTeX. Here is the error:

! Missing $ inserted.
! Missing $ inserted.
<inserted text> 
                $
l.12  \end{bmatrix}

? 

Any help would be greatly appreciated.

  • Welcome to the site! you need to wrap the bmatrix in math mode- for example $\begin{bmatrix}...\end{bmatrix}$ – cmhughes Sep 25 '13 at 5:06
6

You should put them in math mode. It works in latexit as the contents are automatically wrapped inside math mode there.

\documentclass[12pt]{article}
\usepackage{amsmath}

%%% BEGIN DOCUMENT
\begin{document}
\[
\begin{bmatrix}
 U_{11} & U_{12}& U_{13}& \cdots& U_{1k}\\
 U_{21} & U_{22}& U_{23}& \cdots& U_{2k}\\
 \vdots & &\vdots & &\vdots             \\
 U_{N1} & U_{N2}& U_{N3}& \cdots& U_{Nk} \\
 \end{bmatrix}
 \]

\end{document}

enter image description here

  • @user37234 If this answers your question you may want to mark it as an answer. – nam Dec 31 '15 at 4:23
0

I found an interesting clarification for your problem. I quote from a textbook named "Technical notes on the amsmath package, American Mathematical Society,Michael Downes, 1999/10/29"

If you used the plain.tex versions of \matrix, \pmatrix, or \cases in a document and then later converted the document to use the amsmath package (or one of the AMS documentclasses, which automatically call the amsmath package internally), the instances of those commands will produce error messages. The problem is that when LATEX was originally created, it adopted most of its mathematics features straight from plain.tex. But in the case of \matrix, \pmatrix, \cases this was a mistake|the plain.tex syntax for them is decidedly non-LATEX in style, for example the fact that they use \cr instead of \ to mark line breaks, and they don't use \begin and \end. In basic LATEX this mistake will be perpetuated at least until LATEX3 appears, in order to avoid breaking existing documents. But no existing documents that were written with the amsmath package have that syntactic problem, as amsmath provides proper LATEX-syntax versions of \matrix and the others. The possibility of optionally allowing the plain.tex variants to make document conversion easier seems illadvised since those variants are so blatantly wrong in a LATEX context. The array environment ought to have been used instead.

  • What has this to do with bmatrix? – egreg Dec 29 '17 at 23:08
  • I guess it's the same bug since we are talking about the ams package conflicting with plain.tex versions of matrices. – chadoulis Dec 29 '17 at 23:15
  • 2
    \bmatrix is not defined in plain TeX. – egreg Dec 29 '17 at 23:16

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.