Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
3  
Not with MakeIndex that's irremediably old-fashioned and deals only with Latin unaccented characters. With Xindy it should be possible. –  egreg Jun 10 '13 at 21:11
    
\newcommand\saintete{sainteté\index{saintete@sainteté}}..? –  jon Jun 10 '13 at 21:12
    
@jon: I'd have to do that for hundreds of keywords then. –  ℝaphink Jun 10 '13 at 21:15
    
I figured; but this is another reason why technical/special terminology should always be encoded in macros (easy to say that at the wrong time, I know). The advantage, however, is that you can do things like: \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. –  jon Jun 10 '13 at 21:27
    
Well I don't really do my indexes this way actually (not for this book at least). Quite a few words I use as index do not actually occur in the text. –  ℝaphink Jun 10 '13 at 21:35

2 Answers 2

up vote 7 down vote accepted

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).

enter image description here

share|improve this answer
    
What are your exact command lines for compiling this example with Xindy? Thanks –  pluton Jun 10 '13 at 22:52
    
@pluton Just pdflatex -shell-escape <filename> –  egreg Jun 10 '13 at 22:54
    
That is strange. I've been trying that several times and it does not work. On windows, I got a "'texindy' is not recognized as an internal or external command, operable program or batch file" error message. I have to investigate. –  pluton Jun 10 '13 at 23:02
    
@pluton: I'm guessing you need to install xindy. –  ℝaphink Jun 11 '13 at 5:31
1  
@ℝaphink Don't give the texindy option to the package, but use \makeindex[program=texindy,options=-L french,...] for defining the index which you want to use Xindy for. –  egreg Jun 11 '13 at 8:30

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

enter image description here

share|improve this answer
    
That looks like a very interesting alternative. –  ℝaphink Jun 11 '13 at 5:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.