tags:

views:

339

answers:

1

I've got a list of listings at the end of my document following my list of tables and my list of figures. The thing that is really annoying me is that they look the same except the list of listings doesn't leave a line gap between chapters.

I've had a good google around and people have asked the same question but don't seem to have had any response.

Is their any reason why they don't look the same and it be made to look concise?

+2  A: 

The reason for this is that the vertical spacing between chapters in the list of figures (lof) and list of tables (lot) is added by the \chapter command, and there simply is no such provision for the list of listings (lol).

How to fix this depends a bit on the document class you are using. If you are using the excellent memoir class, hooks for this purpose are already provided:

\renewcommand{\memchapinfo}[4]{%
  \addtocontents{lol}{\protect\addvspace{10pt}}}

If your listings are appearing in the appendices, you'll hook \memappchapinfo instead of \memchapinfo. (Consult section 18.25 of the memoir manual for a list of hooks available.)

If you're not using memoir, you'll typically need to hook your class' \@chapter command. This could look like, for example:

\makeatletter
\let\my@chapter\@chapter
\renewcommand*{\@chapter}{%
  \addtocontents{lol}{\protect\addvspace{10pt}}%
  \my@chapter}
\makeatother

You can easily check what is used for generating the lol by checking the .lol file corresponding to your document. If your document is, for example, base.tex, look into base.lol. You should see something like:

\contentsline {lstlisting}{...}{...}
\contentsline {lstlisting}{...}{...}
\addvspace {10pt}
\contentsline {lstlisting}{...}{...}

Note the \addvspace separating the content lines from different chapters.

As the actual code used to insert spacing between chapters also depends on the document class, adapt the actual \addvspace command to be the same as in your .lof or .lot files.

earl
I'm not using the memoir class, I'm using report. Your suggestion for classes other than memoir worked like a charm. Thank you!
Aetius