3

It deals with the displaying of the tcblistof feature with the package tcolorbox, which differs from the classic \listoffigures when used with the book class. In the example below (with tcolorbox v 3.05), you can see vertical space added between chapters inside the List of Figures, but not inside the List of Theorems.

\documentclass{book}
\usepackage[theorems]{tcolorbox}

\newtcbtheorem[auto counter,number within=chapter,list inside=thm]{theo}{Theorem}{}{}

\begin{document}
\listoffigures{}
\tcblistof[\chapter*]{thm}{List of Theorems}

\chapter{Chapter No1}
\begin{figure}
\caption{Figure No1}
\end{figure}
\begin{figure}
\caption{Figure No2}
\end{figure}
\begin{theo}{Theorem No1}{}
\end{theo}
\begin{theo}{Theorem No2}{}
\end{theo}

\chapter{Chapter No2}
\begin{figure}
\caption{Figure No3}
\end{figure}
\begin{figure}
\caption{Figure No4}
\end{figure}
\begin{theo}{Theorem No3}{}
\end{theo}
\begin{theo}{Theorem No4}{}
\end{theo}

\end{document}

Is it possible to achieve the same displaying for both? (more precisely, I'd like to make tcblistof behave like the List of Figures).

3

You have to teach \chapter to add the vertical space also in the list of theorems as it does for the lists of figures and tables.

The easiest way is patching \@chapter with etoolbox:

\documentclass{book}
\usepackage[theorems]{tcolorbox}
\usepackage{etoolbox}

\newtcbtheorem[auto counter,number within=chapter,list inside=thm]{theo}{Theorem}{}{}

\makeatletter
\patchcmd{\@chapter}
  {\chaptermark{#1}}% search
  {\chaptermark{#1}\addtocontents{thm}{\protect\addvspace{10\p@}}}% replace
  {}{}
\makeatother

\begin{document}
\listoffigures{}
\tcblistof[\chapter*]{thm}{List of Theorems}

\chapter{Chapter No1}
\begin{figure}
\caption{Figure No1}
\end{figure}
\begin{figure}
\caption{Figure No2}
\end{figure}
\begin{theo}{Theorem No1}{}
\end{theo}
\begin{theo}{Theorem No2}{}
\end{theo}

\chapter{Chapter No2}
\begin{figure}
\caption{Figure No3}
\end{figure}
\begin{figure}
\caption{Figure No4}
\end{figure}
\begin{theo}{Theorem No3}{}
\end{theo}
\begin{theo}{Theorem No4}{}
\end{theo}

\end{document}

enter image description here

If you have more lists, you can use just one patch instead of many:

\makeatletter
\patchcmd{\@chapter}
  {\chaptermark{#1}}% search
  {\chaptermark{#1}\@addvspaceinlists}% replace
  {}{}

\newcommand\@addvspaceinlists{%
  \@for\next:=\listoftocs\do{%
    \addtocontents{\next}{\protect\addvspace{10\p@}}%
  }%
}
\newcommand\listoftocs{thm}
% in an ideal world it would be
% \renewcommand\listoftocs{lot,lof,thm}
\makeatother

Just define \listoftocs to a comma separated list with the file extensions pertaining to each list.

  • Works fine for me. @ThomasF.Sturm (if you see this post): could it be implemented in tcolorbox? – mathieu2l Jul 2 '14 at 11:35
  • 1
    Just for the sake of completness, if hyperref is loaded, this works only is it is loaded after the patch. In case hyperref has to be loaded before (e.g. if it is loaded by the class), it should be enough to use \makeatletter \xapptocmd{\Hy@org@chapter}{% \addtocontents{thm}{\protect\addvspace{10\p@}}% }{}{} \makeatother – Denis Bitouzé Jul 9 '14 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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