Hi Wim,
Quoting WN <wneimeijer@tiscali.nl>:
I tried your code and performed more tests. My first tests show your fix
works. But than I added a \section{} in my test code and I am sorry
to say that
the math matrix alignment does not work at that point.
:-) Section modifies \!!counta so things get messed up again. Actually,
this really helped to narrow down the bug. Basically, dostartmatrix
does a test
\scratchcounter=\ifnum\eqaligncolumn>\scratchcounter \eqaligncolumn
\else \plusone \fi
which is comparing eqaligncolmn with scratch counter, but
scratchcounter is never initialized. Therefore, everything depends on
what was the value of scratchcounter, which explains, different
behaviour depending on when the matrix occurred, and why you had a
hard time pinning down a minimal example.
The fix is easy, change the scratchcounter to zerocount (or maybe just
change to \ifcase\eqaligncolunm). So add this to your file,
\unprotect
\def\dostartmathmatrix[#1][#2]%
{\begingroup
\edef\currentmathmatrix{#1}%
\doifassignmentelse{#2}{\setupmathmatrix[#1][#2]}\donothing
\null
\executeifdefined{\??mx:\mathmatrixparameter\c!location}{\getvalue{\??mx:\v!lohi}}%
\mathmatrixleft
\mathmatrixbox\bgroup
\pushmacro\domatrixNC
\let\endmath\relax
\def\NC{\domatrixNC}%
\def\MC{\domatrixNC\ifmmode\else$\def\endmath{$}\fi}%
\global\let\domatrixNC\dodomatrixNC
\def\NR{\endmath\global\let\domatrixNC\dodomatrixNC\crcr}%
\normalbaselines
\mathsurround\zeropoint
\everycr\emptytoks
\tabskip\zeropoint
\eqaligncolumn\zerocount
\processcommacommand[\mathmatrixparameter\c!align]{\advance\eqaligncolumn\plusone\dosetmatrixcolumn}%
\scratchcounter=\ifnum\eqaligncolumn>\zerocount \eqaligncolumn \else
\plusone \fi
\global\eqaligncolumn\plusone
\preparemathmatrix } % uses scratchcounter
\protect
Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________