12

How does one go about setting an arbitrary sorting order in an index? For example, I would like to create an index of citations to Roman and canon law, which should not be sorted alphabetically. (All the citations in the text are already written by macros, so it seems like getting them into an index is trivial enough.)

A long example of what I mean, which I hope shows the complexity of how things need to be sorted:

Index of Roman law citations: [= heading division]

Institutiones: [= heading subdivision]

Inst. 1.2 pr. [pr. = prologue]

Inst. 1.2.2

Inst. 3.17 pr.

Digestum: [= heading subdivision]

Dig. 1.1.1.3

Dig. 1.10.1.2

Dig. 27.1.2

Dig. 50.16.289

Codex: [= heading subdivision]

Cod. 1.1.1

Cod. 4.2

Canon law is different again:

Decretum Gratiani: [= heading division]

Prima pars: [= heading subdivision]

D. 1 c. 1

D. 6 c. 3

D. 6 d.p.c. 3 [p. = post = after c. 3]

D. 8 d.a.c 1 [a. = ante = before c. 1]

D. 8 c. 1

Secunda pars: [= heading subdivision]

C. 1 q. 1 c. 10

C. 1 q. 3 c. 7

C. 1 q. 3 c. 15

C. 23 q. 4 c. 5

C. 33 q. 3 (De penitentia) [= subsection in Causa 33, quaestio 3]

D. 5 c. 8

D. 6 c. 1

Tertia pars (De consecratione): [= heading subdivision]

D. 2 c. 2

D. 4 c. 1

  • I guess theoretically this should be possible with xindy. But I have no idea how. – Caramdir Sep 23 '11 at 19:15
4

The bibleref package has a feature that does that for Bible books (which are sorted by Bible order usually). There's two suggested ways.

The native way inserts numbers before the entry, so the index looks like:

\indexentry{01\relax @\BRbooktitlestyle {\BRbookof Gen\`ese}!001:026@\BRchapterstyle {1}\BRchvsep \BRversestyle {26}|textrm}{12}

Where 01 is the order for the book of Genesis.

The other way involves using xindy with a custom dictionary. See the xindy manual for that.

  • Ah, thanks for the suggestions. I had not known about bibleref; it is certainly worth a look. I knew about xindy, but I was hoping someone had already had to do something similar to this. – jon Sep 26 '11 at 15:22
1

I have built arbitrary sorting rules earlier but unfortunately they stopped working with the update to xindy 2.5.1. It has never been confirmed whether this is a bug in 2.5.1 or a conscious decision to go away from this behaviour.

If you happen to have a xindy 2.5.0 somewhere (e.g. in texlive 14) or a able to aquire it, you could try my approach.

Running xindy 2.5.0 with xindy -o index.ind -C utf8 -M test.xdy -M m.idx on an m.idx looking like:

\indexentry{Ant}{2}
\indexentry{Bison}{2}
\indexentry{Camel}{2}
\indexentry{Unicorn}{2}
\indexentry{Ðuck}{2}

will give you

default

Unicorn, 2

Start with C though

Camel, 2

Letter A

Ant, 2

Letter B

Bison, 2

Test Unicode ð

Ðuck, 2

test.xdy:

(require "latex.xdy")
(require "makeindex.xdy")
(require "numeric-sort.xdy");; "V64" appears before "V128".
(require "latex-loc-fmts.xdy")


(require "ff-ranges.xdy")
;;(require "book-order.xdy")



;; minimal alphabet
(define-alphabet "myminimal"
   ("Start with C though" "Letter A" "Letter B" "Test Unicode ð"))



;; minimal letters
(sort-rule "A" "Letter A")
(sort-rule "B" "Letter B")
(sort-rule "C" "Start with C though")
(sort-rule "Ð" "Test Unicode ð")



(define-location-class "myminimal"
   ("myminimal" :sep " " "arabic-numbers" :sep "," "arabic-numbers"))


(define-letter-groups
 ("Start with C though" "Letter A" "Letter B" "Test Unicode ð"))




(markup-letter-group :open-head "~n {\bf " :close-head "}
"
                    )

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.