2

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:

enter image description here

Then, I edited the xindy style file to create groups:

enter image description here

but I also want the minor page number to disappear in favor of the default one:

enter image description here

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.

1

I'm not sure I fully understand what happens, but using

(define-attributes (("major") ("default" "minor") ("minor")) )

seems to do the trick. Minor entries are still grouped with default ones if they are both present on one page, but if there's only a minor entry on a page, it falls into a separate "minor" group and goes after the default group.

the result

  • This “hack” seems to work nicely with alone index references and when there is only one group of attributes. Thank you for this. – gwenj Aug 7 '17 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.