2

I'm using xindy to typeset an index that I've already created by hand. The idx file looks like this:

\indexentry{Aboriginal!Advising the Accused}{Ch. 46, S. 3.7.8, P. 208A}
\indexentry{Aboriginal!Definition Of}{Ch. 46, S. 2.1, P. 452B}
\indexentry{Aboriginal Rights!Defence}{Ch. 46, S. 3.1.4(a), P. 109AB}

As you can see, the page references follow a pattern of Chapter-section-page-column; e.g. Ch. 46, S. 3.7.7(a), P. 208A.

My xdy file looks like this:

(define-alphabet "chapter" ("Ch."))
(define-alphabet "section" ("S."))
(define-alphabet "page" ("P."))
(define-alphabet "column" ("A" "B" "AB" "ABA"))
(define-location-class "combination-locator" :var
  ("chapter" :sep " " "arabic-numbers" 
    :sep ", "
    "section" :sep " "
        "arabic-numbers" :sep "."
        "arabic-numbers" :sep "."
        "arabic-numbers" :sep "("
        "alpha" :sep ")" :sep ", " 
    "page" :sep " " "arabic-numbers" "column"
    ))

The problem I've been running into is that the format is slightly variable — sections have at most 4 hierarchical levels, including one that's alphabetical, and xindy is having trouble recognizing where one section ends and the other begins:

WARNING: location-reference "Ch. 46, S. 2.1, P. 208A" did not match any location-class! (ignored)

My sense is that part of the problem is using this complex location-class. It seems like it would be easier to create a series of location classes, and then link them together in a meta-location class. However, the documentation doesn't explain how to create a recursive location class.

2

I couldn't find anything in the xindy docs that suggests that you can specify optional elements, so it seems like the easiest thing is just to add these location classes to the end of the xdy you gave above:

(define-location-class "combination-locator-a" :var
  ("chapter" :sep " " "arabic-numbers" 
    :sep ", "
    "section" :sep " "
        "arabic-numbers" :sep "."
        "arabic-numbers" :sep "."
        "arabic-numbers" :sep ", " 
    "page" :sep " " "arabic-numbers" "column"
    ))
(define-location-class "combination-locator-b" :var
  ("chapter" :sep " " "arabic-numbers" 
    :sep ", "
    "section" :sep " "
        "arabic-numbers" :sep "."
        "arabic-numbers" :sep ", " 
    "page" :sep " " "arabic-numbers" "column"
    ))
(define-location-class "combination-locator-c" :var
  ("chapter" :sep " " "arabic-numbers" 
    :sep ", "
    "section" :sep " "
        "arabic-numbers" :sep ", " 
    "page" :sep " " "arabic-numbers" "column"
    ))

When I ran your sample idx file through that, it produced what looks like appropriate output:

  \lettergroup{A}
  \item Aboriginal
    \subitem Advising the Accused, Ch. 46, S. 3.7.8, P. 208A
    \subitem Definition Of, Ch. 46, S. 2.1, P. 452B
  \item Aboriginal Rights
    \subitem Defence, Ch. 46, S. 3.1.4(a), P. 109AB

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.