5

I'm working with a Ktunaxa, a First Nations language that uses the symbols ȼ and (and the uppercase equivalents Ȼ and , but not c or l.

How can I create an enivronment that would change all c and l to ȼ and ?

I'm aware I could create commands for the individual letters, but I'll usually be switching between English and Ktunaxa, so it makes sense to define an environment to make my life a little easier.


I would like this code:

This text has big C's and little c's and also a capital L. {\kt Na xaⱡȼin} means \textit{this dog.}

To create an output like this:

This text has big C's and little c's and also a capital L. Na xaⱡȼin means this dog.


Unicode code points: ȼ U+023C

Ȼ U+023B

ⱡ U+2C61

Ⱡ U+2C60

  • 1
    You could do this. But you might wanna look at XeTeX, for instance, where you can just use unicode input that would actually look quite a lot like your sample code – Au101 Nov 15 '15 at 6:09
  • Please give an example of a font that features ȼ, ⱡ, Ȼ and Ⱡ. – Mico Nov 15 '15 at 7:29
  • @Au101 - I think the OP's issue is that he/she may not have a keyboard that makes entering ȼ, Ȼ, , and particularly straightforward. Hence, he/she is looking for a solution in which LaTeX does an automatic conversion of c, C, l, and L to ȼ, Ȼ, , and within a certain environment. – Mico Nov 15 '15 at 8:11
  • Thanks for the XeTeX idea, I forgot about it and have been meaning to learn about it for a while. I'd still be interested in an answer for curiosity's sake. – Azor Ahai -him- Nov 15 '15 at 8:28
  • @Mico Arial has the characters. – Azor Ahai -him- Nov 15 '15 at 8:28
4

If you can use LuaLaTeX instead of either pdfLaTeX or XeLaTeX, it's possible to set up a Lua function as well as TeX macros and environments -- named \kt and ktenv in the example code below -- that perform an automated conversion of c, C, l, and L to ȼ, Ȼ, , and , respectively.

enter image description here

% !TEX TS-program = lualatex
\documentclass{article} 
\usepackage{luacode}
\begin{luacode}
function kt ( s )
    s = unicode.utf8.gsub ( s , "c", "ȼ" )
    s = unicode.utf8.gsub ( s , "C", "Ȼ" )
    s = unicode.utf8.gsub ( s , "l", "ⱡ" )
    s = unicode.utf8.gsub ( s , "L", "Ⱡ" )
    return ( s )
end
\end{luacode} 
\newcommand\kt[1]{\directlua{tex.sprint(kt(\luastring{#1}))}}
\newenvironment{ktenv}{%
   \directlua{luatexbase.add_to_callback( "process_input_buffer", kt, "kt")}}{%
   \directlua{luatexbase.remove_from_callback( "process_input_buffer", "kt")}}

\usepackage{fontspec}
\setmainfont{Arial} % features ȼ, Ȼ, ⱡ, and Ⱡ 
\begin{document}
Na xalcin, c C l L

\kt{Na xalcin, c C l L}

\begin{ktenv}
Na xalcin, c C l L
\end{ktenv}

Na xalcin, c C l L
\end{document}
3

For XeLaTeX, prepare a file ktunaxa.map containing

; TECkit mapping for TeX input conventions <-> Unicode characters

LHSName "ktunaxa"
RHSName "UNICODE"

pass(Unicode)

; ligatures from Knuth's original CMR fonts
U+002D U+002D           <>  U+2013  ; -- -> en dash
U+002D U+002D U+002D    <>  U+2014  ; --- -> em dash

U+0027          <>  U+2019  ; ' -> right single quote
U+0027 U+0027   <>  U+201D  ; '' -> right double quote
U+0022           >  U+201D  ; " -> right double quote

U+0060          <>  U+2018  ; ` -> left single quote
U+0060 U+0060   <>  U+201C  ; `` -> left double quote

U+0021 U+0060   <>  U+00A1  ; !` -> inverted exclam
U+003F U+0060   <>  U+00BF  ; ?` -> inverted question

; additions supported in T1 encoding
U+002C U+002C   <>  U+201E  ; ,, -> DOUBLE LOW-9 QUOTATION MARK
U+003C U+003C   <>  U+00AB  ; << -> LEFT POINTING GUILLEMET
U+003E U+003E   <>  U+00BB  ; >> -> RIGHT POINTING GUILLEMET

; additions for Ktunaxa
U+0043 <> U+023B ; C -> LATIN CAPITAL LETTER C WITH STROKE
U+0063 <> U+023C ; c -> LATIN SMALL LETTER C WITH STROKE
U+004C <> U+2C60 ; L -> LATIN CAPITAL LETTER L WITH DOUBLE BAR
U+006C <> U+2C61 ; l -> LATIN SMALL LETTER L WITH DOUBLE BAR

and run teckit_compile ktunaxa.map, which will write a file ktunaxa.tec in the current directory.

In the same directory, prepare the test file

\documentclass{article}
\usepackage{fontspec}

\setmainfont{Linux Libertine O}
\newfontfamily{\ktunaxafont}[Mapping=ktunaxa]{Linux Libertine O}

\DeclareTextFontCommand{\textkt}{\ktunaxafont}

\begin{document}

This text has big C's and little c's and also
a capital L. \textkt{Na xaⱡȼin} means \textit{this dog.}

This text has big C's and little c's and also
a capital L. \textkt{Na xalcin} means \textit{this dog.}

\textkt{CcLl}

\end{document}

Run XeLaTeX; the output, provided the font has the required glyphs, will be

enter image description here

There is no need that the fonts are the same; in the \newfontfamily declaration you can use any font having the glyphs for the language.

You can place your new .tec file (and also the .map source) in the directory

$TEXMFHOME/fonts/misc/xetex/fontmapping/ktunaxa/

(create the tree), where $TEXMFHOME stands for the personal tree; for TeX Live it is ~/texmf, for MacTeX it is ~/Library/texmf. For MiKTeX there are similar methods.

You can also use $TEXMFLOCAL, but this requires also mktexlsr.

An automated way for building the structure and moving the files is, assuming a Bash shell

mkdir -p $(kpsewhich -var-value=TEXMFHOME)/fonts/misc/xetex/fontmapping/ktunaxa
mv ktunaxa.{map,tec} $(kpsewhich -var-value=TEXMFHOME)/fonts/misc/xetex/fontmapping/ktunaxa/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.