12

I am a preparing a book in a native American language that requires multiply accented characters. Entering these by, e.g., \'{\b{a}} is painful and makes the source code difficult to read, especially for triply accented characters. What I'd like is the following input/output pairs:

'a = \'a

,a = \b{a}

',a = \'{\b{a}}

Here is the full version of the problem.

There are two different writing systems, based on the Roman alphabet, currently in use by the tribe. I want to define two different environments (\PMKencoding and \AHWencoding) such that the same code will output in both orthographies: all you need to do is switch the environment.

The language has 6 basic vowels. In the AHW encoding, I want a = a (i.e., a to give a), e = e, i = i, o = o, u = u, and å = au). In PMK, a = à, e = è, i = ì, o = ò, u = ù, and å = àu.

In AHW, the long versions of vowels are aa, ey, ii, ow, uu, aw. In PMK, they are grave + macron: \`{\=a}}, \`{\=e}}, \`{\=i}}, \`{\=o}}, \`{\=u}}, \`{\=a}}u.

In addition to low tone, vowels can also have high or falling tone. They can also be nasal. Thus, each vowel can occur in 12 forms. I'd like to encode these 12 forms with something like the following input system. In all of the following, I'm open to suggestions concerning the symbols, but I'd definitely like to avoid mixing SHIFT-accessed characters (e.g., ~) with non-SHIFT-accessed ones (e.g., '); I find such mixing leads to errors. I've chosen characters that are intuitive from a linguist's point of view.

'a = short high a (\'{a})
',a = short high nasal a (\'{\b{a}})
'.a = long high a (AHW \'{a}a, PMK \'{\=a})
';a = long high nasal a (AHW \'{\b{a}}a, PMK \'{\={\b{a}}})

`a = short falling a (\^a)
`,a = short falling nasal a (\^{\b{a}})
`.a = long falling a (AHW \^{a}a, PMK \^a)
`;a = long falling nasal a (AHW \^{\b{a}}a, PMK \^{\b{a}})

a = short low a (AHW a, PMK à)
,a = short nasal a (AHW \b{a}, PMK \`{\b{a}})
.a = long low a (AHW aa, PMK \'{\=a})
;a = long low nasal a (AHW \b{a}a, PMK \`{\={\b{a}}})

Note. I'm also open to '.,a for long high nasal. Above, I've used ; for the combination of . and ,.

Note 2. I would rather input grave+a than circumflex+a (I find using lots of SHIFT strokes slows typing speed and increases error).

Note 3. In case you think there's been a slip up, the PMK orthography does not distinguish long from short on vowels with falling tone.

Note 4. All vowels behave the same from the point of view of accents. But length is indicated by various means in the AHW orthography. The vowels i and u behave like a (repetition denotes length). For the sake of clarity, at the end, I've appended a list of what the other vowels should do.

In addition to vowels, consonants present some demands:

.p = AHW p, PMK f
`p = AHW ph, PMK p
'p = AHW p', PMK v

.t = AHW t, PMK j
`t = AHW th, PMK t
't = AHW t', PMK th

.k = AHW k, PMK c
`k = AHW kh, PMK k
'k = AHW k', PMK q

.c = AHW ts, PMK ch
'c = AHW ts', PMK x

The letter Y has some strange grammatical properties, which call for:

.y = AHW i, PMK i
,y = AHW y, PMK (nothing)

Finally, I need a symbol that will be a hyphen in the AHW system but a space in the PMK system.

~ = AHW -, PMK   (i.e., a space).

I will be more than happy to acknowledge any assistance in print. Truth is, just thinking about the encoding has kept me from the project I'm about to embark on for far too long.


Other vowels:

'e = short high e (\'{e})
',e = short high nasal e (\'{\b{e}})
'.e = long high e (AHW \'{e}y, PMK \'{\=e})
';e = long high nasal e (AHW \'{\b{e}}y, PMK \'{\={\b{e}}})

`e = short falling e (\^e)
`,e = short falling nasal e (\^{\b{e}})
`.e = long falling e (AHW \^{e}y, PMK \^e)
`;e = long falling nasal e (AHW \^{\b{e}}y, PMK \^{\b{e}})

