When generating an index with French words, I need to add a prefix to accentuated words so they they get listed in alphabetical order:
\index{saintete@sainteté}
\index{ame@âme}
Is there a way to have this done automatically?
With Xindy instead of MakeIndex the sorting seems to be correct.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[texindy]{imakeidx}
\makeindex[options=-L french]
\begin{document}
ame\index{ame}
âme\index{âme}
année\index{année}
cote\index{cote}
côte\index{côte}
coté\index{coté}
côté\index{côté}
\printindex
\end{document}
Recall that imakeidx
with Xindy requires -shell-escape
(or running texindy
manually).
texindy
option to the package, but use \makeindex[program=texindy,options=-L french,...]
for defining the index which you want to use Xindy for.
Sticking with makeindex
and pdftex
you can do something like this
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{makeidx}
\makeindex
\let\oldindex\index
\makeatletter
\def\index#1{%
{\let\IeC\@firstofone \let\^\@empty
\let\'\@empty
\let\`\@empty
\let\'\@empty
\let\@tabacckludge\@gobble
\protected@xdef\tmp{#1\unexpanded{@#1}}}%
\oldindex{\tmp}}
\makeatother
\begin{document}
ame\index{ame}
âme\index{âme}
année\index{année}
cote\index{cote}
côte\index{côte}
coté\index{coté}
côté\index{côté}
\printindex
\end{document}
which produces an idx file
\indexentry{ame@ame}{1}
\indexentry{ame@\IeC {\^a}me}{1}
\indexentry{annee@ann\IeC {\'e}e}{1}
\indexentry{cote@cote}{1}
\indexentry{cote@c\IeC {\^o}te}{1}
\indexentry{cote@cot\IeC {\'e}}{1}
\indexentry{cote@c\IeC {\^o}t\IeC {\'e}}{1}
and output
\newcommand\saintete{sainteté\index{saintete@sainteté}}
..?\newcommand{\saintete}[1][]{sainteté\index{saintete@sainteté!#1}}
and then have in your text, main and sub-entries like\saintete
and\saintete[typologie de]
very easily.