3

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?

1 Answer 1

3

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 \advance\count255 1 \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.

enter image description here

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@}} \renewcommand\indexspace{\par\addvspace{10\p@ \@plus 5\p@ \@minus 3\p@}} \patchcmd\theindex{\indexname}{\indexname\vspace{12pt}}{}{} \makeatother 

then the space between different letters will be double of the space between entries starting with the same letter.

enter image description here

11
  • 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? Commented Apr 4, 2015 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! Commented Apr 4, 2015 at 23:26
  • 1
    @laminin Look at the fix Commented Apr 5, 2015 at 9:27
  • 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? Commented Apr 5, 2015 at 19:38
  • 1
    @laminin I can do nothing if the editor doesn't recognize commands. This is completely irrelevant. Commented Apr 5, 2015 at 20:01

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.