TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
    
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}

enter image description here

share|improve this answer
    
argh, duh. Thanks! – user37234 Sep 25 '13 at 17:47
    
@user37234 If this answers your question you may want to mark it as an answer. – nam Dec 31 '15 at 4:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.