Take the 2-minute tour ×
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.

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!

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

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.