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.

Aditya
\unprotect

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

\def\dorlap{\begingroup\dowithnextbox{\normalhbox to \zeropoint
   {\flushnextbox\normalhss}\endgroup}\normalhbox}

\def\dollap{\begingroup\dowithnextbox{\normalhbox to \zeropoint
   {\normalhss\flushnextbox}\endgroup}\normalhbox}

\def\doclap{\begingroup\dowithnextbox{\normalhbox to \zeropoint
   {\normalhss\flushnextbox\normalhss}\endgroup}\normalhbox}

\def\domathclap{\mathpalette\dodomathclap}
[EMAIL PROTECTED]

\def\domathllap{\mathpalette\dodomathllap}
[EMAIL PROTECTED]

\def\domathrlap{\mathpalette\dodomathrlap}
[EMAIL PROTECTED]

\unexpanded\def\rlap{\mathortext\domathrlap\dorlap}
\unexpanded\def\llap{\mathortext\domathllap\dollap}
\unexpanded\def\clap{\mathortext\domathclap\doclap}

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

\def\cramped
  {\mathpalette\docramped}

\def\docramped#1#2%
%D Force a cramped style by issuing a non||existing radical
  {\setbox\scratchbox=\hbox{\nulldelimiterspace=\zeropoint%
                            [EMAIL PROTECTED]
%D Make sure the height is correct
   \ifx#1\displaystyle
      \scratchdimen=\fontdimen8\textfont3
      \advance\scratchdimen .25\fontdimen5\textfont2
   \else
      \scratchdimen=1.25\fontdimen8
      \ifx#1\textstyle\textfont
      \else
        \ifx#1\scriptstyle\scriptfont\else\scriptscriptfont\fi
      \fi      
      3
    \fi
    \advance\scratchdimen-\ht\scratchbox
    \ht\scratchbox=-\scratchdimen
    \box\scratchbox}

%D Now we provide commands for cramped styles

\def\crampedclap
  {\mathpalette\docrampedclap}

\def\docrampedclap#1#2%
  {{}\doclap{\docramped #1{#2}}}

\def\crampedllap
  {\mathpalette\docrampedllap}

\def\docrampedllap#1#2%
  {{}\dollap{\docramped #1{#2}}}

\def\crampedrlap
  {\mathpalette\docrampedrlap}

\def\docrampedrlap#1#2%
  {{}\dorlap{\docramped #1{#2}}}
\protect

\starttext

Look at the output of
\startbuffer
\startformula
  \sum_{\clap{a^2 < b^2 < c^2}} \quad
  \sum_{a^2 < b^2 < c^2}
\stopformula
\stopbuffer
\typebuffer{\switchtobodyfont[24pt]\getbuffer}

The formula on the left is not set in cramped style. The above
\tex{cramped} macro typesets in cramped style. So, we can use
\startbuffer
\startformula
  \sum_{\clap{\cramped a^2 < b^2 < c^2}} \quad
  \sum_{a^2 < b^2 < c^2}
\stopformula
\stopbuffer
\typebuffer{\switchtobodyfont[24pt]\getbuffer}

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.

\startbuffer
\startformula
  \sum_{\crampedclap{a^2 < b^2 < c^2}} \quad
  \sum_{a^2 < b^2 < c^2}
\stopformula
\stopbuffer
\typebuffer{\switchtobodyfont[24pt]\getbuffer}

\stoptext
_______________________________________________
dev-context mailing list
dev-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/dev-context

Reply via email to