# 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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 2, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9303584694862366, "perplexity": 10070.966251016449}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2015-35/segments/1440645348533.67/warc/CC-MAIN-20150827031548-00166-ip-10-171-96-226.ec2.internal.warc.gz"}