Text Formatting ⇒ lstlistoflistings toc vertical spacings
lstlistoflistings toc vertical spacings
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.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
lstlistoflistings toc vertical spacings
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
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!