13

I'm using \printindex for my index and I wonder how to have

  1. bold page numbers
  2. ordering by first character of the indexed word and have dots in between the name and page number like

A
Apple .... 1
Always ... 5

B
Bottle ... 2
Beauty ... 7

1 Answer 1

20

I'm assuming that your index was generated with the help of the makeindex program. This program is automatically called when you compile a LaTeX document with makefiles like latexmk and may also be called by editors like TeXworks or TeXnicCenter. The output generated by makeindex can be configured by using an .ist style file. Details about creating such a file can be found e.g. in section 11.2 of the LaTeX Companion. The following example file would create bold headings for each index letter group and add dots between index keywords and page numbers.

headings_flag 1
heading_prefix "{\\bfseries "
heading_suffix "}\\nopagebreak\n"
delim_0 " \\dotfill "
delim_1 " \\dotfill "
delim_2 " \\dotfill "

To use the file, save it as mystyle.ist and call makeindex with the parameter

-s mystyle.ist

when compiling your LaTeX document. How to exactly add this parameter depends on your compilation method. As a quick workaround: If your main document is called <name>.tex, save the above file as <name>.mst (note the different file type!), copy it to your working directory and compile <name>.tex as usual.

Note that there is a package called idxlayout (disclosure: I'm the package author). This package acts as a complement to .ist files for configuring index layout parameters, e. g. allowing for three-column indexes or for "parent" items and their affiliated subitems being typeset as a single paragraph.

4
  • 1
    Awesome! Thanks! As I use TexnicCenter, I could define the option "-s stylefile.ist" for my compilation-profile easily! Works great!!
    – tim
    May 3, 2011 at 9:51
  • 2
    Could you please explain me how to make the font of the main-items bold? Tried it with item_0 "\n \\bf{\\item}" but this makes also the dots, the page number and the subitems bold...
    – tim
    May 3, 2011 at 10:05
  • 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, 2016 at 14:20
  • I have a similar problem, but I have to use imakeidx as there are two indices in the book I am typesetting. As I don't have to explcitly call makeindex, I am not sure how I can include the style file. I tried adding it as an option alongwith \usepackage{makeindex} in the preamble, but that doesn't seem to work. Knowing tex, I am sure there will be a way this can be done, but I don't know that. Thanks in advance for any help in the matter.
    – Sasi
    Sep 22, 2020 at 7:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .