Possible Duplicate:
package makeidx: print first letter for each group of keys

I'm trying to adapt the index of my contribution such that each group of words (starting with the same letter) has the starting letter displayed as bold an on top of the group.

Note that I tried to find an answer, but the related questions and answers are rather confusing. I use \documentclass[a4paper,12pt]{book} and \usepackage{makeidx} \makeindex.


We need to create an .iststyle file and tell makeindex to use it. My style file is as follows:

headings_flag 1
heading_prefix "{\\textbf{"
heading_suffix "}}\\nopagebreak\n"

The first line tells makeindex to display a heading for each group (1 stands for true). The last two lines will format the heading the way you want (I used textbf to make the heading bold).

Now, with myheader.ist, we simply call

makeindex -s myheader.ist myfile.idx

Consider this example:

% arara: pdflatex
% arara: makeindex: { style: myheader.ist }
% arara: pdflatex




Some text.\index{Apple}\index{Apricot}\index{Avocado}\index{Banana}
\index{Jackfruit}\index{Jambul}\index{Kiwi fruit}\index{Kumquat}
\index{Pomegranate}\index{Purple Mangosteen}\index{Raisin}\index{Raspberry}
\index{Rambutan}\index{Redcurrant}\index{Salal berry}\index{Satsuma}
\index{Star fruit}\index{Strawberry}\index{Tangerine}\index{Tomato}
\index{Ugli fruit}\index{Watermelon}\index{Ziziphus mauritiana}



Running the following commands:

pdflatex myfile.tex
makeindex -s myheader.ist myfile.idx
pdflatex myfile.tex

We will obtain this output:

My index

Hope it helps. :)

  • 1
    I thought that if you use the makeidx package, it runs makeindex internally for you, so you don't need a separate run. Am I mistaken? – Brent.Longborough Jul 30 '12 at 15:44
  • @Brent.Longborough: The package imakeidx has this functionality. – Marco Daniel Jul 30 '12 at 16:07
  • @Brent: makeidx provides a couple of extra commands to the default indexing mechanism, but that's all. As Marco mentioned, imakeidx has this feature. :) – Paulo Cereda Jul 30 '12 at 16:18
  • This works also with sections, i.e. heading_prefix "{\\section*{", in order to have consistent formatting with bibliographies grouped by initial letters, like here: tex.stackexchange.com/questions/150068/… – Martin Jan 7 '16 at 14:18
  • I'm using overleaf online, How can I adapt it to the remote version ? – Emna Ayadi Nov 29 '20 at 0:50

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