5

I'm writing a quite large document and would like to make a toc of used boxes. I'm using the tcolorbox package because i like the way it gives you freedom to modify the appearance of the boxes. While generating the toc using the options provided by the package i get extra numbering within the toc. I suspect it's because the tcblistof generates it's own numbers and i use them as well in the title of the box. I would like to get rid of those numbers. In front of the title in the tcblistof.

here's a MWE that gives the problem:

\documentclass[numbers=noenddot,12pt,footinput=true,headinput=true,cleardoublepage=empty,twoside,svgnames,colorlinks=true]{scrbook}
\usepackage{scrlfile}
\PreventPackageFromLoading{mathpazo}
\usepackage[parts,pdfspacing,manychapters,dottedtoc,drafting]{classicthesis}
%manychapters,eulerchapternumbers,eulermath,listings,linedheaders
\usepackage{lmodern}     
\usepackage{textcomp}   
\usepackage[T1]{fontenc}  
\usepackage[outer=7cm, inner=1.5cm, marginparwidth=4.5cm,marginparsep=.6cm, textheight=674pt]{geometry}%showframe
\usepackage[dutch]{babel}
\usepackage{xspace}
\usepackage{tocbibind} 
\usepackage{graphicx}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage[font=footnotesize,font=rm,labelfont={bf,rm},format=plain,style=default]{caption}                  
\usepackage{subcaption}               
\usepackage{multicol}
\usepackage{multirow}
\usepackage{float}
\usepackage[utf8]{inputenc}
\usepackage[framemethod=tikz]{mdframed} 
\usepackage[most,listings]{tcolorbox}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{arsclassica}
\usepackage{threeparttable}

\usepackage{lipsum}

\setcounter{tocdepth}{1}

\newtcolorbox[auto counter,number within=chapter,list inside=box]{test}[2][]{
enhanced,
colback=red!25,
colframe=red!25,
fonttitle=\bfseries,
coltitle=black,
arc=0pt,outer arc=0pt,
drop shadow,
title=Box~
\thetcbcounter.\quad#2,#1}

\begin{document}

\tableofcontents

\tcblistof[\chapter*]{box}{Lijst van Boxen}

\chapter{Test}

\lipsum[1]

\begin{test}{Example}
This is an example
\end{test}

\chapter{Test continued}

\lipsum[2]

\begin{test}{Next example}
More text
\end{test}

\end{document}

enter image description here

what i get:

1.1 Box 1.1. Example . . . . . . . . . . . . . . . . . . . . 9

2.1 Box 2.1. Next example . . . . . . . . . . . . . . . . . 11

should be:

Box 1.1. Example . . . . . . . . . . . . . . . . . . . . 9

Box 2.1. Next example . . . . . . . . . . . . . . . . . 11

2
  • That's not really a M(minimal)WE, you are loading a lot of irrelevant packages. Commented Dec 11, 2014 at 10:44
  • yes i know sorry,i already trimmed it down from the actual document, but i just need to get more used to which packages are the only ones really required to reproduce the problem... Again my apologies Commented Dec 11, 2014 at 11:22

3 Answers 3

4

Add this to your preamble

\makeatletter
\def\tcb@addcontentsline#1#2{%
  \ifx\kvtcb@listentry\@empty%
    \ifx\kvtcb@title\@empty%
      \ifx\tcbtitletext\@empty%
        \addcontentsline{#1}{#2}{{\ignorespaces\kvtcb@savedelimiter}}%
      \else%
        \addcontentsline{#1}{#2}{{\ignorespaces\tcbtitletext}}%
      \fi%
    \else%
      \addcontentsline{#1}{#2}{{\ignorespaces\kvtcb@title}}%
    \fi%
  \else%
    \addcontentsline{#1}{#2}{\kvtcb@listentry}%
  \fi%
}
\makeatother

enter image description here

2
  • this works, but could you tell how to get rid off the indentation this solution gives? Commented Dec 11, 2014 at 11:47
  • @Charles-AlexandreMattelaer You have to add \renewcommand{\l@tcolorbox}{\@dottedtocline{1}{0em}{2.3em}} just before \makeatother
    – user11232
    Commented Dec 11, 2014 at 11:48
4

This should work; with [...] I denote all that precedes \begin{document} in your file:

[...]

\makeatletter % no indent for entries
\renewcommand{\l@tcolorbox}{\@dottedtocline{1}{0pt}{2.3em}}
\makeatother

\begin{document}

\tableofcontents

\begingroup
% temporarily make \numberline do nothing
\renewcommand\numberline[1]{}
\tcblistof[\chapter*]{box}{Lijst van Boxen}
\endgroup

enter image description here

4

The text for the list can be set explicitely with list entry, here:

list entry=Box~\thetcbcounter.\quad#2,

All together, this gives:

\documentclass[numbers=noenddot,12pt,footinput=true,headinput=true,cleardoublepage=empty,twoside,svgnames,colorlinks=true]{scrbook}
\usepackage{scrlfile}
\PreventPackageFromLoading{mathpazo}
\usepackage[parts,pdfspacing,manychapters,dottedtoc,drafting]{classicthesis}
%manychapters,eulerchapternumbers,eulermath,listings,linedheaders
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage[T1]{fontenc}
\usepackage[outer=7cm, inner=1.5cm, marginparwidth=4.5cm,marginparsep=.6cm, textheight=674pt]{geometry}%showframe
\usepackage[dutch]{babel}
\usepackage{xspace}
\usepackage{tocbibind}
\usepackage{graphicx}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage[font=footnotesize,font=rm,labelfont={bf,rm},format=plain,style=default]{caption}
\usepackage{subcaption}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{float}
\usepackage[utf8]{inputenc}
\usepackage[framemethod=tikz]{mdframed}
\usepackage[most,listings]{tcolorbox}
\usepackage{xcolor}
\usepackage{tikz}
\usepackage{arsclassica}
\usepackage{threeparttable}

\usepackage{lipsum}

\setcounter{tocdepth}{1}

\newtcolorbox[auto counter,number within=chapter,list inside=box]{test}[2][]{
enhanced,
colback=red!25,
colframe=red!25,
fonttitle=\bfseries,
coltitle=black,
arc=0pt,outer arc=0pt,
drop shadow,
title=Box~\thetcbcounter.\quad#2,
list entry=Box~\thetcbcounter.\quad#2,
#1}

\begin{document}

\tableofcontents

\tcblistof[\chapter*]{box}{Lijst van Boxen}

\chapter{Test}

\lipsum[1]

\begin{test}{Example}
This is an example
\end{test}

\chapter{Test continued}

\lipsum[2]

\begin{test}{Next example}
More text
\end{test}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .