4

@Nicola-Talbot managed to solve my last question: Makeindex, different kinds of references and collation in the index

Unfortunately I don't succeed to carry this solution beyond splitindex.

This was the premise: Consider an index with three different attributes, default, ii (implicit) and nn:

Shakespeare\index{Shakespeare}

famous playwright from Stratford\index{Shakespeare|ii}

note: William Shakespeare (/ˈʃeɪkspɪər/;[1] 26 April 1564 (baptised) – 23 April 1616)[nb 1] was an English poet, playwright, and actor, widely regarded as the greatest writer in the English language and the world's pre-eminent dramatist.\index{Shakespeare|nn}

If there are entries of the default type on a page the ones with attributes should be omitted from the output.

This MWE works:

\documentclass{scrartcl} 
\usepackage{filecontents}
\usepackage[T1]{fontenc} 
\usepackage[ngerman]{babel} 
\usepackage{makeidx}

\begin{filecontents*}{\jobname.xdy}
; list of allowed attributes

(define-attributes (( "default" "ii" "nn" )))

; define format to use for locations

(markup-locref :open "\emph{" :close "}" :attr "ii")
(markup-locref :open "\nn{" :close "}" :attr "nn")

; location list separators

(markup-locref-list :sep ", ")
(markup-range :open "\range{" :sep "}{" :close "}")

(merge-to "nn" "ii" :drop)    
\end{filecontents*}

\makeindex 

\newcommand{\nn}[1]{#1n}

\newcommand{\range}[2]{{\def\nn##1{##1}#1}--#2}

\begin{document} 

bla\index{Lahm} blablab\index{Lahm|nn}

bla\index{A} bla\index{A|nn}

bla\index{B} bla\index{B|nn}

\newpage

bla\index{Lahm|nn} blablab

bla\index{B|nn}

\newpage

bla\index{B|nn}

\printindex 
\end{document}

Unfortunately when I introduce splitindex (I have two indices), the MWE doesn't properly omit the attributes anymore:

\documentclass{scrartcl} 
\usepackage{filecontents}
\usepackage[T1]{fontenc} 
\usepackage[ngerman]{babel} 
  \usepackage[makeindex, protected]{splitidx}
\newindex[persons]{pw}

\begin{filecontents*}{\jobname.xdy}
; list of allowed attributes

(define-attributes (( "default" "ii" "nn" )))

; define format to use for locations

(markup-locref :open "\ii{" :close "}" :attr "ii")
(markup-locref :open "\nn{" :close "}" :attr "nn")

; location list separators

(markup-locref-list :sep ", ")
(markup-range :open "\range{" :sep "}{" :close "}")

(merge-to "nn" "ii" :drop)    
\end{filecontents*}

\makeindex 

\newcommand{\nn}[1]{#1n}
\newcommand{\ii}[1]{\emph{#1}}

\newcommand{\range}[2]{{\def\nn##1{##1}#1}--#2}

\begin{document} 

bla\sindex[pw]{Lahm} blablab\sindex[pw]{Lahm|nn}

bla\sindex[pw]{A} bla\sindex[pw]{A|nn}

bla\sindex[pw]{B} bla\sindex[pw]{B|nn}
bla\sindex[pw]{B} bla\sindex[pw]{B|ii}
\newpage

bla\sindex[pw]{Lahm|nn} blablab

bla\sindex[pw]{B|nn}

\newpage

bla\sindex[pw]{B|nn}

\printindex[pw] 
\end{document}

I believe it has something to do with splitindex as the .ilg brings up the same warnings as makeindex:

Generating output file ./indextest-pw.ind....
## Warning (input = ./indextest-pw.idx, line = 4; output = ./indextest-pw.ind, line = 3):
   -- Conflicting entries: multiple encaps for the same page under same key.

## Warning (input = ./indextest-pw.idx, line = 8; output = ./indextest-pw.ind, line = 7):
   -- Conflicting entries: multiple encaps for the same page under same key.

## Warning (input = ./indextest-pw.idx, line = 6; output = ./indextest-pw.ind, line = 7):
   -- Conflicting entries: multiple encaps for the same page under same key.

## Warning (input = ./indextest-pw.idx, line = 2; output = ./indextest-pw.ind, line = 11):
   -- Conflicting entries: multiple encaps for the same page under same key.

Any idea how to solve this? Or should is there another way to have two indices with xindy?

  • What should the output be? Or what output do you get and what's wrong with it? I've compiled your example, but I'm really not sure what is meant to be wrong with it. – cfr Apr 8 '17 at 22:02
  • For example, I get Lahm, 1, 2n so it has omitted 1n because there's a 1 already, but included a 2n because there's no 2 otherwise. Isn't that what you'd expect? – cfr Apr 8 '17 at 22:04
4

I get the following from when I compile your MWE:

split index with omitted entries

This seems to be what I'd expect. For example, Laum is indexed multiple times on page 1, but only the occurrence without attributes is included, whereas it is only indexed once on page 2, so that occurrence is included, with its attribute.

Adapting the command line from Nicola's answer, you would use

splitindex -m "xindy -M test -M texindy -C utf8 -L english" test

if test.tex is the name of your file. Adapt the options you pass xindy for German or whatever you need as you do when not using the split index.

  • I can't check until tomorrow but it's very likely that my mistake was in not adapting the splitindex command to xindy. – Martin Mueller Apr 9 '17 at 4:53
  • Yes, it definitely was my mistake of using the splitindex-command without any options, i.e. with makeindex. – Martin Mueller Apr 10 '17 at 7:12
  • @MartinMueller Glad you solved it. I would have thought you'd get errors in that case, rather than just wrong output. – cfr Apr 10 '17 at 17:05

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.