マクロツイーター

はてダから移行した記事の表示が崩れてますが、そのうちに直せればいいのに(えっ)

Babel な話: hyphsubst パッケージ (2)

ここでは、hyphsubst パッケージの使用例として、ギリシャ語の分綴パターンの選択の問題を取り上げる。

問題

TeX Live 2012(および最近の W32TeX)の language.dat では、ギリシャ語の分綴パターンの設定は以下のようになっている。

ancientgreek loadhyph-grc.tex
monogreek loadhyph-el-monoton.tex
greek loadhyph-el-polyton.tex
=polygreek

つまり、単式の現代ギリシャ語用の「monogreek」、複式の現代ギリシャ語用の「polygreek」、古典ギリシャ語用の「ancientgreek」の 3 種類が登録されていて、「greek」は「polygreek」と同義になっている。*1

greek が polygreek の別名であるということは、Babel で greek 言語を選択すると、「複式現代ギリシャ語」用のパターンが適用されるが、古典ギリシャ語を含む文書を書く場合にはこれでは都合が悪い。以下ではこの状況を例示するサンプル文書を示す。ただし、「現在有効な分綴パターンが何か」という情報は非常に「外に見え難い」ので、ここでは TeX のコードを用意して「現在有効な分綴パターン」の内部情報を端末に出力する命令 \showhyphinfo を用意した。無論このコードの中身については気にする必要がない。

\documentclass[a4paper]{article}
% 古典ギリシャ語を使う設定
\usepackage[greek=ancientgreek]{hyphsubst}
\usepackage[greek,english]{babel}
\usepackage{teubner}
\makeatletter %!!!!!!!!!!!!!!!!!!!!!!!!!
\def\showhyphinfo{\typeout{Hyphenation =
\ifnum\language=\l@monogreek monotonic modern greek%
\else\ifnum\language=\l@polygreek polytonic modern greek%
\else\ifnum\language=\l@ancientgreek ancient greek%
\else not greek\fi\fi\fi}}
\makeatother  %!!!!!!!!!!!!!!!!!!!!!!!!!
\begin{document}
\begin{otherlanguage*}{greek}
\showhyphinfo % 現在有効なパターンの情報を表示
P'anta <re~i.
\end{otherlanguage*}
\end{document}

この文書をコンパイルすると、画面(およびログ)に次のように出力される。

Hyphenation = polytonic modern greek

つまり、先に説明した通り、複式現代ギリシャ語のパターンが有効になっている。ここで「古典ギリシャ語」用のパターン(ancientgreek)を有効にしたい。

解決方法

hyphsubst を使う場合は、「何を何と同義にしたいのか」に注意する必要がある。ancientgreek を使いたいのだから、「何に」は ancientgreek であることは自明だが、「何を」はどうだろう。変更したいのは、「greek 言語に切り替えた時に有効なパターン」であり、Babel の規則により、それは言語と同名の「greek」(既定ではそれが polygreek と同値になっている。)のはずである。従って、babel の読込の直前(2 行目)に以下の行を挿入すればよい。

\usepackage[greek=ancientgreek]{hyphsubst}

修正した文書をコンパイルすると、正しく反映されていることがわかる。

Hyphenation = ancient greek

古典ギリシャ語と現代ギリシャ語を切り替える

文書中での \HyphSubstLet の実行を利用すると、古典ギリシャ語と現代ギリシャ語の間で分綴パターンを切り替えることも可能である。

\documentclass[a4paper]{article}
\makeatletter %!!!!!!!!!!!!!!!!!!!!!!!!!
\def\showhyphinfo{\typeout{Hyphenation =
\ifnum\language=\l@monogreek monotonic modern greek%
\else\ifnum\language=\l@polygreek polytonic modern greek%
\else\ifnum\language=\l@ancientgreek ancient greek%
\else not greek\fi\fi\fi}}
\makeatother  %!!!!!!!!!!!!!!!!!!!!!!!!!
\usepackage{hyphsubst}
\usepackage[greek]{babel}
\languageattribute{greek}{polutoniko}
\begin{document}
\showhyphinfo

\HyphSubstLet{greek}{ancientgreek}\showhyphinfo
<H t'eqnh makr'h.

\HyphSubstLet{greek}{monogreek}\showhyphinfo
H t'eqnh makr'a.
\end{document}

この文書をコンパイルすると、画面に以下のように表示される。

Hyphenation = polytonic modern greek
Hyphenation = ancient greek
Hyphenation = monotonic modern greek

*1:実際には「polygreek」の方が別名となっているが、どちらが別名であっても内部的には変わらない。