# How to move from makeindex to xindy?

Is there an easy, lightweight way to manage multiple glossaries and indices using xindy rather than makeindex? Everything works currently using makeindex, but it's not as nice as it could be. I'm fine with how things look for now, but I'd like to start using the preferred tool as soon as possible. Evidently xindy is the way to go.

I understand a possible workaround is to use makeindex4, which is a wrapper to xindy that tries to behave like makeindex, but I'd like to avoid using yet another program, and makeindex4 doesn't come with TexLIVE 2012.

If anyone could point me to a xindy style file that is similar to the glossaries style 'altlist', I could probably modify it from there.

Thoughts?

(Other info: I use TexShop 2.47 for Mac.) (Also, I LOVE this site and have found many forums very helpful. Unfortunately, I can't vote anything up because I lack reputation. I wish voting for answers would help build reputation!)

It is not clear to me what kind of issues you are experiencing, so I will give you complete example on how to use modern LaTeX engine (lualatex or xelatex) with xindy. With pdflatex, there might be some problems with accented characters, see this answer for some details.

So in our example, we have utf8 file with some Czech language index and glossary entries:

\documentclass{article}
\usepackage[]{fontspec}
\usepackage[czech]{babel}
\usepackage[xindy={language=czech, codepage=utf8}, style=altlist]{glossaries}
\usepackage[xindy, splitindex]{imakeidx}
\usepackage[itemlayout=singlepar]{idxlayout}
\setmainfont{TeX Gyre Termes}
\makeglossaries
\def\xindylangopt{-M lang/czech/utf8-lang}
\makeindex[options=\xindylangopt]
\makeindex[name=nameindex,title = Index of names,  options=\xindylangopt]
\newglossaryentry{first}{name = ddd, description = {První položka}}
\newglossaryentry{second}{name = čokoláda, description = {Druhá položka}}
\newglossaryentry{third}{name = cosi, description = {Třetí položka}}
\begin{document}
Hello worls, \gls{first}, \gls{second} and \gls{third}
\index[nameindex]{Čapek, Karel}
\index[nameindex]{Hašek, Jaroslav}
\index[nameindex]{Cílek, Václav}
\index[nameindex]{Deml, Jakub}
\index[nameindex]{Chalupa, Václav}
\index{Hello|see{Entry}}
\index{Entry!Subentry}
\index{Entry!Another subentry}
\index{What|textbf}
\printglossary
\printindex[nameindex]
\printindex
\end{document}


Some important points:

\usepackage[xindy={language=czech, codepage=utf8}, style=altlist]{glossaries}


glossaries package have built in xindy support, we only have to set xindy option and pass correct arguments for language and codepage. makeglossaries script will take care of correct xindy call for us.

\usepackage[xindy, splitindex]{imakeidx}
...
\def\xindylangopt{-M lang/czech/utf8-lang}
\makeindex[options=\xindylangopt]
\makeindex[name=nameindex,title = Index of names,  options=\xindylangopt]


for index creation, we use imakeidx package. There we create two indexes, one general and other for names. xindy option will call xindy automatically on LaTeX run

\xindylangopt macro defines xindy options for language processing, -M lang/czech/utf8-lang will use xindy module for the Czech language in utf8 encoding.

two uses of \makeindex will create two indexes, there are many options which can be used for formatting of these indexes, see imakeidx manual.

For example of another mean of controlling index appearance, I used also

\usepackage[itemlayout=singlepar]{idxlayout}


which will result in index in run-in style. I don't like it much, I just wanted to show you what can be done :). idxlayout package really isn't necessary, but maybe you will find it useful.

Now how to compile the example:

lualatex sample.tex
makeglossaries sample
lualatex -shell-escape sample.tex


first lualatex run will write glossary and index entries, makeglossaries script will compile the glossary, second lualatex run is with -shell-escape option, so indexes are creaed by imakeidx automatically.

The result:

• I'm working through this in applying it to my problem. It looks good -- thanks! I'm having a little trouble getting stuff to compile perfectly on my bigger example. Should this work using LaTeX rather than LuaTeX? – jvriesem Nov 17 '13 at 6:29
• this should work for lualatex or xelatex, for pdflatex, you will need to preprocess the .idx file with script provided in this answer: tex.stackexchange.com/questions/131334/… – michal.h21 Nov 17 '13 at 11:56
• It works great with makeindex, but with xindy it gives ' Processing index... ERROR: CHAR: index 0 should be less than the length of the string' Does that look familiar? – jvriesem Nov 19 '13 at 7:08
• what if you want to use two languages simultaneously? – skan Mar 3 '16 at 16:51
• @tatojo subentries should be supported, but in my example they are printed on one line, because of singlepar option for idxlayout package. Just don't use this option. – michal.h21 Nov 19 '18 at 16:41