0

I want to create a multilingual (Russian and English) alphabetical index. makeidx doesn't work with Cyrrilic symbols, so as far as I know the best solution is to use xindy option in imakeidx. I tried to run the code that was found here:

\documentclass[openany]{book}
\usepackage[T1, T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, russian]{babel}
\usepackage{tikz} 

\usepackage{xcolor}
\definecolor{purpl}{RGB}{150, 120, 182} 
\usepackage{calc} 

\usepackage[xindy]{imakeidx}
\makeindex[program=texindy, options=-M mystyle.xdy -L russian -C utf8]

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

\usepackage[breaklinks,pdftex,hyperindex,unicode]{hyperref} 

\usepackage{filecontents}
\begin{filecontents*}{mystyle.xdy}
    ;;; xindy style file
    (markup-locclass-list :open "\dotfill" :sep "") 
    
    (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 "\nopagebreak\tikz\node at (0pt,0pt) [draw=none,fill=purpl!50,line width=1pt,inner sep=5pt]{\parbox{\linewidth-2\fboxsep-2\fboxrule-2pt}{\centering\large\sffamily\bfseries\textcolor{white}{ "
                :close-head "}}};\vspace*{0.2cm}\nopagebreak"
    :capitalize)
\end{filecontents*}

\begin{document}
    
    \chapter{Первая}
    
    \rindex{часть}
    \rindex{дерево}
    \rindex{электрон}
    \rindex{well}
    
    \printindex
    
\end{document}

I use TeXstudio 4.5.2 on Windows 10 and I compiled the code with PDFLaTeX compiler for document and texindy option for index:

enter image description here

And what I got:

enter image description here

You can see that the index isn't sorted in the correct order. Moreover, the code in filecontents* environment doesn't work at all, because there aren't any purple rectangles as in example at the link above.

However, if I use xindex option: enter image description here

--- I will get a properly sorted index:

enter image description here

But the code in filecontents* environment still doesn't work.

What should I do to get an alphabetically sorted index?

4
  • An alternative is upmendex. See an example here: tex.stackexchange.com/a/650880/5735 Jul 31, 2023 at 14:53
  • @JavierBezos, great thank you for your helpful answer! upmendex seems to be working. But can I automatize this process? To compile idx file I need to launch cmd from folder where my file is and manually input upmendex -s names <your file>.idx command. And TeXstudio doesn't support upmendex compiler. Jul 31, 2023 at 15:22
  • No idea, sorry, I don’t use TeXstudio. Jul 31, 2023 at 16:17
  • @JavierBezos, anyway, thank you Jul 31, 2023 at 16:18

0

You must log in to answer this question.

Browse other questions tagged .