# Matrix environments not working

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

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}


-
argh, duh. Thanks! –  user37234 Sep 25 '13 at 17:47