e = short low e (AHW e, PMK \`e)
,e = short nasal e (AHW \b{a}, PMK \`{\b{e}})
.e = long low e (AHW ey, PMK \`{\=e})
;e = long low nasal e (AHW \b{e}y, PMK \`{\={\b{e}}})


'o = short high o (\'{o})
',o = short high nasal o (\'{\b{o}})
'.o = long high o (AHW \'{o}w, PMK \'{\=o})
';o = long high nasal o (AHW \'{\b{o}}w, PMK \'{\={\b{o}}})

`o = short falling o (\^o)
`,o = short falling nasal o (\^{\b{o}})
`.o = long falling o (AHW \^{o}w, PMK \^o)
`;o = long falling nasal o (AHW \^{\b{o}}w, PMK \^{\b{o}})

o = short low o (AHW o, PMK \`o)
,o = short nasal o (AHW \b{a}, PMK \`{\b{o}})
.o = long low o (AHW ow, PMK \`{\=o})
;o = long low nasal o (AHW \b{o}w, PMK \`{\={\b{o}}})




'å = short high au (\'{a}u)
',å = short high nasal au (\'{\b{a}}u)
'.å = long high au (AHW \'{a}w, PMK \'{\=a}u)
';å = long high nasal au (AHW \'{\b{a}}w, PMK \'{\={\b{a}}}u)

`å = short falling au (\^{a}u)
`,å = short falling nasal au (\^{\b{a}}u)
`.å = long falling au (AHW \^{a}w, PMK \^{a}u)
`;å = long falling nasal au (AHW \^{\b{a}}w, PMK \^{\b{a}}u)

å = short low au (AHW au, PMK \`å)
,å = short nasal au (AHW \b{a}u, PMK \`{\b{a}}u)
.å = long low au (AHW aw, PMK \'{\=a}u)
;å = long low nasal au (AHW \b{a}w, PMK \`{\={\b{a}}}u)
4
  • Hi! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). May 27, 2012 at 9:16
  • @DanielHarbour Is it \b or \k?
    – egreg
    May 27, 2012 at 22:26
  • @egreg It's \b for the purposes of this question. (\k is used in academic writing. I slipped up in my original post.) May 27, 2012 at 22:31
  • There's an immediate problem: you can't have a simple a transformed into à without making the a active, which is out of the question. What about preceding short vowels by - and long ones by =? This would also simplify the definitions, as we wouldn't need to make quotes, comma, period and semicolon active.
    – egreg
    May 28, 2012 at 8:32

2 Answers 2

11

This could be useful:

\documentclass{article}
\usepackage[T1]{fontenc}
\makeatletter
\newif\if@kiowa
\def\normal@quote{'}
{
 \catcode`\'=\active
 \gdef'{\if@kiowa\expandafter\kiowa@quote\else\expandafter\normal@quote\fi}
}
\AtBeginDocument{\catcode`\'=\active}
\def\kiowa@quote#1{%
  \ifx#1,%
    \expandafter\kiowa@k
  \else
    \'{#1}%
  \fi
}
\def\kiowa@k#1{\k{\'{#1}}}

\def\kiowaencoding{\@kiowatrue}
\makeatother

\begin{document}
These are ``quotes''

{\kiowaencoding 'a 'e ',a}
\end{document}

The ' is made always active, but expands to the normal quote if we are not in a Kiowa context. Otherwise it looks at the next character: if it is a comma it swallows it and executes \kiowa@k, otherwise it uses the acute accent over the next character.

Of course, changing category codes is always risky. Don't use quotes as such in Kiowa text.


Here's a very preliminary version; only short vowels in AHW encoding are defined, at the moment, but the result seems good. It's still to decide what to do for au.

\documentclass{article}
\usepackage[T1]{fontenc}

% -a   short
% -.a  short nasal
% -'a  short high
% -'.a short high nasal
% -`a  short falling
% -`.a short falling nasal
% =a   long
% =.a  long nasal
% ='a  long high
% ='.a long high nasal
% =`a  long falling
% =`.a long falling nasal

\makeatletter
\newif\if@kiowa
\newif\if@AHW
\DeclareRobustCommand{\AHWencoding}{\@kiowatrue\@AHWtrue}
\DeclareRobustCommand{\PMKencoding}{\@kiowatrue\@AHWfalse}
\def\kiowa@hyphen{\if@AHW\expandafter\kiowa@AHW@hyphen\else\expandafter\kiowa@PMK@hyphen\fi}
\def\kiowa@equals{\if@AHW\expandafter\kiowa@AHW@equals\else\expandafter\kiowa@PMK@equals\fi}

\def\kiowa@normal@hyphen{-}
\def\kiowa@normal@equals{=}
\begingroup
\catcode`-=\active
\catcode`==\active
\protected\gdef-{\if@kiowa\expandafter\kiowa@hyphen\else\expandafter\kiowa@normal@hyphen\fi}
\protected\gdef={\if@kiowa\expandafter\kiowa@equals\else\expandafter\kiowa@normal@equals\fi}
\endgroup
\AtBeginDocument{\catcode`-=\active \catcode`==\active}

%%% AHW
\def\kiowa@AHW@hyphen{%
  \@ifnextchar.\kiowa@AHW@shortnasal\kiowa@AHW@hyphen@i}
\def\kiowa@AHW@hyphen@i{%
  \@ifnextchar'\kiowa@AHW@shorthigh@m\kiowa@AHW@hyphen@ii}
\def\kiowa@AHW@shorthigh@m#1{%
  \@ifnextchar.\kiowa@AHW@shorthighnasal\kiowa@AHW@shorthigh}
\def\kiowa@AHW@hyphen@ii{%
  \@ifnextchar`\kiowa@AHW@shortfalling@m\kiowa@AHW@short}
