[XeTeX] Defining a ligature-like macro

Jonathan Kew jonathan_kew at sil.org
Fri Nov 17 12:24:53 CET 2006


On 16 Nov 2006, at 10:58 am, Philipp Reichmuth wrote:

> Will Robertson schrieb:
>> On 11/16/06, James Crippen <jcrippen at gmail.com> wrote:
>>> What I'd like to have is something like a ligature such that when I
>>> type "kh", depending on some variable setting I either get "kh" or
>>> "\ul{k}" (or a similar macro) as the output.
>>
>> This is unfortunately impossible in TeX and XeTeX.
>

It's not *impossible*; however, it is tricky, and likely to have  
unwanted interaction with other things, so I wouldn't advise it. In  
principle, one could make 'k' an active character, and define it such  
that it examines the next token to see if it's 'h', and behaves as  
required (depending on a setting, as mentioned).

The problem with doing this -- or at least one of the problems -- is  
that it will make 'k' unusable as part of normal control sequence  
names, so careful planning and command aliasing might be needed. You  
really don't want to go here.

I note that "latin small letter k with line below" exists in Unicode  
at U+1E35, as do many other letters with diacritics as used in  
various transcription systems. Therefore, provided you use a font  
with adequate Unicode coverage (try Lucida Grande, Gentium, or Charis  
SIL, for example; Apple's Times also includes a fair selection,  
though I don't think it's as complete as the SIL fonts), you can use  
XeTeX's font mapping mechanism to access these; you'd have rules such as

   U+006B U+0068  <>  U+1E35

in a mapping file, and load this in conjuction with your choice of  
font when you want to print 'kh' as \ul{k}. This doesn't require any  
special macros in the text itself; it's just a choice that you make  
when defining the fonts to use.

HTH,

JK



More information about the XeTeX mailing list