Dear list,

Some months ago, Hans wrote to this list (see below) a macro to do matrix showing outside the brackets some informations (like we usually do for Markov chains), but adapted some plain tex code, which worked in MKII). I have used with success this code since then, but some weeks ago, the behavior of Context had changed (probably something on my part; I have updated the installation, but nothing changed). 

The problem (I think) is linked to \unprotect \protect. When this code is put before the \starttext to the the cont-new-mkiv, the border matrix behave well, but a simple \eqalign like this:

\startformula  
\eqalign{ & \lambda=5, \mu =5 \cr
       & \mu=8 \cr }
\stopformula

do not works is I replace «  \lambda » by « \lambda_2 » for example. I have no idea what’s is going on. here is a minimal example where Hans’s code is before the \starttext:


% ————————————————————————————————————————
\unprotect

\def\math_border_NC_indeed 
{\gdef\math_border_NC{\aligntab}} 

\let\math_border_NC\math_border_NC_indeed 

\def\math_border_NR 
{\glet\math_border_NC\math_border_NC_indeed 
\cr} 

\unexpanded\def\math_border_matrix#1#2#3% adapted plain 
{\begingroup 
\pushmacro\cr 
\setbox\scratchbox\hbox\bgroup 
\mr B% 
\egroup 
\scratchdimenone\wd\scratchbox 
\scratchdimentwo.2\bodyfontsize 
\mathsurround\zeropoint 
\def\NC{\math_border_NC}% 
\def\NR{\math_border_NR}% 
\setbox\scratchboxone\vbox\bgroup 
\def\cr{% 
\crcr 
\noalign\bgroup 
\kern\scratchdimentwo 
\global\let\cr\endline 
\egroup 
}% 
\ialign{% 
\startimath\alignmark\alignmark\stopimath 
\hfil 
\kern\dimexpr\scratchdimentwo+\scratchdimenone\relax 
\aligntab 
\thinspace 
\hfil 
\startimath\alignmark\alignmark\stopimath 
\hfil 
\aligntab 
\aligntab 
\quad 
\hfil 
\startimath\alignmark\alignmark\stopimath 
\hfil 
\crcr 
\omit 
\strut 
\hfil 
\crcr 
\noalign{\kern-\baselineskip}% 
#3\crcr 
\omit 
\strut 
\cr 
}% 
\egroup 
\setbox\scratchboxtwo\vbox\bgroup 
\unvcopy\scratchboxone 
\global\setbox\globalscratchbox\lastbox 
\egroup 
\setbox\scratchboxtwo\hbox\bgroup 
\unhbox\globalscratchbox 
\unskip 
\global\setbox\globalscratchbox\lastbox 
\egroup 
\setbox\scratchboxtwo\hbox\bgroup 
\startimath 
\kern\dimexpr\wd\globalscratchbox-\scratchdimenone\relax 
\left#1\relax 
\kern-\wd\globalscratchbox 
\global\setbox\globalscratchbox\vbox\bgroup 
\box\globalscratchbox 
\kern\scratchdimentwo 
\egroup 
\vcenter\bgroup 
\kern-\ht\globalscratchbox 
\unvbox\scratchboxone 
\kern-\baselineskip 
\egroup 
\thinspace 
\right#2\relax 
\stopimath 
\egroup 
\null 
\thickspace 
\vbox\bgroup 
\kern\ht\globalscratchbox 
\box\scratchboxtwo 
\egroup 
\popmacro\cr 
\endgroup} 

\unexpanded\def\bordermatrix {\math_border_matrix()} 
\unexpanded\def\bbordermatrix{\math_border_matrix[]} 

