This question is similar to others, but I could not find an answer that actually works for me.

This is my document:

\usepackage{xcolor, colortbl}
\rightskip{0pt plus 1fil}
\fancyhead{} % clear all fields
\fancyhead[RO,LE]{\footnotesize Studi sulla tradizione indiretta di Erodoto}
\fancyfoot{} % clear all fields

\makeindex[name=n, title=Nomi di persone e luoghi] 
\makeindex[name=p, title=Passi citati nel testo]
\makeindex[name=t, title=Altri testi citati]
\makeindex[name=pap, title=Papiri e manoscritti citati nel testo]

I have 600 pages+ of text with index entries marked as follow:


This is because I want the index to sort by book and then by chapter. The result in the index at chapter level however is sorted in the following way:

  • 1-4, 279 (this is a range)
  • 1.9, 74 (after the dot are lines in the chapter of the text quoted)
  • 10-11, 357, 359
  • 105-6, 80, 304
  • 105.3-106.1, 75
  • 105.4-108.2, 75
  • 107-114, 305
  • 2, 24
  • 24, 56
  • 207, 67
  • 3, 78

Please, could you suggest me what I need to do so that things are ordered like:

  • 1-4, 279
  • 1.11.1-4, 74
  • 1.9, 74
  • 2, 24
  • 3, 78
  • 10-11, 357, 359
  • 24, 56
  • ...
  • 1
    the makeindex sort is a simple ascii sort. the only suggestion I can make at the moment is to provide a separate sort field with enough leading zeros to get the desired output order. obnoxious, i know; maybe someone else has a better suggestion. Commented Nov 4, 2013 at 3:04
  • Thank you for this suggestion! I am a complete beginner therefore I have not actually understood what I need to do... sorry... could you please tell me where and how to put this extra sort field? I am also happy to change packages and do some overall modifications but I am a bit worried if I need to change something in the actual index entries which are thousands and I have entered all one by one... Commented Nov 4, 2013 at 14:45
  • Dear all, perhaps I got the point: I have tried with this \index[p]{[email protected]} on some entries and it does work to put them in the correct order! thanks a lot @barbara-beeton! Now, they are thousands as I wrote: any suggestion, please, on how to edit them may be with a macro? \index commands are all already there and I might have sometimes to alter the structure of the sort field to include alphabetic as well. Thank you very much again! Commented Nov 9, 2013 at 7:07

1 Answer 1


You can use xindy instead of makeindex. It applies merging rules and it is already ready for cases like yours. We can even customize it by preparing new location classes and setting their order if we run into an unusual situation. This is a snippet from the samplexdy-mc.xdy file (it is a part of the glossaries package) where this approach was used in a large-scale.

(define-location-class "Roman-page-numbers-roman-page-numbers"
   ( :sep "{" "roman-numbers-uppercase" :sep "}{" "roman-numbers-lowercase" :sep "}" )
   :min-range-length 2

(define-location-class-order (
   "see" ))

I can show you the difference between the result from makeindex (the first column) and the result from xindy (the second column). We only need to eliminate the group letters, that's default option in xindy. It can be done by redefining markup for the letter group.

I enclose an example, how to process the file and a preview of pages 2 and 3.

%! *latex mal-sorting.tex
%\usepackage[noautomatic]{imakeidx} % splitindex
%\makeindex[name=p, title=Passi citati nel testo]
%\makeindex[name=n, title=Nomi di persone e luoghi] 
%\makeindex[name=t, title=Altri testi citati]
%\makeindex[name=pap, title=Papiri e manoscritti citati nel testo]

% \printindex % The index is displaying over here with imakeidx (?)...
;; mal-style.xdy
(markup-letter-group :open-head "~n\mycleaner{" :close-head "}")

First part.



Last part.

\begingroup % Limit changes of \thispagestyle and \mycleaner to this group only.
\def\thispagestyle#1{}% Delete the page numbers for a while...
\def\mycleaner#1{}% Delete the word groups in index from xindy...
\printindex % This file (mal-sorting.ind) was created by makeindex...
%\printindex[n] % This is supported by the imakeidx package...
% This file was created by xindy...
\endgroup % End of the group.

I processed that file by these four commands:

lualatex mal-sorting.tex
makeindex mal-sorting.idx
xindy -M texindy -M mal-style -C utf8 -L general -o mal-sorting-xindy.ind mal-sorting.idx
lualatex mal-sorting.tex

mwe, makeindex and xindy comparison

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .