# Matrices in ConTeXt?

I'm typesetting up some linear algebra notes, and in the process moving from LaTeX to ConTeXt. What is the most efficient method of entering matrices in ConTeXt? I can use plain TeX:

\startformula
\left[matrix{
1&2&3\cr
4&5&-6\cr}
\right]
\stopformula


which is OK, but typesets all elements centered in their columns. To obtain right-aligned elements I'd have to add lots of hfill's through the matrix.

Alternatively:

\startformula
\startmmatrix[align={right,right,right}]
\NC 1 \NC 2 \NC 3 NR
\NC 5 \NC 6 \NC -6 \NR
\stopmmatrix
\stopformula


which works, but is very wordy and cumbersome (I much prefer the "&, \" of LaTeX here). What is the canonical way of obtaining right-aligned entries in ConTeXt?

Thanks!

-

The canonical way is to use \definemathmatrix.

\definemathmatrix[rightmatrix]
[left={\left[\,},
right={\,\right]},
align=right]

\startformula
\startrightmatrix
\NC ... \NC ... \NR
\NC ... \NC ... \NR
\stoprightmatrix
\stopformula


In some ways, the ConTeXt style encourages you to separate content from presentation.

Typing \NC ... \NR can be simplified a bit by using editor macros. But that is not all that verbose compared to & and \\.

Also see Section 3 of this MAPS article that compares LaTeX and ConTeXt matrices.

-