# [NTG-context] Math literal colon

Hans Hagen pragma at wxs.nl
Fri Jul 24 15:34:08 CEST 2015

On 7/24/2015 2:40 PM, Hans Aberg wrote:
>
>> 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.

that is ok for some input sequences (this kind of input translation
happens for accented characters and some math like negated symbols) but
replacing <= in the input is bad as it is only meaningful in math and
not all input is math (and unicode lacks script/language tagging); keep
in mind that 'verbatim' in tex really means verbatim and input

> It will save a lot of programming time, at least on the ConTEXt project. :-)

not really as that code is already in place for years; in this case it
mainly boils down to adding some extra entries in the character database

(and this code is simple compared to other code so not much to save here)

Hans

-----------------------------------------------------------------