3

The manual for tcolorbox is an immense volume that I have been slowing chipping away at, but it has a rather inspiring table of contents that I would like to reproduce and then modify. How do I code a table of contents like the one that wraps around the table of contents in the tcolorbox manual?

A search for 'table of contents' in the documentation gave only one result on page 122, but it is not clear to me whether it is relevant to my goal.

6

The source code for the tcolorbox manual is here, split into different files. The code for the table of contents is in tcolorbox.doc.abstract.tex and says:

\begin{tcolorbox}[breakable,enhanced jigsaw,title={Contents},fonttitle=\bfseries\Large,
  colback=yellow!10!white,colframe=red!50!black,before=\par\bigskip\noindent,
  interior style={fill overzoom image=goldshade.png,fill image opacity=0.25},
  colbacktitle=red!50!yellow!75!black,
  enlargepage flexible=\baselineskip,pad at break*=3mm,
  height fixed for=first and middle,
  watermark color=yellow!75!red!25!white,
  watermark text={\bfseries\Large Contents},
  attach boxed title to top center={yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2},
  boxed title style={enhanced,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;}  },
  drop fuzzy shadow]
\makeatletter
\@starttoc{toc}
\makeatother
\end{tcolorbox}

The breakable key here requires you to load \tcbuselibrary{breakable} after \usepackage{tcolorbox}, and enables the automatic page breaking. This code also uses \tcbuselibrary{skins}. The enhanced jigsaw key (a shortcut for skin=enhanced jigsaw) handles the top and bottom borders, so if you wanted there to be a frame at the bottom of page 3 and the top and bottom of page 4, for example, you could change this to skin=enhanced.

The \@starttoc command is defined in the LaTeX kernel, used here rather than \tableofcontentsto skip unwanted formatting such as page breaks and title. If you wanted to change the appearance of the table of contents inside the box, you would normally use a package like tocloft or tocbasic. That link, for example, shows how to format the table of contents in two columns.

3

Page 167. Change colors and put \tableofcontents Into example (instead of \lipsum[2])

enter image description here

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.