\def\kiowa@AHW@shortfalling@m#1{%
  \@ifnextchar.\kiowa@AHW@shortfallingnasal\kiowa@AHW@shortfalling}
\def\kiowa@AHW@short{\@ifnextchar\bgroup\kiowa@normal@hyphen\@firstofone}
\def\kiowa@AHW@shortnasal#1#2{\b{#2}}
\def\kiowa@AHW@shorthigh#1{\'{#1}}
\def\kiowa@AHW@shorthighnasal#1#2{\b{\'{#2}}}
\def\kiowa@AHW@shortfalling#1{\^{#1}}
\def\kiowa@AHW@shortfallingnasal#1#2{\b{\^{#2}}}

\begin{document}
{\AHWencoding -a -.a -'a -'.a -`a -`.a -{}}
\end{document}

enter image description here


The idea of using \DeclareTextCompositeCommand is excellent: here's how the previous code can be improved, without overloading already defined commands.

% -*- coding: latin-1 -*-

\documentclass{article}
\usepackage[T1]{fontenc}

% -a   short
% -.a  short nasal
% -'a  short high
% -'.a short high nasal
% -`a  short falling
% -`.a short falling nasal
% =a   long
% =.a  long nasal
% ='a  long high
% ='.a long high nasal
% =`a  long falling
% =`.a long falling nasal

\makeatletter
\newif\if@kiowa
\newif\if@AHW
\DeclareRobustCommand{\AHWencoding}{\@kiowatrue\@AHWtrue}
\DeclareRobustCommand{\PMKencoding}{\@kiowatrue\@AHWfalse}
 \def\kiowa@hyphen{\if@AHW\expandafter\kiowa@AHW@hyphen\else\expandafter\kiowa@PMK@hyphen\fi}
\def\kiowa@equals{\if@AHW\expandafter\kiowa@AHW@equals\else\expandafter\kiowa@PMK@equals\fi}

\def\kiowa@normal@hyphen{-}
\def\kiowa@normal@equals{=}
\begingroup
\catcode`-=\active
\catcode`==\active
\protected\gdef-{\if@kiowa\expandafter\kiowa@hyphen\else\expandafter\kiowa@normal@hyphen\fi}
\protected\gdef={\if@kiowa\expandafter\kiowa@equals\else\expandafter\kiowa@normal@equals\fi}
\endgroup
\AtBeginDocument{\catcode`-=\active \catcode`==\active}

