I am using scrbook
document class. I've created my own environment named example
and I wanted to create "List of examples." In that name I've loaded package tocloft
.
However as much as I try, the "List of examples" is formatted differently than other lists, like "List of tables" or "List of figures": horizontal spacing is substantially smaller for "List of Examples".
I've tried everything, including option titles
, which only makes things worse, changing vertical spacing.
Please help me format "List of examples" just like the other lists.
Here is MWE:
\documentclass[11pt,parskip=half,numbers=noenddot,bibliography=totoc,index=totoc]{scrbook}
\usepackage{tcolorbox,etoolbox}
% Adding option `titles' makes it worse
\usepackage{tocloft}
\newcommand{\listexamplename}{List of examples}
\newlistof[chapter]{example}{loe}{\listexamplename}
\renewcommand{\theexample}{\thechapter.\arabic{example}}
\newenvironment{example}[1]{\refstepcounter{example}\addcontentsline{loe}{example}{\protect\numberline{\theexample}{\ignorespaces #1}}\par\begin{tcolorbox}[title=Example\ \theexample:\ #1]}{\end{tcolorbox}}
% For list of examples, make space between chapters
\makeatletter
\preto\chapter{\addtocontents{loe}{\protect\addvspace{10\p@}}}%
\makeatother
\begin{document}
\chapter{First}
\begin{example}{First example.}
\end{example}
\begin{table}
\caption{First graph.}
\end{table}
\chapter{Second}
\begin{example}{Second example.}
\end{example}
\begin{table}
\caption{Second graph.}
\end{table}
\begin{example}{Third example.}
\end{example}
\begin{table}
\caption{Third graph.}
\end{table}
\chapter{Lists}
\listoftables
\listofexample
\end{document}