[dev-context] [NTG-context] llap, rlap, clap equivalent for math

Aditya Mahajan adityam at umich.edu
Mon Apr 23 19:08:07 CEST 2007

On Thu, 19 Apr 2007, Hans Hagen wrote:
> before i add this, we need to be sure that llap/rlap are not used in
> math constructs which expect it to behave like an hbox

Continuing on the same thread, I found that the above definitions for 
(c|l|r)lap is not always adequate for math mode. The main problem is 
that tex does not provide a cramped primitive. The problem has been 
discussed with a solution proposed by Knuth 
http://www.ctan.org/tex-archive/digests/tex-implementors/042 and 
implemented for LaTeX in the mathtools package. Attached is my attempt 
to port it to ConTeXt. Please look at the \cramped and \crampedclap 
macros carefully before deciding to include them in the core. I have 
just copied most of the code from Knuth's definition and do not really 
understand what is happening here.

-------------- next part --------------

% Taco's definition of \tex{rlap}, etc.

\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$}}


%D There is a problem with using these in the math mode. The problem is
%D not with the macros, but with \TEX. \TEX provides no primitive to
%D force in cramped math mode. Here is a macro that does so. It is based
%D on a solution by 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

%D Now we provide commands for cramped styles


  {{}\doclap{\docramped #1{#2}}}


  {{}\dollap{\docramped #1{#2}}}


  {{}\dorlap{\docramped #1{#2}}}


Look at the output of
  \sum_{\clap{a^2 < b^2 < c^2}} \quad
  \sum_{a^2 < b^2 < c^2}

The formula on the left is not set in cramped style. The above
\tex{cramped} macro typesets in cramped style. So, we can use
  \sum_{\clap{\cramped a^2 < b^2 < c^2}} \quad
  \sum_{a^2 < b^2 < c^2}

But \type{\clap{\cramped ... }} typesets its arguments 16 times (which
is true for any command recursively using \tex{mathpalette}. So, we
provide a \tex{cramped...} version of \tex{clap} etc.

  \sum_{\crampedclap{a^2 < b^2 < c^2}} \quad
  \sum_{a^2 < b^2 < c^2}


More information about the dev-context mailing list