%%% AHW
\def\kiowa@AHW@equals{%
  \@ifnextchar.\kiowa@AHW@longnasal\kiowa@AHW@equals@i}
\def\kiowa@AHW@equals@i{%
  \@ifnextchar'\kiowa@AHW@longhigh@m\kiowa@AHW@equals@ii}
\def\kiowa@AHW@longhigh@m#1{%
  \@ifnextchar.\kiowa@AHW@longhighnasal\kiowa@AHW@longhigh}
\def\kiowa@AHW@equals@ii{%
  \@ifnextchar`\kiowa@AHW@longfalling@m\kiowa@AHW@long}
\def\kiowa@AHW@longfalling@m#1{%
  \@ifnextchar.\kiowa@AHW@longfallingnasal\kiowa@AHW@longfalling}
\def\kiowa@AHW@long{\@ifnextchar\bgroup\kiowa@normal@equals\@firstofone\l}
\def\kiowa@AHW@longnasal#1#2{\AHWlongnasal{#2}}
\def\kiowa@AHW@longhigh#1{\AHWlonghigh{#1}}
\def\kiowa@AHW@longhighnasal#1#2{\AHWlonghighnasal{#2}}
\def\kiowa@AHW@longfalling#1{\AHWlongfalling #1}
\def\kiowa@AHW@longfallingnasal#1#2{\AHWlongfallingnasal #2}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%AHW long falling nasal
\DeclareTextAccent\AHWlongfallingnasal{T1}{2} % just a dummy
\DeclareTextCompositeCommand{\AHWlongfallingnasal}{T1}{a}{\b{\^{a}}a}
\DeclareTextCompositeCommand{\AHWlongfallingnasal}{T1}{e}{\b{\^{e}}y}
\DeclareTextCompositeCommand{\AHWlongfallingnasal}{T1}{i}{\b{\^{i}}i}
\DeclareTextCompositeCommand{\AHWlongfallingnasal}{T1}{o}{\b{\^{o}}w}
\DeclareTextCompositeCommand{\AHWlongfallingnasal}{T1}{u}{\b{\^{u}}u}
\DeclareTextCompositeCommand{\AHWlongfallingnasal}{T1}{å}{\b{\^{a}}w}

\DeclareTextCompositeCommand{\AHWlongfallingnasal}{T1}{A}{\b{\^{A}}a}
\DeclareTextCompositeCommand{\AHWlongfallingnasal}{T1}{E}{\b{\^{E}}y}
\DeclareTextCompositeCommand{\AHWlongfallingnasal}{T1}{I}{\b{\^{I}}i}
\DeclareTextCompositeCommand{\AHWlongfallingnasal}{T1}{O}{\b{\^{O}}w}
\DeclareTextCompositeCommand{\AHWlongfallingnasal}{T1}{U}{\b{\^{U}}u}
\DeclareTextCompositeCommand{\AHWlongfallingnasal}{T1}{Å}{\b{\^{A}}w}
%%%AHW long falling nasal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%AHW long falling oral
\DeclareTextAccent\AHWlongfalling{T1}{2} % just a dummy
\DeclareTextCompositeCommand{\AHWlongfalling}{T1}{a}{\^{a}a}
\DeclareTextCompositeCommand{\AHWlongfalling}{T1}{e}{\^{e}y}
\DeclareTextCompositeCommand{\AHWlongfalling}{T1}{i}{\^{i}i}
\DeclareTextCompositeCommand{\AHWlongfalling}{T1}{o}{\^{o}w}
\DeclareTextCompositeCommand{\AHWlongfalling}{T1}{u}{\^{u}u}
\DeclareTextCompositeCommand{\AHWlongfalling}{T1}{å}{\^{a}w}

\DeclareTextCompositeCommand{\AHWlongfalling}{T1}{A}{\^{A}a}
\DeclareTextCompositeCommand{\AHWlongfalling}{T1}{E}{\^{E}y}
\DeclareTextCompositeCommand{\AHWlongfalling}{T1}{I}{\^{I}i}
\DeclareTextCompositeCommand{\AHWlongfalling}{T1}{O}{\^{O}w}
\DeclareTextCompositeCommand{\AHWlongfalling}{T1}{U}{\^{U}u}
\DeclareTextCompositeCommand{\AHWlongfalling}{T1}{Å}{\^{A}w}
%%%AHW long falling oral
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

{\AHWencoding 

=`.a =`.e =`.i =`.o =`.u =`.å

=`A =`E =`I =`O =`U =`Å

}

\end{document}

I've left the Emacs instruction for the input encoding because the usage of å and Å with UTF-8 will definitely break the code.

2
  • I gave your suggestion (start every vowel entry with - if it's a short vowel or = if it's a long one) a go. The resulting code is quite usable (i.e., easy to scan through and read qua text). This is what you had in mind right? (I'm using ', ,, etc for concreteness. Not sure if you're planning on assigning different characters to the accents.) Input: =',Eg-å ='eb-åt -e~.k=od-'ok,y-al-åmg,y-a` PMK output (_Ḗ for underlined _Ḗ): _Ḗgàu ḗbàut è cṑdókàlàumgà AHW output ( for underlined ): _Éygau éybaut e-kowdókhyalaumgya Looks good to me May 28, 2012 at 17:46
  • Ooh, that's great. I can see why au might be tricky, as might AHW long vowels, as the representation of length is repetition for a/i/u, y for e, and w for o/å. I'll pore over the code. May 28, 2012 at 20:07
0

@egreg Here's what I've come up with based on your code. I'm sure that anyone sophisticated will regard it as a horrible hack. But it does what I need.

Core addition: instead of defining e.g. \kiowa@AHW@longfallingnasal directly in terms of \', \b and so on, I've defined them in terms of single preexisting accent commands, e.g., \" or \c, and then I've used \DeclareTextCompositeCommand to define what \"a, \c å, etc. should output to. This allows single character inputs (e.g., A, å) to yield multiple character outputs (e.g., Âa, áw).

Here's part of the code (just for long vowels in the AHW encoding). (Note the addition of \l at the end of \def\kiowa@AHW@long{\@ifnextchar\bgroup\kiowa@normal@equals\@firstofone\l} so that = isn't just the "identity map" any more.)

