[dev-context] Incorporating math ligatures in ConTeXt

Taco Hoekwater taco at elvenkind.com
Sun Dec 3 14:15:10 CET 2006


Hi,

Aditya Mahajan wrote:
> Hi Hans and Taco,
> 
> I recently came across mathlig.tex 
> (ftp://tug.ctan.org/pub/tex-archive/macros/generic/misc/mathlig.tex) 
> which allows one to write
> 
> \mathlig {->} {\rightarrow}
> 
> and then in math mode -> will be equal to \rightarrow so one can just 
> write
> 
> $A -> B$

Yes, that reads much better. It really should be a separate module
because of potential conflicts with active characters, but you can
just incorporate the existing mathlig.tex wholesale in a module
file since it appears to work (but consider using \protect/\unprotect
instead of the @ trickery)

> This file is way beyond my understanding of TeX. Some parts are easy, 
> but I just keep staring at definitions like
> 
> \def\actively#1#2{\begingroup\uccode`\~=`#2\relax\uppercase{\endgroup#1~}}
> 
> without understanding what it means.

This macro is a candidate for inclusion in the core (syst-ext). It
redefines the macro attached to an active character, even if that
character is not really active at this moment (such definitions
remain dormant).

In this case, it is used to make characters like < and - run a macro.
Normally this will be done in math mode only, because their \mathcode
becomes "8000 but the \catcode remains as it is.

But: whenever you switch the character to active mode, this macro will
now be executed instead of the original one, and that is why it has to
be a  module: consider what happens with \mathlig{:=}{\coloneq} in
french document ...


Side note: Luatex allows direct unicode input

   \definemathcaracter [→]       [rel] [sy] ["21] % 0x2192
   $A → B$

Best,

Taco



More information about the dev-context mailing list