Text Formatting ⇒ lstlistoflistings toc vertical spacings
lstlistoflistings toc vertical spacings
A need my lstlistoflistings in the table of contents to be grouped by chapters and to use the same vertical spacings that are used in figures and tables listings.
What do I need to do add/modify to get those spacings?
Thank you.
What do I need to do add/modify to get those spacings?
Thank you.
NEW: TikZ book now 40% off at Amazon.com for a short time.

lstlistoflistings toc vertical spacings
I guess that depends on the class you're using.
For report class, you could try sth. like
south of loading listings in your preamble.
KR
Rainer
For report class, you could try sth. like
Code: Select all
\usepackage{etoolbox}
\makeatletter
\patchcmd{\@chapter}{\chaptermark{#1}}{%
\chaptermark{#1}%
\addtocontents{lol}{\protect\addvspace{10\p@}}%
}{\typeout{Chapters patched for list-of-listings.}}{\typeout{Could not patch chapters for list-of-listings.}}
\makeatother
KR
Rainer
lstlistoflistings toc vertical spacings
I forgot to say it's a book. Sorry.rais wrote:I guess that depends on the class you're using.
For report class, you could try sth. likesouth of loading listings in your preamble.Code: Select all
\usepackage{etoolbox} \makeatletter \patchcmd{\@chapter}{\chaptermark{#1}}{% \chaptermark{#1}% \addtocontents{lol}{\protect\addvspace{10\p@}}% }{\typeout{Chapters patched for list-of-listings.}}{\typeout{Could not patch chapters for list-of-listings.}} \makeatother
KR
Rainer
lstlistoflistings toc vertical spacings
if you mean the standard book class, it should work the same way.MakezHD wrote: I forgot to say it's a book.
If you're using another class that typesets books, you'll have to let us know which one.
KR
Rainer
lstlistoflistings toc vertical spacings
Chapters are being grouped fine now but vertical spaces are yet not identical to the ones in the figures and tables listings.rais wrote:I guess that depends on the class you're using.
For report class, you could try sth. likesouth of loading listings in your preamble.Code: Select all
\usepackage{etoolbox} \makeatletter \patchcmd{\@chapter}{\chaptermark{#1}}{% \chaptermark{#1}% \addtocontents{lol}{\protect\addvspace{10\p@}}% }{\typeout{Chapters patched for list-of-listings.}}{\typeout{Could not patch chapters for list-of-listings.}} \makeatother
KR
Rainer

lstlistoflistings toc vertical spacings
In a book, LaTeX tries to keep the last line consistent throughout the pages. To that end, it may add vertical space between paragraphs, list entries, ...
So with different numbers of entries in LOF/LOL, you get different such added space.
If you don't want that, add to your preamble.
If that is not enough (you may now notice different space between headlines and first entries in LOF/LOT), addto above \makeatletter..\makeatother block. This will redefine \lstlistoflistings to behave the same way as \listoffigures does in a book class, hence the vertical space between `Listings' and the first entry in LOL should now be the same as between `List of figures' and the first entry in LOF (if there's the same number of entries LOF/LOL or \raggedbottom is active).
KR
Rainer
So with different numbers of entries in LOF/LOL, you get different such added space.
If you don't want that, add
Code: Select all
\raggedbottom
If that is not enough (you may now notice different space between headlines and first entries in LOF/LOT), add
Code: Select all
\renewcommand\lstlistoflistings{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\lstlistlistingname}%
\@mkboth{\MakeUppercase\lstlistlistingname}%
{\MakeUppercase\lstlistlistingname}%
\@starttoc{lol}%
\if@restonecol\twocolumn\fi
}
KR
Rainer
lstlistoflistings toc vertical spacings
rais wrote:In a book, LaTeX tries to keep the last line consistent throughout the pages. To that end, it may add vertical space between paragraphs, list entries, ...
So with different numbers of entries in LOF/LOL, you get different such added space.
If you don't want that, addto your preamble.Code: Select all
\raggedbottom
If that is not enough (you may now notice different space between headlines and first entries in LOF/LOT), addto above \makeatletter..\makeatother block. This will redefine \lstlistoflistings to behave the same way as \listoffigures does in a book class, hence the vertical space between `Listings' and the first entry in LOL should now be the same as between `List of figures' and the first entry in LOF (if there's the same number of entries LOF/LOL or \raggedbottom is active).Code: Select all
\renewcommand\lstlistoflistings{% \if@twocolumn \@restonecoltrue\onecolumn \else \@restonecolfalse \fi \chapter*{\lstlistlistingname}% \@mkboth{\MakeUppercase\lstlistlistingname}% {\MakeUppercase\lstlistlistingname}% \@starttoc{lol}% \if@restonecol\twocolumn\fi }
KR
Rainer
Thank you so much!