[NTG-context] Math literal colon
Hans Aberg
haberg-1 at telia.com
Fri Jul 24 14:40:49 CEST 2015
> On 24 Jul 2015, at 11:40, Hans Hagen <pragma at wxs.nl> wrote:
>
> On 7/20/2015 6:09 PM, Hans Aberg wrote:
>>
>>> On 20 Jul 2015, at 17:50, Manuel Blanco <manuelbl at ucm.es> wrote:
>>>
>>> A little bit more of intelligence can be given with
>>>
>>> \begingroup\lccode`\~=`\:\lowercase{\endgroup
>>> \unexpanded\def~}{\futurelet\tmptoken\docolon}
>>> \unexpanded\def\docolon{\ifx=\tmptoken\mathrel{\mathop{\mathchar`\:}}\else\colon\fi}
>>> \mathcode`\:="8000 %
>>>
>>> That lets you do $f: A \to B$ and $f(x) := x^2$
>>
>> For the second, one can use ≔ COLON EQUALS U+2254. But it is a good point, though.
>
> there is actually a more modern trick:
>
> \starttext
>
> \startluacode
> characters.mathpairs[0x3A] = { [0x3D] = 0x2254 }
> characters.mathpairs[0x3E] = { [0x3D] = 0x2265 }
> characters.mathpairs[0x3C] = { [0x3D] = 0x2264 }
> characters.mathpairs[0x3D] = { [0x3A] = 0x2255 }
> \stopluacode
>
> \startTEXpage
> $a := b <= =< c =: d >= e$
> \stopTEXpage
>
> \stoptext
I have experimented with a theorem proof assistant that admitted parallel ASCII and Unicode symbol names, but it turns out to be complicated. Think of C/C++ trigraphs, a chore to implement, only to be removed in the latest standards.
So I think one should only focus on UTF-8, and add TeX ASCII “\” commands as a complement.
One problem with this approach is the lack of Unicode input methods. But that may coming.
For example, instead having “:=“ in the input file and let Lua translate it, one can merely type it and let the text editor translate it ≔ COLON EQUALS U+2254.
It will save a lot of programming time, at least on the ConTEXt project. :-)
More information about the ntg-context
mailing list