# List of listing (using tcblistof) vertical spacing, group by chapter

I'm currently trying to set the vertical spacing within \tcblistof command.

The template which causes my problems can be found here: https://github.com/ManuelRauber/LaTeX-Template

At first here are some screenshots showing my problem.

The table of contents shows what I want to have for all my listings: The caption of chapters are grouped together and between the chapters there is a bit more space. This is completely fine.

The same is for the list of figures and the list of tables (lof as example). Chapters are grouped together and minimal space between the captions within a chapter.

The problems are my list of listings. Created by the following code (see the GitHub link for a complete example or here https://tex.stackexchange.com/a/124688/15907):

% by Thomas F. Sturm (https://tex.stackexchange.com/a/124688/15907)
\newtcblisting[auto counter,number within=section,
list inside=mypyg]{listingsbox}[3][]{%
listing only,title={Listing \thetcbcounter: #3},
list entry={\protect\numberline{\thetcbcounter}#3},

\begin{document}



This is the output:

I tried the solution found here: tcblistof, book class and vertical spacing. But that didn't work for me (and I changed the patchcmd to use addchap instead of chapter).

What do I need to do to get the \tcblistof to group the entries by chapter (and get minimals spacing within in chapter)?

• It could be easier to help you with a minimal working (or not) example instead of expecting we download your complete document and all accompaning packages which are not related to your problem. – Ignasi Jul 29 '14 at 11:40

Add the following lines to the preamble:

\usepackage{etoolbox}
\makeatletter
\renewcommand*\l@tcolorbox{\@dottedtocline{1}{1.5em}{3em}}
\makeatother


and then in the document, for the list of listings:

\begingroup
\parskip=0pt
\endgroup


Here's a complete example using the settings from the link provided:

\documentclass[12pt,a4paper,oneside,
final,
titlepage,
BCOR6mm,
toc=listof,
parskip=full,
ngerman,
]{scrreprt}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{etoolbox}
\usepackage[many,minted]{tcolorbox}
\tcbuselibrary{listings}

\newcommand{\mynewminted}[3]{%
\newminted[#1]{#2}{#3}%
\tcbset{myminted/#1/.style={minted language=#2,minted options={#3}}}}

\mynewminted{mycsharp}{csharp}{tabsize=2,fontsize=\footnotesize}
\mynewminted{myjavascript}{js}{tabsize=2,fontsize=\footnotesize}
\mynewminted{myxml}{xml}{tabsize=2,fontsize=\footnotesize}
\mynewminted{myshell}{shell-session}{tabsize=2,fontsize=\footnotesize}
\mynewminted{myjson}{json}{tabsize=2,fontsize=\footnotesize}
\mynewminted{mycode}{text}{tabsize=2,fontsize=\footnotesize}

\newtcblisting[auto counter,number within=section,
list inside=mypyg]{listingsbox}[3][]{%
listing only,title={Listing \thetcbcounter: #3},
list entry={\protect\numberline{\thetcbcounter}#3},

\makeatletter
\renewcommand*\l@tcolorbox{\@dottedtocline{1}{1.5em}{3em}}
\makeatother

\begin{document}

\tableofcontents

\begingroup
\parskip=0pt
\endgroup

\chapter{Test chapter}
\section{A test section}
\begin{listingsbox}{mycsharp}{A test listing}
test
\end{listingsbox}

\section{Another test section}
\begin{listingsbox}{mycsharp}{A test listing}
test
\end{listingsbox}

\chapter{Test chapter}
\section{A test section}
\begin{listingsbox}{mycsharp}{A test listing}
test
\end{listingsbox}

\section{Another test section}
\begin{listingsbox}{mycsharp}{A test listing}
test
\end{listingsbox}

\end{document}


An image of the resulting document:

An image of the ToC:

An image of the list of listings:

• Thanks, that does work, sometimes. Sometimes I get the error: Incomplete \iffalse; all text was ignored after line 3 ...listof[\addchap*]{mypyg}{Codeverzeichnis}. Have you experienced this? – Manuel Rauber Jul 31 '14 at 12:26
• @Raubi No; in my examples the code works es expected with no errors. Please compose a little complete document (as in the one in my answer) allowing us to reproduce the error and add it to your question so we can easiy diagnose the problem and propose solutions. – Gonzalo Medina Jul 31 '14 at 14:46
• After an hour of trying to provide a mwe, I found my problem: I used \printglossary[style=super,type=\acronymtype] to print a list of acronyms. If I remove style=super it works very well. With style=super it didn't not work. So it may be a bug with that style. But to fix it, I wrote \FloatBarrier (from the placeins package) after the \printglossary command. With it, it works very well. (It seems that there is a floating problem with that combination of commands). Anyway. Thank you very much! :) – Manuel Rauber Aug 4 '14 at 7:47
• @Raubi You're welcome. Glad to hear you found the problem and solved it. Don't forget that you can accept the answer if you consider it solved the problem in the question :) – Gonzalo Medina Aug 4 '14 at 13:47
• I did. :) Just for the records (I saw it, when I printed my document today): \begingroup \endgroup didn't restore the \parskip properly. I used { } then, which works as expected. – Manuel Rauber Aug 5 '14 at 14:57