# How to add custom letter groups to an index, e.g. for greek letters or brackets?

I have an index of symbols made using makeindex:

\documentclass{article}

\usepackage{makeidx}
\makeindex

\begin{document}
Text

\index{sin@$\sin$}    % just some examples of index entries
\index{cos@$\cos$}
\index{tan@$\tan$}

\index{greek.a@$\alpha$}    % symbols with greek letters
\index{greek.b@$\beta_{x,y}$}

\index{(@$(a)_n$}    % an entry with a bracket

\printindex

\end{document}


I would like to have a letter group (subdivision) of the index for each Greek letter. (I understand I would have to specify another key and greek.a isn't going to work.) But not just for Greek letters. I also want to organize the entries under the symbols heading, for example gather those that involve round brackets ().

Question: How can I add custom letter groups to an index? (It doesn't need to be with makeindex.)

• It appears this can be done with xindy, although I'm not sure... May 27 '18 at 20:12
• May 27 '18 at 20:18
• Don't you need \makeindex? Otherwise, I get no index at all.
– cfr
May 28 '18 at 2:35
• @cfr yes; of course. May 28 '18 at 5:16

This answer is for MikTeX, I don't know about TeXLive. It can be done with xindy. My .xdy file begins:

(define-letter-group "$\alpha$" :after "default" :before "A" :prefixes ("\235\313\227\227\256\200\264\310\244\200"))
(define-letter-group "$\beta$" :after "$\alpha$" :before "A" :prefixes ("\235\313\227\227\256\204\227\332\200"))


where those numbers are octal codes for "greekalpha" resp. "greekbeta" (you can choose any string you think makes sense) which I entered in Emacs not as strings but as single bites, using M-x hexl-mode C-M-o 235 etc. You can't copy them from another file, but you can copy (or find and replace) them in normal mode within the same file. The numbers themselves I got from ...\xindy\modules\lang\english\utf8.xdy. If you're having problems, this answer may help.

I then wrapped everything by defining \newcommand\greekindex[1]{\index{greek#1}} so that I can use

\greekindex{alpha@$\alpha$}
\greekindex{beta@$\beta_{x,y}$}


Note that I compile with

xindy -C utf8 -L english -M texindy -M mystylefile myfile.idx


I also used package bm and as headings I wrote \bm\alpha etc: Just change $\alpha$ in the .xdy file to $\bm\alpha$.