[Tex/LaTex] How to use xindy with XeTeX/LuaTeX

indexingluatexunicodexetexxindy

According to Xindy revisited: Multi-lingual index creation for the UTF-8 age (TUGboat), “if one has a raw index file that was produced by [XeTeX], one can use xindy; it will ‘just work’.”

Unfortunately I can't get it to “just work”. How can I use Xindy together with XeLaTeX or LuaLaTeX?


An example LaTeX file:

\documentclass{article}
\makeindex

\begin{document}
start
\index{a}\index{b}\index{ä}\index{ü}
end
\end{document}

The LaTeX Companion (2ed) then tells me to run

texindy -L german-duden test.idx

However when I do this all umlauts are sorted under O.

Best Answer

Based on Ulrike's answer, here is one way to invoke xindy to get it to sort .idx files created by Xe/LuaLaTeX. The trick is to use xindy directly (instead of texindy) and pass the -C utf8 flag.

Minimal Example

\documentclass{article}
\usepackage{luatextra}
\usepackage{makeidx}
\makeindex
\begin{document}
üäö

start 
\index{a}\index{b}\index{ä}\index{ü}
end

\printindex
\end{document}

Compilation

lualatex filename.tex
xindy -M texindy -C utf8 -L german-duden filename.idx 
lualatex filename.tex

In (pdf)latex you can use UTF-8 encoding and xindy in the following way:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{makeidx}
\makeindex

\begin{document}
start
\index{a}\index{b}\index{ä}\index{ü}
end
\printindex
\end{document}

And then simply run texindy -L ⟨language⟩ ⟨filename⟩.idx.

In LuaTeX you can also use the luainputenc package to use legacy encodings.

\documentclass{article}
\usepackage{fontspec}
\usepackage[utf8]{luainputenc}
\usepackage{makeidx}
\makeindex

\begin{document}
start 
\index{a}\index{b}\index{ä}\index{ü}
end
\printindex
\end{document}

Again, run texindy -L ⟨language⟩ ⟨filename⟩.idx.

Here the result for both examples:

result