我正在尝试制作多语言索引。我使用xelatex
和xindy
。我的文档中有波兰语、立陶宛语和俄语术语。问题出在俄语上。我找到了一些关于如何在索引中混合拉丁语和西里尔语术语的类似解决方案,但它们都不完全正确,也不完全适合我:
解决方案 1:没有拉丁语单词的字母组。
解决方案2:命令require "lang/russian/utf8.xdy"
导致字母组重新定义并引发警告("Ђ" now maps to letter group "Рђ"
等等),并导致错误排序(例如拉丁字母“A”转到西里尔字母“A”组。这就是为什么“apple”出现在“notepad”之后)。同样的问题这里。
解决方案 3:此解决方案使用俄语作为主要语言,这不是我想要的。西里尔字母必须出现在拉丁字母之后。
解决方案4:与上述相同的问题。
最接近的解决方案是:
\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setdefaultlanguage{polish}
\setotherlanguage{russian}
\setmainfont{Linux Libertine O}
\usepackage[xindy]{imakeidx}
\makeindex [program=texindy, options = -C utf8 -M mystyle2.xdy -L polish]
\usepackage{filecontents}
\begin{filecontents*}{mystyle2.xdy}
(require "makeindex.xdy")
(require "lang/polish/utf8.xdy")
(require "lang/lithuanian/utf8.xdy")
(define-letter-groups
("Č" "Š" "Ū" "Ž" ;lithuanian specific letter groups
"А" "Б" "В" "Г" "Д" "Е" "Ё" "Ж" "З" "И" "Й" "К" "Л" "М" "Н" "О" "П" "Р" "С" "Т" "У" "Ф" "Х" "Ц" "Ч" "Ш" "Щ" "Ъ" "Ы" "Ь" "Э" "Ю" "Я" ;russian specific letter groups
)
)
(markup-letter-group
:open-head "~n~n \textbf {\Large "
:close-head "}~n \nopagebreak"
:capitalize)
\end{filecontents*}
\begin{document}
section{First}
%polish
\index{Ap} \index{Lipa} \index{Łaj} \index{Nos} \index{Sima} \index{Siesławin} \index{Skodlarski} \index{Salut} \index{Well} \index{Święto} \index{Żuk}
%lithuanian
\index{Ąsotis} \index{Liepa} \index{Šimkus} \index{Žas}
%russian
\index{Арбуз} \index{Волос} \index{Дерево} \index{Жиденький} \index{Пуля} \index{Пуп}
\printindex
\end{document}
但这里也存在一些缺陷。一些单词被分配到了错误的组:“Salut”在正确的“S”组中,但“Sima”和“Siesławin”不知何故被分配到了俄语“Ш”,而“Skodlarski”被分配到了俄语“Ю”。此外,在这样的解决方案中,没有处理小写字母(这并不重要,因为我只对姓氏使用索引,但在大多数一般情况下可能很重要)。
答案1
我这样做了(稍微修改了 Sergey Golovan 的代码书):
(define-letter-groups ("A" "Ą" "B" "C" "Ć" "Č" "D" "E" "Ę" "F" "G" "H" "I" "J" "K"
"L" "Ł" "M" "N" "O" "Ó" "P" "Q" "R" "S" "Ś" "Š" "T" "U" "V" "W" "X" "Y" "Z" "Ź" "Ż" "Ž"
"А" "Б" "В" "Г" "Д" "Е" "Ж" "З" "И" "Й" "К"
"Л" "М" "Н" "О" "П" "Р" "С" "Т" "У" "Ф" "Х" "Ц" "Ч" "Ш" "Щ" "Ъ"
"Ы" "Ь" "Э" "Ю" "Я"
))
(define-rule-set "alphabetize"
:rules (
("a" "A") ("b" "B")
("c" "C") ("d" "D") ("e" "E") ("f" "F") ("g" "G") ("h" "H")
("i" "I") ("j" "J") ("k" "K") ("l" "L") ("m" "M") ("n" "N")
("o" "O") ("p" "P") ("q" "Q") ("r" "R") ("s" "S") ("t" "T")
("u" "U") ("v" "V") ("w" "W") ("x" "X") ("y" "Y") ("z" "Z")
("а" "А") ("б" "Б") ("в" "В") ("г" "Г") ("д" "Д") ("е" "Е")
("Ё" "Е") ("ё" "Е") ("ж" "Ж") ("з" "З") ("и" "И") ("й" "Й")
("к" "К") ("л" "Л") ("м" "М") ("н" "Н") ("о" "О") ("п" "П")
("р" "Р") ("с" "С") ("т" "Т") ("у" "У") ("ф" "Ф") ("х" "Х")
("ц" "Ц") ("ч" "Ч") ("ш" "Ш") ("щ" "Щ") ("ъ" "Ъ") ("ы" "Ы")
("ь" "Ь") ("э" "Э") ("ю" "Ю") ("я" "Я")
))
(define-rule-set "ignore-special"
:rules (("?" "") ("." "") ("-" "") ("'" "") ("!" "")))
(define-sort-rule-orientations (forward forward))
(use-rule-set :run 0
:rule-set ("alphabetize" "ignore-special"))
(markup-letter-group
:open-head "~n~n \textbf {\Large "
:close-head "}~n \nopagebreak"
:capitalize)