# How to set the space between two index entries with the same character

When I make an index, I get only between the different characters (b,s,t) an optimal vertical spacing.

\usepackage{makeidx}\makeindex
\index{book}
\index{summer!sun}
\index{summer!heat}
\index{sound}
\index{tower}


Because I've only a few index entries, the vertical spacing between summer and sound (starting with the same character) should be the same as for different letters like (book and summer or sound and tower: one blank line of 1em).

I've tried to find for a solution in the internet and in the package documentation but was not successful.

Is this somehow possible with makeidx?

You can redefine \@idxitem to have a vertical space preceding it, while \indexspace does nothing. Also \subitem needs to be redefined, otherwise it would add the vertical space as well.

For separating the first entry from the heading, a \vspace{12pt} instruction is added to \theindex, modify it to suit.

% arara: pdflatex
% arara: makeindex
% arara: pdflatex

\documentclass{article}
\usepackage{etoolbox}
\usepackage{makeidx}\makeindex

\makeatletter
\def\@idxitem{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}\hangindent 40\p@}
\def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
\def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}
\def\indexspace{}
\patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{}
\makeatother

\begin{document}
x
\index{book}
\index{summer!sun}
\index{summer!heat}
\index{summer!heat!sweat}
\index{sound}
\index{tower}

\count255=0
\loop\ifnum\count255<40
\expandafter\index\expandafter{\romannumeral\count255}
\repeat

\printindex
\end{document}


The arara directives are what I used to ease compilation; the \loop just fills in some more index entries so we arrive at the second column.

If I change the code above into

\makeatletter
\def\@idxitem{\par\addvspace{5\p@ \@plus 2.5\p@ \@minus 1.5\p@}\hangindent 40\p@}
\def\subitem{\par\hangindent 40\p@ \hspace*{20\p@}}
\def\subsubitem{\par\hangindent 40\p@ \hspace*{30\p@}}

• Thank you, that's very cool. However I have a list with several indixes and therefore a two column index. The problem is that the secon column begins at higher position than the first column. With playing with vspace I was able to \appto\theindex{\vspace*{-2.22em}} adjust both beginnings of the two columns but they don't begin exactly at the same hight. Is this somehow possible to do this automatically? Apr 4 '15 at 18:59
• Thank you. Please consider to add \def\subsubitem{\par\hangindent 70\p@ \hspace*{40\p@}} because I need a subsubentry. Thank you! Apr 4 '15 at 23:26
• I tried another texteditor. There I get a notification: command is not recognized. Will \addvspace and \theindex also be recognized with other documentclasses like \documentclass[twoside,ngerman,fontsize=10pt]{scrreprt} or do I need to add something? Apr 5 '15 at 19:38