2

I'm working on a document that contains many older Danish names and places, from when Å was still the Aa-digraph. I want these entries to sort correctly, ie. in the order A..Z Æ Ø Aa/Å.

Looking in the imakeidx documentation I haven't found anything, neither in the search here. If some other package solves it, that is fine.

I am aware that I could use something like \index{Åge@Aage} to sort Aage as if it was spelled Åge, but the full document I'm working on creates the index entries based on other variables fairly deeply in the code, and I don't see a good simple way of detecting and changing the entries on the fly. I would like to just sort the entries as described with the least amount of fuss.

Note also that Ø is sorted after Å for some reason, this is incorrect in Danish.

MWE:

\documentclass{article}

\usepackage[danish]{babel}

\usepackage{imakeidx}
%\indexsetup{noclearpage}
\makeindex

\newcommand\indexed[1]{#1\index{#1}}

\begin{document}

The entries should come in this order:

\indexed{Abel}
\indexed{Anders}

\indexed{Hans}
\indexed{Haagen}

\indexed{Karen}
\indexed{Karsten}
\indexed{Kaare}

\indexed{Lærke}

\indexed{Øjvind}

\indexed{Aage}
\indexed{Åse}

\printindex

\end{document}

enter image description here

3
  • You can use xindy that can sort out based on a sorting alphabet. Quick hack, \index{z1@Øjvind} \index{z2@Åse}. You will also do this for æ. Since danish has only 3 problematic macro you can write custom macros for the 3.
    – yannisl
    Commented Feb 21 at 15:44
  • upmendex also can do sorting as per custom sorting orders. I havent really used it though.
    – yannisl
    Commented Feb 21 at 16:05
  • As mentioned, the \index entries in my full document are assembled from variables, I don't write them by hand directly in the document.
    – meide
    Commented Feb 21 at 16:26

1 Answer 1

2

You need to call indexing processor with support for Danish, which can be either Xindy or Xindex. It seems that imakeidx supports only xindy. You can use it with the following code:

\documentclass{article}

\usepackage[danish]{babel}

\usepackage[]{imakeidx}
%\indexsetup{noclearpage}
\makeindex[program=truexindy,options={-M texindy -C utf8 -L danish}]

\newcommand\indexed[1]{#1\index{#1}}

\begin{document}

The entries should come in this order:

\indexed{Abel}
\indexed{Anders}

\indexed{Hans}
\indexed{Haagen}

\indexed{Karen}
\indexed{Karsten}
\indexed{Kaare}

\indexed{Lærke}

\indexed{Øjvind}

\indexed{Aage}
\indexed{Åse}

\printindex

\end{document}

Compile using:

$ lualatex --shell-escape test.tex

This is the resulting index:

enter image description here

You must log in to answer this question.

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