# Makeindex number sorting

I would like to change the standard number sorting of makeindex.

Standard sorting output:
1.1, 1
1.2, 1
10.4, 1
12.2, 1
2.2, 1
3.3, 1
4.4, 1

Requested sorting output:
1.1, 1
1.2, 1
2.2, 1
3.3, 1
4.4, 1
10.4, 1
12.2, 1

Here is a mini example of the standard sorting which produces the above mentioned standard sorting output.

\documentclass{scrartcl}
\usepackage{makeidx}
\makeindex
\begin{document}
Refering to OM A 1.1\index{OM A!1.1}.\\
Refering to OM A 1.2\index{OM A!1.2}.\\
Refering to OM A 2.2\index{OM A!2.2}.\\
Refering to OM A 10.4\index{OM A!10.4}.\\
Refering to OM A 3.3\index{OM A!3.3}.\\
Refering to OM A 4.4\index{OM A!4.4}.\\
Refering to OM A 12.2\index{OM A!12.2}.\\
\printindex
\end{document}


Any help is highly appreciated.

Using makeindex, you may add a sorting key inside your \index macros. Just add as many leading zeros as needed to fill up to the width of the largest number:

\documentclass{scrartcl}
\usepackage{makeidx}
\makeindex
\begin{document}
Refering to OM A 1.1\index{OM A!01.01@1.1}.\\
Refering to OM A 1.2\index{OM A!01.02@1.2}.\\
Refering to OM A 2.2\index{OM A!02.02@2.2}.\\
Refering to OM A 10.4\index{OM A!10.04@10.4}.\\
Refering to OM A 3.3\index{OM A!03.03@3.3}.\\
Refering to OM A 4.4\index{OM A!04.04@4.4}.\\
Refering to OM A 12.2\index{OM A!12.02@12.2}.\\
\printindex
\end{document}


• That is pretty cool, thanks a lot. I will use that solution. To sum up, the sorting key is between !...@, and after the @ is the displayed number on the index. – Speedwing Oct 10 '14 at 6:18
• @Speedwing Yes, exactly :-) – Thomas F. Sturm Oct 10 '14 at 6:58

Although the question was about makeindex, I'll show a solution with xindy and using imakeidx for automatic numerical sorting of the index.

One - column index is achieved by columns=-1, the letter group heading can be switched off by dumping \lettergroup to do do nothing after \theindex started.

\documentclass{scrartcl}
\usepackage{etoolbox}%
\usepackage[xindy]{imakeidx}
\apptocmd{\theindex}{\newcommand{\lettergroup}[1]{}}{}{}%
\makeindex[options={-M numeric-sort.xdy},columns=1]
\begin{document}
Refering to OM A 1.1\index{OM A!1.1}.\\
Refering to OM A 1.2\index{OM A!1.2}.\\
Refering to OM A 2.2\index{OM A!2.2}.\\R
Refering to OM A 10.4\index{OM A!10.4}.\\
Refering to OM A 3.3\index{OM A!3.3}.\\
Refering to OM A 4.4\index{OM A!4.4}.\\
Refering to OM A 12.2\index{OM A!12.2}.\\
\printindex
\end{document}


• May thanks, that is a good alternative. What bothers me is that it has 2 columns and the 'O' is displayed on top of 'OM A'. – Speedwing Oct 10 '14 at 6:10
• @Speedwing: The number of columns can be specified as an option to \makeindex: [columns=1] – user31729 Oct 10 '14 at 6:54
• Ok, thanks for the hint. What about to hide the 'O' in top of 'OM A'? – Speedwing Oct 10 '14 at 7:12
• By the way, I just found out, that on my system (TEX Maker 4.2, LatexMk compiler -> TexLive 2013, Windows 7) it does not work to get the correct number sorting as in the picture above. Furthermore it does not show the 'O' in top of 'OM A', when I compile your example... How come? – Speedwing Oct 10 '14 at 7:25
• @Speedwing: I neither use texmaker,latexmk,tl2013 and windows 7, so there is nothing I can say about why there is a wrong sorting and the 'missing' letter group opener 'O', I am sorry – user31729 Oct 10 '14 at 7:38