如何对西里尔字母进行索引和排序?
尝试用塞尔维亚语单词制作索引:
\documentclass{book}
\usepackage[OT1, OT2]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, serbian]{babel}
\usepackage{imakeidx}
\makeindex[name=person,title={Indeks imena},options=-s index_style.ist]
\makeindex[program=makeindex,columns=2,intoc=true,options=-s index_style.ist]
\begin{document}
\chapter{Pitagora}
\index[person]{Pitagora|text}
\index[person]{Riman|text}
\index[person]{Vijet|text}
\index[person]{Gaus|text}
\printindex[person]
\end{document}
答案1
这对我有用:
\documentclass{book}
\usepackage[OT1, OT2]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, serbian]{babel}
\usepackage[xindy]{imakeidx}
\makeindex[program=truexindy,name=person,title={Indeks imena},options=-M mystyle.xdy]
\usepackage{filecontents}
\begin{filecontents*}{mystyle.xdy}
(require "lang/serbian/utf8-lang.xdy")
(require "texindy.xdy")
(define-letter-groups
("A" "B" "V" "G" "D" "DJ" "E" "ZH" "Z" "I" "J" "K" "L" "LJ" "M"
"N" "NJ" "O" "P" "R" "S" "T" "C1" "U" "F" "H" "C" "CH" "D2" "SH"))
(sort-rule "a" "A")
(sort-rule "b" "B")
(sort-rule "v" "V")
(sort-rule "g" "G")
(sort-rule "d" "D")
(sort-rule "Dj" "DJ")
(sort-rule "dj" "DJ")
(sort-rule "e" "E")
(sort-rule "Zh" "ZH")
(sort-rule "zh" "ZH")
(sort-rule "z" "Z")
(sort-rule "i" "I")
(sort-rule "j" "J")
(sort-rule "k" "K")
(sort-rule "l" "L")
(sort-rule "Lj" "LJ")
(sort-rule "lj" "LJ")
(sort-rule "m" "M")
(sort-rule "n" "N")
(sort-rule "Nj" "NJ")
(sort-rule "nj" "NJ")
(sort-rule "o" "O")
(sort-rule "p" "P")
(sort-rule "r" "R")
(sort-rule "s" "S")
(sort-rule "t" "T")
(sort-rule "c1" "C1")
(sort-rule "u" "U")
(sort-rule "f" "F")
(sort-rule "h" "H")
(sort-rule "c" "C")
(sort-rule "Ch" "CH")
(sort-rule "ch" "CH")
(sort-rule "d2" "D2")
(sort-rule "Sh" "SH")
(sort-rule "sh" "SH")
\end{filecontents*}
\begin{document}
\chapter{Pitagora}
\index[person]{Pitagora}
\index[person]{Riman}
\index[person]{Vijet}
\index[person]{Gaus}
\printindex[person]
\end{document}
然后你像这样编译:
pdflatex yourFile.tex
xindy -M mystyle.xdy -L serbian person.idx
pdflatex yourFile.tex
但要小心!您得到的与数字组合的字母(例如c1
或)d2
将被错误排序。始终最好使用utf8
输入和T2A
编码,而不是OT2
使用ASCII
输入。
PS 对于塞尔维亚语我始终建议使用包内容管理系统。在新版本中,我创建了实验性编码,您可以使用它dx cy
来џ ћ
获得更好的排序结果。
编辑:
经过一番尝试xindy
,我发现了另一种解决方案,可以解决使用数字编码的字母(OT2
例如c1
)的问题ћ
。此外,对于塞尔维亚语,字母组已经定义,因此无需再次编写,我们只需将拉丁字母或连字符映射到相应的西里尔 UTF-8 字母即可。
\documentclass{book}
\usepackage[OT1, OT2]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, serbian]{babel}
\usepackage[xindy]{imakeidx}
\makeindex[program=xindy,name=person,title={Indeks imena},columns=1]
\usepackage{filecontents}
\begin{filecontents*}{mystyle.xdy}
(require "texindy.xdy")
(merge-rule "DJ" "Ђ" :again)
(merge-rule "Dj" "Ђ" :again)
(merge-rule "dj" "Ђ" :again)
(merge-rule "ZH" "Ж" :again)
(merge-rule "Zh" "Ж" :again)
(merge-rule "zh" "Ж" :again)
(merge-rule "LJ" "Љ" :again)
(merge-rule "Lj" "Љ" :again)
(merge-rule "lj" "Љ" :again)
(merge-rule "NJ" "Њ" :again)
(merge-rule "Nj" "Њ" :again)
(merge-rule "nj" "Њ" :again)
(merge-rule "C1" "Ћ" :again)
(merge-rule "c1" "Ћ" :again)
(merge-rule "CH" "Ч" :again)
(merge-rule "Ch" "Ч" :again)
(merge-rule "ch" "Ч" :again)
(merge-rule "D2" "Џ" :again)
(merge-rule "d2" "Џ" :again)
(merge-rule "SH" "Ш" :again)
(merge-rule "Sh" "Ш" :again)
(merge-rule "sh" "Ш" :again)
(merge-rule "A" "А" :again)
(merge-rule "a" "А" :again)
(merge-rule "B" "Б" :again)
(merge-rule "b" "Б" :again)
(merge-rule "V" "В" :again)
(merge-rule "v" "В" :again)
(merge-rule "G" "Г" :again)
(merge-rule "g" "Г" :again)
(merge-rule "D" "Д" :again)
(merge-rule "d" "Д" :again)
(merge-rule "E" "Е" :again)
(merge-rule "e" "Е" :again)
(merge-rule "Z" "З" :again)
(merge-rule "z" "З" :again)
(merge-rule "I" "И" :again)
(merge-rule "i" "И" :again)
(merge-rule "J" "Ј" :again)
(merge-rule "j" "Ј" :again)
(merge-rule "K" "К" :again)
(merge-rule "k" "К" :again)
(merge-rule "L" "Л" :again)
(merge-rule "l" "Л" :again)
(merge-rule "M" "М" :again)
(merge-rule "m" "М" :again)
(merge-rule "N" "Н" :again)
(merge-rule "n" "Н" :again)
(merge-rule "O" "О" :again)
(merge-rule "o" "О" :again)
(merge-rule "P" "П" :again)
(merge-rule "p" "П" :again)
(merge-rule "R" "Р" :again)
(merge-rule "r" "Р" :again)
(merge-rule "S" "С" :again)
(merge-rule "s" "С" :again)
(merge-rule "T" "Т" :again)
(merge-rule "t" "Т" :again)
(merge-rule "U" "У" :again)
(merge-rule "u" "У" :again)
(merge-rule "F" "Ф" :again)
(merge-rule "f" "Ф" :again)
(merge-rule "H" "Х" :again)
(merge-rule "h" "Х" :again)
(merge-rule "C" "Ц" :again)
(merge-rule "c" "Ц" :again)
\end{filecontents*}
\begin{document}
\chapter{Pitagora}
\index[person]{Pitagora}
\index[person]{Riman}
\index[person]{Vijet}
\index[person]{Gaus}
\printindex[person]
\end{document}
之后,使用以下命令编译代码:
pdflatex yourFile.tex
xindy -M mystyle.xdy -C utf8 -L serbian person.idx
pdflatex yourFile.tex
当然,如果您想使用其他连字符,例如d1
for ђ
,则必须添加 line (merge-rule "d1" "Ђ" :again)
。