# Latex matrix not displaying right numbers

I've just started writing in latex to expose math problems to a forum.
I am trying to display a matrix:

\begin{align*} \begin{matrix} 1 & -9 & 3 \\ 1 & 2 & -2 \\ -2 & 1 & 1 \end{matrix} \end{align*}


But I get this:

There's 1b1 and there's not the last element that I'm trying to display, why?

• Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Nov 19 '12 at 2:23
• Your use of the word "forum" suggests that this is to do with entering LaTeX-like mathematics on a website which then converts it to some sort of HTML/XHTML that a browser can understand. It is, in my experience, highly unlikely that this is actually TeX doing the conversion and more likely to be some sort of javascript. If so, it is possible that this question will be off-topic here as TeX isn't actually used. Can you provide a little more information as to the conversion that the forum uses? – Andrew Stacey Nov 19 '12 at 10:28
• Truly I don't know what conversion does the forum use.It just says that we shall use the latex tags and to search a guide online.This is the forum: mymathforum.com/viewforum.php?f=20 – Ramy Al Zuhouri Nov 19 '12 at 14:49

As @Peter Grill mentioned,  already starts math mode, so you don't need align*. If you need square brackets as delimiters you can use \left[ and \right] commands or predefined environment bmatrix. \documentclass[a4paper,12pt]{article} \usepackage[utf8]{inputenc} \usepackage{amsmath} \begin{document} % % Option #1 % \[ \left[ \begin{matrix} 1 & -9 & 3 \\ 1 & 2 & -2 \\ -2 & 1 & 1 \end{matrix} \right]

%
% Option #2
%
$\begin{bmatrix} 1 & -9 & 3 \\ 1 & 2 & -2 \\ -2 & 1 & 1 \end{bmatrix}$

\end{document}


Both approaches give the same result:

• So maybe it's the forum that somehow doesn't recognize this syntax. There is the latex tag, but if I copy and paste this code it doesn't work, this is what I get: img850.imageshack.us/img850/3136/screenshot20121119at125.png – Ramy Al Zuhouri Nov 18 '12 at 23:55
• I checked copy & paste right now on my side - everything is ok. It seems that you have additional software dealing with buffer and/or shortcuts and/or keyboard layouts? – redmode Nov 19 '12 at 11:52
• @RamyAlZuhouri: the forum doesn't do syntax, it merely reports tags to the readers. fwiw, i also cut-and-pasted redmode's sample, and it worked for me. it looks as if you are pasting into an smart editor of some sort, and it's confused by the sample. (i typically simply process these examples by copying to a file and processing that from the command line.) – wasteofspace Nov 19 '12 at 11:54
\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}

%
% You can use tablar envronment with flexibility
% For proper orientation of negative numbers better use r in tabular

% environment
$\left[ \begin{tabular}{rrr} 1 & -9 & 3 \\ 1 & 2 & -2 \\ -2 & 1 & 1 \end{tabular} \right]$
\end{document}

• Although this will produce a nice looking result, it's overkill. Instead, \usepackage{mathtools} (loads amsmath) and use \begin{bmatrix*}[rrr] ... \end{bmatrix*}. This option didn't exist when the question was first asked. – barbara beeton May 23 at 19:03