Making and sorting index for Russian

Due to some constraints, the \index command doesn't work very well with UTF-8 characters (something which could only be solved with a brand new version, I'm afraid.)

You can overcome the issue by doing

\documentclass{book}
\usepackage[T1, T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, russian]{babel}
\usepackage[xindy]{imakeidx}
\makeindex

\makeatletter
\newcommand{\rindex}[2][\imki@jobname]{%
  \index[#1]{\detokenize{#2}}%
}
\makeatother

\begin{document}

\chapter{Первая}

\rindex{notepad}
\rindex{apple}
\rindex{часть}
\rindex{дерево}
\rindex{электрон}

\printindex

\end{document}

Calling

texindy -L russian -C utf8 <filename>.idx

produces the index as expected:

enter image description here


OK, thanks, this works now! But, there is some difference in English and Russian parts of Index. I mean each Russian word (group of words) has corresponding first letter in bold before, and English words are printed in common list. Can all parts of Index (all languages) be printed in a similar way?

I managed this with changing the \makeindex command in egreg's answer to:

\makeindex [options = -L russian -C utf8 -M latin-alph.xdy]

Here for this command could work you should pass -enable-write18 key to pdfLaTeX. Alternatively, you could run texindy manually passing -M latin-alph.xdy key to it.

Here latin-alph.xdy file should look like this:

(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"))

(require
  "rules/latin-tolower.xdy")

(use-rule-set
  :run 0
  :rule-set ("latin-tolower"))

(markup-letter-group
  :open-head "~n~n  \textbf {\Large "
  :close-head "}~n  \nopagebreak"
  :capitalize)

And the result is:

Index


OK, thanks, this works now! But, there is some difference in English and Russian parts of Index. I mean each Russian word (group of words) has corresponding first letter in bold before, and English words are printed in common list. Can all parts of Index (all languages) be printed in a similar way?

Just one more improving. You can use this simple solution.

(require "lang/english/utf8.xdy")
(require "lang/russian/utf8.xdy")

(define-sort-rule-orientations (forward backward forward forward))
(use-rule-set   
    :run 0
    :rule-set (
        "en-alphabetize" 
        "ru-alphabetize" 
        "en-ignore-special" 
        "ru-ignore-special"
    )
)   
(use-rule-set 
    :run 1
    :rule-set (
        "en-resolve-diacritics"  
        "ru-resolve-diacritics" 
        "en-ignore-special" 
        "ru-ignore-special"
    )
)
(use-rule-set 
    :run 2
    :rule-set (
        "en-resolve-case" 
        "ru-resolve-case" 
        "en-ignore-special"
        "ru-ignore-special"
    )
)
(use-rule-set 
    :run 3
    :rule-set (
        "en-resolve-special"
        "ru-resolve-special"
    )
)

Store this code to multilingual.xdy. And run:

texindy -C utf8 -M multilingual.xdy -o you-paper.ind you-paper.idx

Note: You shouldn't pass language to texindy (i.e. -L russian.), because multilingual.xdy contains description of both languages.

\makeindex [options = -L russian -C utf8 -M latin-alph.xdy]

If you prefer use imakeidx code will be

\makeindex [options = -C utf8 -M multilingual.xdy]

The result will be with latin-first sort order. result of multilingual.xdy

By the way, you can change sort order. Just swap language instructions in rule-sets.

Tags:

Xindy