Aditya Mahajan wrote:
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)
made even more cramped:

\def\docramped#1#2%
 {\begingroup % added HH, made even more cramped
  \setbox\scratchbox\hbox
    {\nulldelimiterspace\zeropoint
     [EMAIL PROTECTED]
  \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}


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? maybe the few useful things in there can go to core-mat anyway Hans

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

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

%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 Here we will add code on demand. So, just let us know what
%D should go in here.

%M \usemodule[newmat]

\unprotect

%D \macros
%D   {qedsymbol}
%D
%D [HH] The general Quod Erat Domonstrandum symbol is defined
%D in such a way that we can configure it. Because this symbol
%D is also used in text mode, we make it a normal text symbol
%D with special behavior.

\def\qedsymbol#1%
  {\ifhmode
     \unskip~\hfill#1\par
   \else\ifmmode
     \eqno#1\relax % Do we really need the \eqno here?
   \else
     \leavevmode\hbox{}\hfill#1\par
   \fi\fi}

\definesymbol [qed] [\qedsymbol{\mathematics{\square}}]

%D \macros
%D   {QED}
%D
%D [HH] For compatbility reasons we also provide the \type
%D {\QED} command. In case this command is overloaded, we still
%D have the symbol available. \symbol[qed]

\def\QED{\symbol[qed]}

%D \macros
%D   {genfrac}
%D
%D [TH] The definition of \type {\genfrac} \& co. is not
%D trivial, because it allows some flexibility. This is
%D supposed to be a user||level command, but will fail quite
%D desparately if called outside math mode (\CONTEXT\ redefines
%D \type {\over})
%D
%D [HH] We clean up this macro a bit and (try) to make it
%D understandable. The expansion is needed for generating
%D the second argument to \type {\dogenfrac}, which is to
%D be a control sequence like \type {\over}.

\unexpanded\def\genfrac#1#2#3#4%
  {\edef\!!stringa
     {#1#2}%
   \expanded
     {\dogenfrac{#4}%
      \csname
        \ifx @[EMAIL PROTECTED]
          \ifx\!!stringa\empty
            \strippedcsname\normalover
          \else
            \strippedcsname\normaloverwithdelims
          \fi
        \else
          \ifx\!!stringa\empty
            \strippedcsname\normalabove
          \else
            \strippedcsname\normalabovewithdelims
          \fi
        \fi
      \endcsname}%
     {#1#2#3}}

\def\dogenfrac#1#2#3#4#5%
  {{#1{\begingroup#4\endgroup#2#3\relax#5}}}

%D \macros
%D   {dfrac, tfrac, frac, dbinom, tbinom, binom}
%D
%D [TH] No need to make these \type {\unexpanded} as well.

%\def\dfrac {\genfrac\empty\empty\empty\displaystyle}
%\def\tfrac {\genfrac\empty\empty\empty\textstyle}
%\def\frac  {\genfrac\empty\empty\empty\donothing}

\def\dfrac {\genfrac\empty\empty\empty\displaystyle}
\def\tfrac {\genfrac\empty\empty\empty\textstyle}
\def\frac  {\genfrac\empty\empty\empty\donothing}

\def\dbinom{\genfrac()\zeropoint\displaystyle}
\def\tbinom{\genfrac()\zeropoint\textstyle}
\def\binom {\genfrac()\zeropoint\donothing}

\def\xfrac {\genfrac\empty\empty\empty\scriptstyle}
\def\xxfrac{\genfrac\empty\empty\empty\scriptscriptstyle}

%D Better:

\unexpanded\def\frac#1#2{\mathematics{\genfrac\empty\empty\empty\donothing{#1}{#2}}}

%D [HH] This shows up as:
%D
%D \startbuffer
%D $\dfrac {1}{2} \tfrac {1}{2} \frac {1}{2}$
%D $\dbinom{1}{2} \tbinom{1}{2} \binom{1}{2}$
%D \stopbuffer
%D
%D \typebuffer
%D
%D \getbuffer

%D \macros
%D   {text}
%D
%D [TH] \type {\text} is a command to typeset more or less
%D ordinary text inside of super- and sub|-|scripts. It has to
%D do a full font switch to get the sides right, so it will be
%D quite slow. \type {\text} kind of replaces \CONTEXT's \type
%D {\mathstyle} command.

%D [HH] This macro is now also moved to the core, but we
%D keep it here as well for completeness.
%D
%D \starttyping
%D \unexpanded\def\mathtext
%D   {\mathortext\domathtext\hbox} % [EMAIL PROTECTED]@EA\hbox\fi}
%D
%D \def\domathtext#1%
%D   {\mathchoice
%D      {\dodomathtext\displaystyle\textface        {#1}}%
%D      {\dodomathtext\textstyle   \textface        {#1}}%
%D      {\dodomathtext\textstyle   \scriptface      {#1}}%
%D      {\dodomathtext\textstyle   \scriptscriptface{#1}}}
%D
%D \def\dodomathtext#1#2#3% no \everymath !
%D  %{\hbox{\everymath{#1}\switchtobodyfont  [#2]#3}} % 15 sec
%D   {\hbox{\everymath{#1}\setcurrentfontbody{#2}#3}} %  3 sec (no math)
%D \stoptyping

%D [HH] We use the following indirectness because \type {\text}
%D is a natural candidate for user macros (actually, it is
%D used in some modules).
%D
%D \starttyping
%D \let\text\mathtext
%D \stoptyping

%D [HH] Actually, the font switch is not that slow when
%D typefaces are used. If needed this macro can be sped up.
%D
%D \startbuffer
%D ordinary text $x^{\text{extra ordinary text}}$
%D \stopbuffer
%D
%D \typebuffer
%D
%D \getbuffer

%D \macros
%D  {mathhexbox}
%D
%D [TH] \type {\mathhexbox} is also user||level (already
%D defined in Plain \TEX). It allows to get a math character
%D inserted as if it was a text character.

[EMAIL PROTECTED]"#1#2#3$}}

%D \macros
%D   {boxed}
%D
%D [HH] Another macro that users expect (slightly adapted):

\def\boxed
  {\ifmmode\expandafter\mframed\else\expandafter\framed\fi}

%D \macros
%D   {cfrac}
%D
%D [HH] Now let us see what this one does:
%D
%D \startbuffer
%D $\cfrac{12}{3} \cfrac[l]{12}{3} \cfrac[c]{12}{3} \cfrac[r]{12}{3}$
%D $\cfrac{1}{23} \cfrac[l]{1}{23} \cfrac[c]{1}{23} \cfrac[r]{1}{23}$
%D \stopbuffer
%D
%D \typebuffer
%D
%D \getbuffer

\definecomplexorsimple\cfrac

\def\simplecfrac
  {\complexcfrac[c]}

\def\complexcfrac[#1]#2#3%
  {{\displaystyle
    \frac
      {\strut\ifx r#1\hfill\fi#2\ifx l#1\hfill\fi}%
      {#3}}%
    \kern-\nulldelimiterspace}

%D [HH] The next alternative is nicer:

\def\simplecfrac     {\docfrac[cc]}
\def\complexcfrac[#1]{\docfrac[#1cc]}

\def\docfrac[#1#2#3]#4#5%
  {{\displaystyle
    \frac
      {\strut
       \ifx r#1\hfill\fi#4\ifx l#1\hfill\fi}%
      {\ifx r#2\hfill\fi#5\ifx l#2\hfill\fi}%
    \kern-\nulldelimiterspace}}

%D [HH] Now we can align every combination we want:
%D
%D \startbuffer
%D $\cfrac{12}{3} \cfrac[l]{12}{3} \cfrac[c]{12}{3} \cfrac[r]{12}{3}$
%D $\cfrac{1}{23} \cfrac[l]{1}{23} \cfrac[c]{1}{23} \cfrac[r]{1}{23}$
%D $\cfrac[cl]{12}{3} \cfrac[cc]{12}{3} \cfrac[cr]{12}{3}$
%D $\cfrac[lc]{1}{23} \cfrac[cc]{1}{23} \cfrac[rc]{1}{23}$
%D \stopbuffer
%D
%D \typebuffer
%D
%D \getbuffer

%D \macros
%D   {splitfrac, splitdfrac}
%D
%D Occasionally one needs to typeset multi||line fractions.
%D These commands use \tex{genfrac} to create such fractions.
%D
%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
%D \typebuffer \getbuffer
%D
%D These macros are based on Michael J.~Downes posting on
%D comp.text.tex on 2001/12/06

\def\splitfrac#1#2%
  {\genfrac\empty\empty\zeropoint\plusone
    {\textstyle#1\quad\hfill}%
    {\textstyle\hfill\quad\mathstrut#2}}

\def\splitdfrac#1#2%
  {\genfrac\empty\empty\zeropoint\zerocount
    {#1\quad\hfill}
    {\hfill\quad\mathstrut #2}}

\protect \endinput

%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\tw@
   \advance\baselineskip\fontdimen12 \scriptfont\tw@
   \lineskip\thr@@\fontdimen8 \scriptfont\thr@@
   \lineskiplimit\lineskip
   \ialign\bgroup\ifx [EMAIL PROTECTED]

\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
   [EMAIL PROTECTED]&&\thickspace\hfil
     [EMAIL PROTECTED]

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

\protect \endinput
_______________________________________________
dev-context mailing list
[email protected]
http://www.ntg.nl/mailman/listinfo/dev-context

Reply via email to