In the unlikely event that anyone needs more detail, I can post the rest. Naturally, I remain interested in more elegant solutions.

\documentclass{article}
\usepackage[T1]{fontenc}

% -a   short
% -.a  short nasal
% -'a  short high
% -'.a short high nasal
% -`a  short falling
% -`.a short falling nasal
% =a   long
% =.a  long nasal
% ='a  long high
% ='.a long high nasal
% =`a  long falling
% =`.a long falling nasal

\makeatletter
\newif\if@kiowa
\newif\if@AHW
\DeclareRobustCommand{\AHWencoding}{\@kiowatrue\@AHWtrue}
\DeclareRobustCommand{\PMKencoding}{\@kiowatrue\@AHWfalse}
 \def\kiowa@hyphen{\if@AHW\expandafter\kiowa@AHW@hyphen\else\expandafter\kiowa@PMK@hyphen\fi}
\def\kiowa@equals{\if@AHW\expandafter\kiowa@AHW@equals\else\expandafter\kiowa@PMK@equals\fi}

\def\kiowa@normal@hyphen{-}
\def\kiowa@normal@equals{=}
\begingroup
\catcode`-=\active
\catcode`==\active
\protected\gdef-{\if@kiowa\expandafter\kiowa@hyphen\else\expandafter\kiowa@normal@hyphen\fi}
\protected\gdef={\if@kiowa\expandafter\kiowa@equals\else\expandafter\kiowa@normal@equals\fi}
\endgroup
\AtBeginDocument{\catcode`-=\active \catcode`==\active}

%%% AHW
\def\kiowa@AHW@equals{%
  \@ifnextchar.\kiowa@AHW@longnasal\kiowa@AHW@equals@i}
\def\kiowa@AHW@equals@i{%
  \@ifnextchar'\kiowa@AHW@longhigh@m\kiowa@AHW@equals@ii}
\def\kiowa@AHW@longhigh@m#1{%
  \@ifnextchar.\kiowa@AHW@longhighnasal\kiowa@AHW@longhigh}
