4

I find myself using a lot of matrices, and I would like to save myself some typing by using the separatedlist environment from the database module, but I keep getting errors.

The following produces a "Missing number, treated as zero" error:

\usemodule[database]

\defineseparatedlist
  [Test]
  [before={\startmathmatrix},
   after={\stopmathmatrix},
   first=,
   last={\NR},
   left={\NC},
   right=,
   separator={;}]

\starttext

\startformula
\startTest
  x_{1,1}; x_{1,2}; x_{1,3}
  1; 2; 3
\stopTest
\stopformula

\stoptext

But changing mathmatrix to align seems to work with no issues:

\usemodule[database]

\defineseparatedlist
  [Test]
  [before={\startalign[n=3]},
   after={\stopalign},
   first=,
   last={\NR},
   left={\NC},
   right=,
   separator={;}]

\starttext

\startformula
\startTest
  x_{1,1}; x_{1,2}; x_{1,3}
  1; 2; 3
\stopTest
\stopformula

\stoptext

What am I missing?

6

You don't need to define a new command for easily typesetting matrices. ConTeXt already has a mechanism which uses the MATLAB notation for matrices. To use it, simply specify simplecommand=NAME, and then the macro \NAME{...} can be used to typeset matrices. For example

\definemathmatrix [bmatrix][matrix:brackets][simplecommand=MATRIX]

\starttext
\startformula
  \MATRIX{1,2,3; 4,5,6; 7,8,9} 
  \MATRIX{2;3;4}
\stopformula
\stoptext

gives

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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