Hi Aditya

I tried the new code you send me, and of course I did a quick test.
But when doing a texmfstart texexec --autopdf --pdf testalignfontnew.tex
texexec hangs ''forever''  while trying to process the \section{} command.
Actually its pdftex trying to do something.

To make sure I did not make a edit mistake, I copied my old test code into
the file testalignfontnew.tex and run a diff to see where the difference with the new code
are.

Looking at the code (and I am not a Tex expert, and forgive me, when I ask a dumb question)
I don't see where the \scratchcounter itself is defined ? Must surely be a global Context counter ?

Attached the new test code.
Hope it helps the debugging process and thanks for all your help sofar.

Wim

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
___________________________________________________________________________________