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.

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?

Thanks in advance!

(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!)

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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:

enter image description here enter image description here enter image description here

share|improve this answer
    
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
1  
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
    
Aha! That error was because xindy needed a sort-key defined for any glossary entry whose name was itself a macro. When I gave those glossary entries a sort key, it compiled and worked great with lualatex, bibtex and makeglossaries. Thanks again for your help! –  jvriesem Nov 19 '13 at 7:16

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.