%D \module
%D   [       file=m-newmat,
%D        version=2000.11.16,
%D          title=\CONTEXT\ Math Module,
%D       subtitle=AMS-like math extensions,
%D         author={Taco Hoekwater \& Hans Hagen},
%D           date=\currentdate,
%D      copyright={PRAGMA / Taco Hoekwater}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
%C details.

\unprotect

%D Code has been integrated.

\protect \endinput

%D This module collects macros that \TEX\ users kind of expect
%D to be available when typesetting math. Most of them
%D originate in the \AMS\ macro packages. We have taken the
%D freedom to adapt them to \CONTEXT. This module is derived
%D from the \type {m-math} module by Taco Hoekwater (partially
%D derived from AMS math modules) and adapted|/|extended by
%D Hans Hagen.

%D \macros
%D   {startsubarray,substack,startsmallmatrix}
%D
%D [HH] I wonder what these are supposed to do. An example
%D will be inserted later. Contrary to the original we
%D support an optional argument between either \type {{}} or
%D \type {[]}.

\def\startsubarray
  {\doifnextcharelse\bgroup
     \simplestartsubarray{\dosingleempty\complexstartsubarray}}

\def\complexstartsubarray[#1]%
  {\simplestartsubarray{#1}}

\def\simplestartsubarray#1%
  {\vcenter\bgroup
   \baselineskip\fontdimen10 \scriptfont\plustwo
   \advance\baselineskip\fontdimen12 \scriptfont\plustwo
   \lineskip\plusthree\fontdimen8 \scriptfont\plusthree
   \lineskiplimit\lineskip
   \ialign\bgroup\ifx c#1\hfil\fi$\mathsurround\zeropoint\scriptstyle##$\hfil\crcr}

\def\stopsubarray
  {\crcr\egroup
   \egroup}

\def\startsubstack
  {\doifnextcharelse\bgroup
     \simplestartsubstack{\dosingleempty\complexstartsubstack}}

\def\complexstartsubstack[#1]%
  {\simplestartsubstack{#1}}

\def\simplesubstack#1%
  {\startsubarray[c]#1\stopsubarray}

\def\startsmallmatrix
  {\null
   \,%
   \vcenter\bgroup
   \baselineskip6\ex@
   \lineskip1.5\ex@
   \lineskiplimit\lineskip
   \ialign\bgroup\hfil$\mathsurround\zeropoint\scriptstyle##$\hfil&&\thickspace\hfil
     $\mathsurround\zeropoint\scriptstyle##$\hfil\crcr}

\def\stopsmallmatrix
  {\crcr\egroup
   \egroup
   \,}

\protect \endinput
