I am typesetting a document in french, hence using xindy to create an index.
I have three levels of references : major, which is typesetted in bold; default which is typesetted in roman and minor, which displays in italics.
For a better readability of the index, I want the following order of the location-references to be respected: major, default, minor; like this:
Then, I edited the xindy style file to create groups:
but I also want the minor page number to disappear in favor of the default one:
Almost done, but the minor reference still displays before the default one because of its value. When I introduce more nesting in the groups definition, xindy returns an error:
(define-attributes (("major") (("default") ("minor"))) )
ERROR: nesting level too deep !
Is the style I want, implying group ordering and substituing, possible with xindy?
Below is an example.
% pdflatex -draftmode test.tex; texindy -M style.xdy -C utf8 test.idx; pdflatex test.tex
\documentclass[a4paper, 12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[xindy]{imakeidx}
\usepackage{filecontents}
\begin{filecontents*}{style.xdy}
(define-attributes (("major") ("default" "minor")) )
(markup-attribute-group-list :sep "; ")
(merge-to "minor" "default" :drop)
(markup-locref :attr "major" :open "\textbf{" :close "}")
(markup-locref :attr "minor" :open "\textit{" :close "}")
(markup-locclass-list :open "\dotfill")
\end{filecontents*}
\makeindex
\begin{document}
\verb+\index{Index entry|minor}+\index{Index entry|minor}
\newpage
\verb+\index{Index entry|major}+\index{Index entry|major}
\newpage
\verb+\index{Index entry}+\index{Index entry}
\verb+\index{Index entry|minor}+\index{Index entry|minor}
\printindex
\verb+(define-attributes (("major") ("default" "minor")) )+
\end{document}
Addendum:
After the Sergei Golovan’s answer, I tried some tests.
The method seems to work well with alone index references, although when using intervals with |( and |), warnings can appear:
Processing index... [10%]
WARNING: Found a :close-range in the index that wasn't opened before!
The warning seems to me very similar to this bug: https://sourceforge.net/p/xindy/bugs/54/ , as it appears when interval indexes are used. Sadly, it erases location references.
It also seems that sometimes, the process of substituing which occurs because of the defined groups, can lead to a warning.
This would need more tests to find a pattern and avoid errors in the final documents. I think this question should stay open to other solutions.