TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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. 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

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

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.

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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