Re: [dev-context] [NTG-context] llap, rlap, clap equivalent for math
Aditya Mahajan wrote:
Inspired by Alexander Perlis' macros in http://www.tug.org/TUGboat/Articles/tb22-4/tb72perlS.pdf can we have the math equivalent of llap etc. in ConTeXt.
Ideally, \llap etc. should be modified so that they work in math mode also (just like \smash and \phantom). If not, we can have the following simple definitions:
Some extra \do 's fix up the textmode comands (supp-box.tex): \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} \def\dodomathclap#1#2{\doclap{$\m@th#1#2$}} \def\domathllap{\mathpalette\dodomathllap} \def\dodomathllap#1#2{\dollap{$\m@th#1#2$}} \def\domathrlap{\mathpalette\dodomathrlap} \def\dodomathrlap#1#2{\dorlap{$\m@th#1#2$}} \unexpanded\def\rlap{\ifmmode \@EA\domathrlap \else \@EA\dorlap \fi} \unexpanded\def\llap{\ifmmode \@EA\domathllap \else \@EA\dollap \fi} \unexpanded\def\clap{\ifmmode \@EA\domathclap \else \@EA\doclap \fi} Cheers, Taco
Taco Hoekwater wrote:
Aditya Mahajan wrote:
Inspired by Alexander Perlis' macros in http://www.tug.org/TUGboat/Articles/tb22-4/tb72perlS.pdf can we have the math equivalent of llap etc. in ConTeXt.
Ideally, \llap etc. should be modified so that they work in math mode also (just like \smash and \phantom). If not, we can have the following simple definitions:
Some extra \do 's fix up the textmode comands (supp-box.tex):
\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} \def\dodomathclap#1#2{\doclap{$\m@th#1#2$}}
\def\domathllap{\mathpalette\dodomathllap} \def\dodomathllap#1#2{\dollap{$\m@th#1#2$}}
\def\domathrlap{\mathpalette\dodomathrlap} \def\dodomathrlap#1#2{\dorlap{$\m@th#1#2$}}
\unexpanded\def\rlap{\ifmmode \@EA\domathrlap \else \@EA\dorlap \fi} \unexpanded\def\llap{\ifmmode \@EA\domathllap \else \@EA\dollap \fi} \unexpanded\def\clap{\ifmmode \@EA\domathclap \else \@EA\doclap \fi}
or \unexpanded\def\rlap{\mathortext\domathrlap\dorlap} \unexpanded\def\llap{\mathortext\domathllap\dollap} \unexpanded\def\clap{\mathortext\domathclap\doclap} 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 -- ----------------------------------------------------------------- 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 -----------------------------------------------------------------
On Thu, 19 Apr 2007, Hans Hagen wrote:
Taco Hoekwater wrote:
Aditya Mahajan wrote:
Inspired by Alexander Perlis' macros in http://www.tug.org/TUGboat/Articles/tb22-4/tb72perlS.pdf can we have the math equivalent of llap etc. in ConTeXt.
Ideally, \llap etc. should be modified so that they work in math mode also (just like \smash and \phantom). If not, we can have the following simple definitions:
Some extra \do 's fix up the textmode comands (supp-box.tex):
\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} \def\dodomathclap#1#2{\doclap{$\m@th#1#2$}}
\def\domathllap{\mathpalette\dodomathllap} \def\dodomathllap#1#2{\dollap{$\m@th#1#2$}}
\def\domathrlap{\mathpalette\dodomathrlap} \def\dodomathrlap#1#2{\dorlap{$\m@th#1#2$}}
\unexpanded\def\rlap{\ifmmode \@EA\domathrlap \else \@EA\dorlap \fi} \unexpanded\def\llap{\ifmmode \@EA\domathllap \else \@EA\dollap \fi} \unexpanded\def\clap{\ifmmode \@EA\domathclap \else \@EA\doclap \fi}
or
\unexpanded\def\rlap{\mathortext\domathrlap\dorlap} \unexpanded\def\llap{\mathortext\domathllap\dollap} \unexpanded\def\clap{\mathortext\domathclap\doclap}
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
Maybe change \dorlap to \dotextrlap. Remembering that \dotextrlap is for text mode and \domathrlap is for math mode is easier than remembering the difference between \dorlap and \domathrlap. Does it make sense to make tlap and blap behave in the same way? I do not know of any advantage of them right away, but it may be better to be consistent with all commands of one 'category'. Aditya
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
participants (3)
-
Aditya Mahajan
-
Hans Hagen
-
Taco Hoekwater