我正在准备一本用美国本土语言编写的书,需要多个重音字符。例如,输入这些字符\'{\b{a}}
很麻烦,并且会使源代码难以阅读,尤其是对于三重音字符。我想要的是以下输入/输出对:
'a = \'a
,a = \b{a}
',a = \'{\b{a}}
这是该问题的完整版本。
该部落目前使用两种不同的基于罗马字母的书写系统。我想定义两个不同的环境(\PMKencoding
和\AHWencoding
),以便在两种正字法中输出相同的代码:您需要做的就是切换环境。
该语言有 6 个基本元音。在 AHW 编码中,我想要a
= a
(即a
给出a
)、e
= e
、i
= i
、o
= o
、 =、 u
=u
和å
= au
)。在 PMK 中,a
= à
、e
= è
、i
= ì
、o
= 、= ò
、u
=ù
和å
= àu
。
在 AHW 中,长元音为aa
、ey
、ii
、ow
、uu
。aw
在 PMK 中,长元音为重音符号 + 长音符号:\`{\=a}}
、\`{\=e}}
、\`{\=i}}
、\`{\=o}}
、\`{\=u}}
、\`{\=a}}u
。
除了低音调外,元音还可以有高音或降音。它们也可以是鼻音。因此,每个元音可以以 12 种形式出现。我想用类似以下输入系统的东西对这 12 种形式进行编码。在以下所有情况下,我愿意接受有关符号的建议,但我绝对希望避免将 SHIFT 访问的字符(例如~
)与非 SHIFT 访问的字符(例如'
)混合;我发现这种混合会导致错误。 我选择的字符是从语言学家的角度直观的。
'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}}})
注意。我也接受'.,a
长高鼻音。上面,我使用了和;
的组合。 .
,
注 2. 我宁愿输入重音符号 + a 而不是抑扬符号 + a (我发现使用大量 SHIFT 笔画会降低打字速度并增加错误)。
注 3. 如果您认为出现了错误,PMK 正字法不会区分降调元音的长元音和短元音。
注 4. 从重音的角度来看,所有元音的行为都相同。但在 AHW 正字法中,长度以各种方式表示。元音i
和的u
行为类似a
(重复表示长度)。为了清楚起见,在最后,我附上了一份其他元音应做的事情的列表。
除了元音之外,辅音也有一些要求:
.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
字母 Y 有一些奇怪的语法特性,它要求:
.y = AHW i, PMK i
,y = AHW y, PMK (nothing)
最后,我需要一个符号,在 AHW 系统中是连字符,但在 PMK 系统中是空格。
~ = AHW -, PMK (i.e., a space).
我将非常乐意以书面形式感谢任何帮助。事实上,光是考虑编码就让我远离即将着手的项目太久了。
其他元音:
'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)
答案1
这可能会有用:
\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}
是'
由总是激活,但如果我们不在 Kiowa 语境中,则扩展为正常引号。否则,它会查看下一个字符:如果是逗号,它会吞掉它并执行\kiowa@k
,否则它会在下一个字符上使用尖音符。
当然,更改类别代码总是有风险的。不要在 Kiowa 文本中使用引号。
这是一个非常初步的版本;目前只定义了 AHW 编码中的短元音,但结果似乎不错。仍然需要决定如何处理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}
使用的想法\DeclareTextCompositeCommand
非常好:这里是如何改进以前的代码,而无需重载已经定义的命令。
% -*- 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}
我保留了 Emacs 输入编码指令,因为使用å
UTF Å
-8 肯定会破坏代码。
答案2
@egreg 这是我根据您的代码得出的结论。我相信任何有经验的人都会认为这是一个糟糕的黑客行为。但它满足了我的需要。
核心补充:我没有直接用、等\kiowa@AHW@longfallingnasal
来定义 eg,而是用单个预先存在的重音命令来定义它们,例如或,然后我用 来定义、、 等应该输出到什么。这允许单个字符输入(例如、)产生多个字符输出(例如 、)。 \'
\b
\"
\c
\DeclareTextCompositeCommand
\"a
\c å
A
å
Âa
áw
这是代码的一部分(仅适用于 AHW 编码中的长元音)。(请注意,\l
末尾 添加了\def\kiowa@AHW@long{\@ifnextchar\bgroup\kiowa@normal@equals\@firstofone\l}
,因此它=
不再只是“身份映射”。)
万一有人需要更多细节,我可以发布其余内容。当然,我仍然对更优雅的解决方案感兴趣。
\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}