[dev-context] Some math improvements

Aditya Mahajan adityam at umich.edu
Tue May 22 02:37:38 CEST 2007

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)

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 

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...

-------------- next part --------------
%AM: This should go to supp-box.tex. 

%D \macros
%D   {llap, rlap, tlap, blap, clap}
%D Some well known friends, but we implement them our own
%D way. We want the macros to work in both math and text mode.

\def\dorlap{\begingroup\dowithnextbox{\normalhbox to \zeropoint

\def\dollap{\begingroup\dowithnextbox{\normalhbox to \zeropoint

\def\doclap{\begingroup\dowithnextbox{\normalhbox to \zeropoint

\def\dodomathclap#1#2{\doclap{$\m at th#1#2$}}

\def\dodomathllap#1#2{\dollap{$\m at th#1#2$}}

\def\dodomathrlap#1#2{\dorlap{$\m at th#1#2$}}


%AM: I do not know where this belongs. Perhaps supp-mat.tex

%D \macros {cramed}
%D \TEX provides no primitive to force in cramped math mode.
%D Here is a macro that does so. It is based on a solution by
%D Don Knuth
%D \userul{http://www.ctan.org/tex-archive/digests/tex-implementors/042}.
%D The explanation is by Morten H?gholm's mathtools package.


%D Force a cramped style by issuing a non||existing radical
                            $\m at th#1\radical\zerocount{#2}$}
%D Make sure the height is correct
      \advance\scratchdimen .25\fontdimen5\textfont2

%AM: Not sure about these either. Either supp-box or supp-mat
%AM: core-mat.

%D \macros 
%D    {cramedllap, crampedrlap, crampedclap}
%D In many cases, one wants to use the \tex{clap} macro in
%D math mode while using subscripts. Normally, subscripts are
%D in cramped mode, and these macros allow you to go to
%D cramped mode. For example
%D \startbuffer
%D \startformula
%D   \sum_{a^2 < b^2 < c^2} \quad
%D   \sum_{\clap{a^2 < b^2 < c^2}} \quad
%D   \sum_{\crampedclap{a^2 < b^2 < c^2}}
%D \stopformula
%D \stopbuffer
%D \typebuffer{\switchtobodyfont[24pt]\getbuffer}
%D Notice that \type{\clap{\cramped ... }} would also work,
%D but it requires \TEX\ to typeset it arguments 16 times.

\def\docrampedllap#1#2{{}\dollap{\docramped #1{#2}}}
\def\docrampedrlap#1#2{{}\dorlap{\docramped #1{#2}}}
\def\docrampedclap#1#2{{}\doclap{\docramped #1{#2}}}


%AM: This needs to replace the core-mat macros.

%D \macros
%D   {substack}
%D Preliminary code:
%D \startbuffer
%D \startformula
%D    \sum_{%
%D      \startsubstack
%D       i = 1 \NR
%D       i \neq n \NR
%D       i \neq m
%D       \stopsubstack
%D     }a_i
%D \stopformula
%D \stopbuffer
%D \getbuffer which was typed as \typebuffer
%D Notice that these macros give the correct spacing for
%D subscripts. Compare for example
%D \startbuffer
%D \startformula
%D \sum_{\startsubstack a \NR b \NR \stopsubstack} 
%D \text{ and }
%D \sum_{\scriptstyle a \atop \scriptstyle}
%D \stopformula
%D \typebuffer which gives \getbuffer

  {%\bgroup% Is this ok?
    \baselineskip\fontdimen10 \scriptfont\plustwo
    \advance\baselineskip\fontdimen12 \scriptfont\plustwo
    \lineskip\plusthree\fontdimen8 \scriptfont\plusthree

   %\egroup% Is this ok?

%AM: These need to go into math-tex. Perhaps I should also
%AM: port dotsint?

\def\dointkern  {\mkern-6mu\mathchoice{\mkern-3mu}{}{}{}}

\definemathcommand  [iint]     {\repeatintegral{1}}
\definemathcommand  [iiint]    {\repeatintegral{2}}
\definemathcommand  [iiiint]   {\repeatintegral{3}}

   \dorecurse{#1}{\appendtoks \intop \dointkern \to \scratchtoks}
   \appendtoks \intop \dointlimits \to \scratchtoks

%D If the \type{\limits} option is used after \type{\iint}, use
%D \type{\mathop} and fudge the left hand space a bit to make the
%D subscript visually centered.

   {\ifx\limits\next               \dointlimitcorrection
    \else \ifx \displaylimits\next \dointlimitcorrection


%AM: This needs to go to m-newmat.tex

%D \macros {splitfrac, splitdfrac}
%D Occasionally one needs to typeset multi||line fractions.
%D These commands use \tex{genfrac} to create such fractions.
%D \startbuffer
%D \startformula
%D      a=\frac{
%D          \splitfrac{xy + xy + xy + xy + xy}
%D                    {+ xy + xy + xy + xy}
%D        }
%D        {z}
%D      =\frac{
%D          \splitdfrac{xy + xy + xy + xy + xy}
%D                    {+ xy + xy + xy + xy}
%D        }
%D        {z}
%D \stopformula
%D \stopbuffer
%D \typebuffer \getbuffer
%D These macros are based on Michael J.~Downes posting on
%D comp.text.tex on 2001/12/06


    {\hfill\quad\mathstrut #2}}

More information about the dev-context mailing list