3

I'm working on a an sorted name register produced by an external program with dozens of entries of one surname. To find the main pages easier I try to colorize it and played with different text styles (italic, bold). Xindy seems to be the right solution for this job (see MWE, the first output line is the test result, the second line is the target):

\documentclass{scrartcl}
\usepackage{xcolor}
\usepackage{makeidx}
\usepackage{filecontents}

\begin{filecontents*}{myindex.xdy}
  ;;; xindy style file
  (define-attributes ("gobble" "red" "green") )

  (markup-locclass-list :open "\dotfill" :close "" :sep ", ")
  (markup-locref :open "\mygobble{" :close "}" :attr "gobble" )
  (markup-locref :open "\myred{" :close "}" :attr "red" )
  (markup-locref :open "\color{green}{" :close "}\color{black}" :attr "green" )
\end{filecontents*}

\makeatletter
  \let\mygobble\@gobble
\makeatother

\def\myred#1{\color{red}#1\color{black}}

\makeindex

\begin{document}
  \noindent  
  \begingroup
    {\large\textbf{Test}\normalsize} \newline
    \let\clearpage\relax
    \printindex
  \endgroup

  \vspace{1cm} \noindent 
  {\large\textbf{Target}\normalsize} \newline \newline
  1. Entry ...................... % 
    2, \textbf{3}, {\color{green}4}, \textit{5}, {\color{red}6--8}

  \index{1. Entry|gobble}   
  \newpage Page 2. \index{1. Entry} \index{1. Entry|red}
  \newpage Page 3. \index{1. Entry|textbf}
  \newpage Page 4. \index{1. Entry|green}
  \newpage Page 5. \index{1. Entry|textit}
  \newpage Page 6. \index{1. Entry|red}
  \newpage Page 7. \index{1. Entry|red}
  \newpage Page 8. \index{1. Entry|red}

\end{document}

As we've learned from the famous Latex Companion, 2nd edit., Xindy greps always the first entry as a reference for all subsequent entries. I created a blind page only with the (in reality quite complex) main indices and modified the location reference to gobble the page number (see Remove page number from index entries).

I use full TeXLive 2015, compilation with:

pdflatex.exe myindex.tex
xindy -M texindy -M myindex -C utf8 -L german-duden myindex.idx
pdflatex.exe myindex.tex

Result is:

  • Gobbling works (no page number), but creates an extra comma (logical, but unwanted!)
  • Xindy direct colored attributes (green) placed at line end
  • Xindy indirect colored attributes (red) placed in between
  • Page number sorting depends on attribute type
  • Some separators are missing

How can Xindy's configuration file(s) be changed, that:

  1. Entries forced with a defined layout, but without tricks like gobbled page numbers?
  2. Sorting of pages is independent from attributes?
  3. All separators placed as expected?

Your Answer

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

Browse other questions tagged or ask your own question.