\unexpanded\def\startbordermatrix #1\stopbordermatrix 
{\math_border_matrix(){#1}} 
\unexpanded\def\startbbordermatrix#1\stopbbordermatrix{\math_border_matrix[]{#1}} 

\let\stopbordermatrix \relax 
\let\stopbbordermatrix\relax 

% ————————
% Should there be a "\ptotect" ? 
%\protect 
% ————————

\starttext 

A plain border matrix  : 

\startformula 
\bbordermatrix{ 
a & b & c & d \cr 
e & f & G & h \cr 
i & j & k & l \cr} 
\stopformula 

\startformula 
\startbbordermatrix 
\NC a \NC b \NC c \NC d \NR 
\NC e \NC f \NC G \NC h \NR 
\NC i \NC j \NC k \NC l \NR 
\stopbbordermatrix 
\stopformula 

\startformula  
\eqalign{
& \lambda=5, \mu =5 \cr
% ————————
% Does not work if the next line is uncommented
% & \lambda_1=5, \mu =4 \cr
% ————————
& \mu=8 \cr
}
\stopformula

\stoptext

% ————————————————————————————————————————

Thanks for any help. By the way. Is there with MKIV a more direct way to do such matrix ?
Fabrice.


Le 28 août 2017 à 13:47:59, Hans Hagen (pragma@wxs.nl) a écrit:

Hi,

Put this in cont-new.mkiv (after \unprotect):

\def\math_border_NC_indeed
{\gdef\math_border_NC{\aligntab}}

\let\math_border_NC\math_border_NC_indeed

\def\math_border_NR
{\glet\math_border_NC\math_border_NC_indeed
\cr}

\unexpanded\def\math_border_matrix#1#2#3% adapted plain
{\begingroup
%
\pushmacro\cr
%
\setbox\scratchbox\hbox\bgroup
\mr B%
\egroup
\scratchdimenone\wd\scratchbox
%
\scratchdimentwo.2\bodyfontsize
%
\mathsurround\zeropoint
%
\def\NC{\math_border_NC}%
\def\NR{\math_border_NR}%
%
\setbox\scratchboxone\vbox\bgroup
\def\cr{%
\crcr
\noalign\bgroup
\kern\scratchdimentwo
\global\let\cr\endline
\egroup
}%
\ialign{%
\startimath\alignmark\alignmark\stopimath
\hfil
\kern\dimexpr\scratchdimentwo+\scratchdimenone\relax
\aligntab
\thinspace
\hfil
\startimath\alignmark\alignmark\stopimath
\hfil
\aligntab
\aligntab
\quad
\hfil
\startimath\alignmark\alignmark\stopimath
\hfil
\crcr
\omit
\strut
\hfil
\crcr
\noalign{\kern-\baselineskip}%
#3\crcr
\omit
\strut
\cr
}%
\egroup
\setbox\scratchboxtwo\vbox\bgroup
\unvcopy\scratchboxone
\global\setbox\globalscratchbox\lastbox
\egroup
\setbox\scratchboxtwo\hbox\bgroup
\unhbox\globalscratchbox
\unskip
\global\setbox\globalscratchbox\lastbox
\egroup
\setbox\scratchboxtwo\hbox\bgroup
\startimath
\kern\dimexpr\wd\globalscratchbox-\scratchdimenone\relax
\left#1\relax
\kern-\wd\globalscratchbox
\global\setbox\globalscratchbox\vbox\bgroup
\box\globalscratchbox
\kern\scratchdimentwo
\egroup
\vcenter\bgroup
\kern-\ht\globalscratchbox
\unvbox\scratchboxone
\kern-\baselineskip
\egroup
\thinspace
\right#2\relax
\stopimath
\egroup
\null
\thickspace
\vbox\bgroup
\kern\ht\globalscratchbox
\box\scratchboxtwo
\egroup
%
\popmacro\cr
%
\endgroup}

\unexpanded\def\bordermatrix {\math_border_matrix()}
\unexpanded\def\bbordermatrix{\math_border_matrix[]}

\unexpanded\def\startbordermatrix #1\stopbordermatrix
{\math_border_matrix(){#1}}
\unexpanded\def\startbbordermatrix#1\stopbbordermatrix{\math_border_matrix[]{#1}}

\let\stopbordermatrix \relax
\let\stopbbordermatrix\relax

Then you can do:

\starttext

A plain border matrix:

\startformula
\bordermatrix{
a & b & c & d \cr
e & f & G & h \cr
i & j & k & l \cr}
\stopformula

\startformula
\bbordermatrix{
a & b & c & d \cr
e & f & G & h \cr
i & j & k & l \cr}
\stopformula

\startformula
\startbordermatrix
\NC a \NC b \NC c \NC d \NR
\NC e \NC f \NC G \NC h \NR
\NC i \NC j \NC k \NC l \NR
\stopbordermatrix
\stopformula

\startformula
\startbbordermatrix
\NC a \NC b \NC c \NC d \NR
\NC e \NC f \NC G \NC h \NR
\NC i \NC j \NC k \NC l \NR
\stopbbordermatrix
\stopformula

\stoptext

Not the full matrix support of MKIV but good enough for plain simulations.


-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------