\def\kiowa@AHW@equals@ii{%
  \@ifnextchar`\kiowa@AHW@longfalling@m\kiowa@AHW@long}
\def\kiowa@AHW@longfalling@m#1{%
  \@ifnextchar.\kiowa@AHW@longfallingnasal\kiowa@AHW@longfalling}
\def\kiowa@AHW@long{\@ifnextchar\bgroup\kiowa@normal@equals\@firstofone\l}
\def\kiowa@AHW@longnasal#1#2{\L{#2}}
\def\kiowa@AHW@longhigh#1{\d{#1}}
\def\kiowa@AHW@longhighnasal#1#2{\c{#2}}
\def\kiowa@AHW@longfalling#1{\j{#1}}
\def\kiowa@AHW@longfallingnasal#1#2{\"{#2}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%AHW long falling nasal
\DeclareTextCompositeCommand{\"}{T1}{a}{\b{\^{a}}a}
\DeclareTextCompositeCommand{\"}{T1}{e}{\b{\^{e}}y}
\DeclareTextCompositeCommand{\"}{T1}{i}{\b{\^{i}}i}
\DeclareTextCompositeCommand{\"}{T1}{o}{\b{\^{o}}w}
\DeclareTextCompositeCommand{\"}{T1}{u}{\b{\^{u}}u}
\DeclareTextCompositeCommand{\"}{T1}{å}{\b{\^{a}}w}

\DeclareTextCompositeCommand{\"}{T1}{A}{\b{\^{A}}a}
\DeclareTextCompositeCommand{\"}{T1}{E}{\b{\^{E}}y}
\DeclareTextCompositeCommand{\"}{T1}{I}{\b{\^{I}}i}
\DeclareTextCompositeCommand{\"}{T1}{O}{\b{\^{O}}w}
\DeclareTextCompositeCommand{\"}{T1}{U}{\b{\^{U}}u}
\DeclareTextCompositeCommand{\"}{T1}{Å}{\b{\^{A}}w}
%%%AHW long falling nasal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%AHW long falling oral
\DeclareTextCompositeCommand{\j}{T1}{a}{\^{a}a}
\DeclareTextCompositeCommand{\j}{T1}{e}{\^{e}y}
\DeclareTextCompositeCommand{\j}{T1}{i}{\^{i}i}
\DeclareTextCompositeCommand{\j}{T1}{o}{\^{o}w}
\DeclareTextCompositeCommand{\j}{T1}{u}{\^{u}u}
\DeclareTextCompositeCommand{\j}{T1}{å}{\^{a}w}

\DeclareTextCompositeCommand{\j}{T1}{A}{\^{A}a}
\DeclareTextCompositeCommand{\j}{T1}{E}{\^{E}y}
\DeclareTextCompositeCommand{\j}{T1}{I}{\^{I}i}
\DeclareTextCompositeCommand{\j}{T1}{O}{\^{O}w}
\DeclareTextCompositeCommand{\j}{T1}{U}{\^{U}u}
\DeclareTextCompositeCommand{\j}{T1}{Å}{\^{A}w}
%%%AHW long falling oral
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

{\AHWencoding 

=`.a =`.e =`.i =`.o =`.u =`.å

=`A =`E =`I =`O =`U =`Å

}

\end{document}
3
  • Using \DeclareTextCompositeCommand seems a great idea. I wouldn't overload \" and \j, however.
    – egreg
    Jun 3, 2012 at 10:04
  • @egreg What's the nature of the concern about overloading \", \j, \L, \l, etc.? Is the issue that, if I suddenly needed \" for umlaut, \j for dotless j, etc., then they wouldn't be available? (This could be fixed by defining new text composite commands, like \>, \<, etc.) Or is there some other issue? Jun 3, 2012 at 10:44
  • @egreg I've just now tried using \>. But it seems like I first need to tell tex to treat \> like an accent, i.e., on a par with \". Do you know how I accomplish this? Jun 3, 2012 at 13:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .