On Fri, 23 May 2014, Matthias Weber wrote:
Dear All,
I would like to define a command that expands
\vector{2,4} % or vector[2,4] if that’s easier
to
\startpmatrix \NC 2 \NR \NC 4 \NR \stoppmatrix
and more generally
\vector{2,4,1,7}
to
\startpmatrix \NC 2 \NR \NC 4 \NR \NC 1 \NR \NC 7 \NR \stoppmatrix
Any hints how to achieve this?
Surprisingly, this is not as simple as it may seem at first glance. Some time ago, I had written a module to achieve this. See attached. The usage is: \usemodule[simplematrix] \definesimplematrix[MATRIX][fence=bracket] (any predefined math-fence will work) and then: \MATRIX{1,2,3} for row vectors and \MATRIX{1;2;3} for column vectors, and \MATRIX{1,2,3; 4,5,6} for matrices. You can use \definesimplematrix[...][distance=..., align=...] to influence the distance and align keys of mathmatrix. Aditya