How to add a matrix in LaTeX?
19

latexmatrix

23

Ash's answer typesets the matrix inline with the text. A (perhaps) nicer way to do this is to use the smallmatrix environment in the amsmath package. Add to the document preamble:
And then you can do:
If you want to bracket the matrix you can also do:
The amsmath package also offers the shortcut matrix environments which default to centered alignment for their columns:
This info found in "The LaTeX Companion". 
16

First: if you intend to do math in LaTeX, you SHOULD learn and use AMS LaTeX. The best reference is the Short Math Guide for LaTeX. In this guide, you will learn that there are many different matrix macros available when you use the To quote the document,
Finally, I'd like to mention that, while it is possible to set matrices without AMS LaTeX, just use it. It offers so many benefits that until you get the hang of LaTeX, it's the best single macro package for math. 
7
accepted

For a matrix of the form:
use the LaTeX code:

0

I agree with Ashwin's simple approach. Sometimes you can't rely on amsmath being available, so if you're after straightforward matrices, then use straightforward Latex commands. See more at http://andyroberts.net/misc/latex/latextutorial9.html for how to wrap your 'array' in brackets. 
0


0

For flexible typesetting of matrices with color, lines and justifivation done by formatting parameters see An extension to amsmath matrix environments. 