# [dev-context] Some math improvements

Fri May 25 20:42:38 CEST 2007

Quoting Hans Hagen <pragma at wxs.nl>:

>> Hi Hans and Taco,
>>
>> I am attaching the math enhancements that I have been promising for
>> about for some days^H^H^H^Hweeks now. Here are the changes.
>>
>> 1. Improved \llap, \rlap, \clap that work in both math and text mode
>> (Taco's code)
>>
>> 2. A \cramped macro to go into cramped mode (based on Knuth's code)
>
> \def\docramped#1#2%
>   \setbox\scratchbox\hbox
>     {\nulldelimiterspace\zeropoint
>      $\m at th#1\radical\zerocount{#2}$}%
>   \ht\scratchbox-\dimexpr
>     \ifx#1\displaystyle
>       \fontdimen8\textfont3
>       +.25\fontdimen5\textfont2
>     \else
>        1.25\fontdimen8
>          \ifx#1\textstyle
>            \textfont
>          \else\ifx#1\scriptstyle
>            \scriptfont
>          \else
>            \scriptscriptfont
>          \fi \fi
>          \plusthree
>     \fi
>     -\ht\scratchbox
>   \relax
>   \box\scratchbox
>   \endgroup}

Phew! Took some time to realize that \ht\scratchbox-\dimexp is same as
\ht\scracthbox=-\dimexp. Rest of it is same as the earlier definition,
just a bit more easy to understand.

>>
>> 3. \crampedllap \crampedrlap, \crampedclap for the equivalents to
>> \llap etc which typesets its contents in cramped mode (well, I kinda
>> figured that out on my own :)
>>
>> 4. An improved substack macro, with improved spacing. (Based on
>> amsmath's substack macro). Taco, does it make sense to surround
>> substack with a group, which will save some typing
>> \sum_startsubstack whatever \stopsubstack or are there any side
>> effects? In the code, I do not have the extra group.
>>
>> 5. Definitions for iint, iiint, iiiint (for those who can't count
>> i's like me, you can use \repeatintegral{1}, \repeatintegral{2},
>> etc. Maybe, we should have the more readable \doubleintegral,
>> \tripeintegral, \quadintegral also). This is based on amsmath code,
>> and tries to use correct spacing for \iint\limits_{....}. BTW, does
>> anyone wish that the limits with \int were configurable rather than
>> defaulting to \nolimits? amsmath provides this feature, but I have
>> personally never seen it being used. It is not too difficult to
>> implement.
>>
>>
>> 6. A definition for splitfrac, which is useful for multi-line
>> fractions. Based on Michael Downes' code.
>>
>> ..... I also had something for \intertext, but realized that
>> \intertext does not honor indentations. I will look into that first,
>> before posting the code.
>>
>>
>> Now, I need to do collect everthing for theorems. Hopefully,
>> core-des has not changed since I started working on it...
> i wonder is this genfrac is ok ... dangling \zeropoint etc
>
> can you check m-newmath?

Sorry, here are the correct definitions:

\def\splitfrac#1#2%
{\genfrac{}{}\zeropoint\textstyle%

\def\splitdfrac#1#2%
{\genfrac{}{}\zeropoint\displaystyle%

In LaTeX if the fourth argument of genfrac can be 0-3 as an
abbreviation for \displaystyle, \textstyle, etc. Since ConTeXt does not
follow this, it resulted in 0 and 1 in the output.

> maybe the few useful things in there can go to core-mat anyway

Or probably split core-mat, it is getting a bit too long. How about
disp-mat for  all display math related stuff, and core-mat for the
remaining macros in core-mat and m-newmat