About this photo, I'd like that

(1) the numbers (I, 1, 1.1, 1.1.1, II, 2, 2.1, 2.1.1) and relative pagenumbers have the same size and color of what represent, i.e. (I ... First Example Part ... 3 must have same color and size, in this case red and Huge);

(2) better \vspace between parts and chapters, between chapters and sections and between sections and subsections.

(3) I put a cross on "Contents" because I'd not like two times same title.

Tcolorboxed Contents

Are My three requestes possible? If so, how Could I improve my tex code?




fonttitle=\bfseries,coltitle=red,attach boxed title to top center=
boxed title style={boxrule=0.5mm,
frame code={ \path[tcb fill frame] ([xshift=-4mm]frame.west)
-- (frame.north west) -- (frame.north east) -- ([xshift=4mm]frame.east)
-- (frame.south east) -- (frame.south west) -- cycle; },
interior code={ \path[tcb fill interior] ([xshift=-2mm]interior.west)
-- (interior.north west) -- (interior.north east)
-- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west)
-- cycle;} }] \tableofcontents

\part{\Huge\textcolor{red}{First Example Part}}

\chapter{\huge Goldboxed Theorems}

\section{\Large Some theorem for proof}

\subsection{\large Other examples}

\part{\Huge\textcolor{red}{Second Example Part}}

\chapter{\huge Tcolorboxed Posters}

\section{\Large Definition: \LaTeX--function}

\subsection{\large With Poster of Tcolorbox--package}


1 Answer 1


Well, first, you should probably put that whole tcolorbox environment in a new command. If you're really clever you could do

     \begin{tcolorbox}[lots of stuff]
       % ❶

Slap that in a .sty file and you can just write `\tableofcontents to produce the table of contents.

As for getting rid of the Contents, since we have \taleofcontentsOriginal inside a group,¹ we can just redefine the command that produces the title to do nothing. For the book document class, it's \chapter*{Contents}. We can put at the line marked ❶ the following:

\RenewDocumentCommand{\chapter}{ mm }{}

We're saying that we have two required arguments in the redefined command, with the first consuming the * and the second {Contents}


Per Ulrike Fischer's suggestion, the other approach would be to not even worry about copying the definition of \verb+\tableofcontents+ but instead to use the private command \@starttoc{toc}³. Since it's a private command there are two ways to do this. We'll replace the instance of \tableofcontents inside the tcolorbox with either



 \csname @starttoc\endcsname{toc}

I would recommend the first alternative as it's clearer to someone reading the code what's happening.

  1. We get that for free by being inside an environment.
  2. We could have defined the command with { sm } to indicate that the first argument is a star, but since we know it's going to be a star, there's no real benefit to that approach and will just make things (marginally) slower.
  3. This is what I get for tossing off an answer from my phone—I didn't bother to remind myself what's inside \tableofcontents after the \chapter* command.
  • Thank you for your answer, but Sorry, too complicated. Does another easier way exist, perhaps using imakeidx,indextools-packages?
    – Puck
    Commented Aug 13, 2021 at 1:45
  • I think you're thinking this is harder than it is. The key thing is to put the \RenewDocumentCommand line before your \tableofcontents. The rest is a recommendation to make your document more maintainable, but is not necessary.
    – Don Hosek
    Commented Aug 13, 2021 at 1:47
  • I just tried, no-compile-result, why?
    – Puck
    Commented Aug 13, 2021 at 1:53
  • What’s the error you got?
    – Don Hosek
    Commented Aug 13, 2021 at 2:04
  • 2
    sorry but this a rather convoluted method to get rid of the chapter heading before the entries. Why don't you use simply \csname @starttoc\endcsname{toc} instead of \tableofcontents in the box? Commented Aug 13, 2021 at 8:05

You must log in to answer this question.

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