[Tex/LaTex] Styling very long index entries to look more aesthetic

formattingindexing

I wrote the following style for makeindex:

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

which works pretty good. It happens that I have some very long index entries, and their display is not what I expected. This is a MWE:

\documentclass{article}

\usepackage{makeidx}

\makeindex

\begin{document}
Hello.\index{Hello}
Hello again.\index{Hello again}
Hi there.\index{Hello there, this is a very long text here}
\printindex
\end{document}

When I run makeindex mwe.idx -s mystyle.ist, this is the output:

Index 1

To be honest, I was expecting something like this:

Index 2

I tried to find some help on styles in The LaTeX Companion book, but I could not assimilate much. I'm relying on the belief that I could solve this by using a proper ist file.

Any ideas?

Best Answer

Your belief is correct -- use the style file gind.ist.

EDIT: Or try to change your custom file mystyle.ist as follows:

headings_flag 1
heading_prefix "{\\bfseries "
heading_suffix "}\\nopagebreak\n"
item_x1   "\\efill \n \\subitem "
item_x2   "\\efill \n \\subsubitem "
delim_0   "\\pfill "
delim_1   "\\pfill "
delim_2   "\\pfill "
Related Question