[dev-context] Incorporating math ligatures in ConTeXt

Aditya Mahajan adityam at umich.edu
Sun Dec 3 22:28:23 CET 2006


On Sun, 3 Dec 2006, Taco Hoekwater wrote:
> Aditya Mahajan wrote:
> > 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)

I am doing that and converting parts to the ConTeXt "style". Most 
things are working as expected.

> > 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 ConTeXtize mathlig.tex I came across two macros...Is 
there any ConTeXt equivalent of these?

\def\mathlig at let@cs#1#2{\expandafter\let\expandafter#1\csname#2\endcsname}

\def\mathlig at appendcs#1#2{\expandafter\edef\csname#1\endcsname{\csname#1\endcsname#2}}

If not, what will be the ConTeXt style of doing this?

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

I know. The catcode trickery can bit you in unexpected ways.

> Side note: Luatex allows direct unicode input
>    \definemathcaracter [→]       [rel] [sy] ["21] % 0x2192
>    $A → B$

Great. No more ugly hacks for utf :)


Aditya Mahajan | EECS Systems, University of Michigan
http://www.eecs.umich.edu/‾adityam | Ph: 734.262.4008

More information about the dev-context mailing list