2

I am using imakeidx to create my indices. It works great except for the fact that it does not create normal orders with numbers.

Instead of:

1

3

10

30

it creates:

1

10

3

30

Is there a way to change this?

Here is my MWE:

\documentclass[a4paper,11pt]{scrbook}
\usepackage[utf8]{inputenc}%
\usepackage[T1]{fontenc}%
\usepackage[ngerman]{babel}
\usepackage{blindtext}
\usepackage{imakeidx}% MULTIPLE INDICES
\indexsetup{level=\section*,toclevel=section,headers={Stellenregister}{\indexname}}%
\makeindex[name=band1-bibelstellen,title=Bibelstellen, intoc, options=-c -s untitled.ist]
\makeindex[name=band1-themen,title=Themen, intoc, options=-c -s untitled.ist]
\makeindex[name=band1-personen,title=Personen, intoc, options=-c -s untitled.ist]
\begin{document}
\blindtext\index[band1-themen]{Augustine!Sermones!1, 12}
\blindtext\index[band1-themen]{Augustine!Sermones!3, 34}
\blindtext\index[band1-themen]{Augustine!Sermones!10, 1}
\blindtext\index[band1-themen]{Augustine!Sermones!30, 2}
\addcontentsline{toc}{chapter}{Stellenregister}
\printindex[band1-bibelstellen]
\printindex[band1-themen]
\printindex[band1-personen]
\end{document}

My untitled.ist looks like this at the moment:

delim_0 ":\\quad "
delim_1 ":\\quad "
delim_2 ":\\quad "

1 Answer 1

5

Makeindex sorts the entries as text and not as numbers. The entry 1, 12 starts with a digit, but it is not a number.

The symbol @ can be used to add a sort key to get the desired sort order:

\blindtext\index[band1-themen]{Augustine!Sermones!01, 12@1, 12}
\blindtext\index[band1-themen]{Augustine!Sermones!03, 34@3, 34}
\blindtext\index[band1-themen]{Augustine!Sermones!10, 1}
\blindtext\index[band1-themen]{Augustine!Sermones!30, 2}

The sort keys are now:

01, 12
03, 34
10, 1
30, 2

And the result is:

1, 12
3, 34
10, 1
30, 2
2
  • Yes I am aware of this but unfortunately I have over thousand entries, and they are rather complicated. It would take a month to change all entries to what you suggested. There must be an automatic way to do this!
    – stx932
    Nov 24, 2017 at 19:16
  • 1
    @eklisiarh The question only contains less than 4 ‰ of the over thousand entries. That does not allow to derive any rules for an automatic way. Develop such rules. Then, for example, you can write a script/program in the programming language of your choice to post-process either the .tex files (if the markup is clear) or the .idx files to add or update the sort keys for the index entries. Nov 24, 2017 at 19:34

You must log in to answer this question.

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