Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using the listings package. I want to print out a list of listings, which I can do. The thing is that in the other listings the typesetter "groups" figures/tables by chapter. Is it possible to achieve a similar behaviour with the list of listings?

Here is an example

Example of how I want it

Here is how it is now

How it is

share|improve this question

2 Answers 2

up vote 8 down vote accepted

Write into the preamble:

\let\Chapter\chapter
\def\chapter{\addtocontents{lol}{\protect\addvspace{10pt}}\Chapter}
share|improve this answer
    
This solution seems better as it works automatically for every chapter. I need to learn how to make those kinds of macros, where should I start? –  Tiago Veloso Feb 3 '11 at 10:58
    
Difficult to say, because there are tons of manuals ... For TeX related stuff: http://tex.stackexchange.com/questions/7695/ and for LaTeX see http://mirror.ctan.org/info/ –  Herbert Feb 3 '11 at 11:05

Add the following to your preamble (adjusted for the book and report class):

\usepackage{etoolbox}

\makeatletter
\patchcmd{\@chapter}{%
  \chaptermark{#1}%
}{
  \chaptermark{#1}%
  \addtocontents{lol}{\protect\addvspace{10pt}}%
}{}{}
\makeatother

EDIT: The "chapter gap" mechanism of the KOMA-Script classes works for any "listofsomething".

share|improve this answer
    
Your hack worked. Unfortunately the listings package only provides a \lstlistoflistings which does not match the \listofsomething rule. Is there a better package for listings? –  Tiago Veloso Feb 3 '11 at 10:43
    
@Tiago: I shouldn't have use code tags for "listofsomething". The KOMA-Script classes control the layout of \lstlistoflistings. –  lockstep Feb 3 '11 at 10:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.