3

I want to create a table of contents that looks like the one of the toc of the tcolorbox package. So I did this (MWE) :

\documentclass[12pt,a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{tikz,lipsum,lmodern}
\usepackage[most]{tcolorbox}
\newcommand{\tablemat}[1]{
    \begin{tcolorbox}[enhanced,title=Table des matières,
    colframe=black,colback=white,colbacktitle=black!10,
    fonttitle=\bfseries,coltitle=black,attach boxed title to top center=
    {yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2},
    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;} }]
    #1
    \end{tcolorbox}
}
\begin{document}
\tablemat{\tableofcontents}
\chapter{a chapter}
\section{a section}
\section{a second section}
\end{document}

This creates a chapter header named "table of contents" inside the tcolorbox, and I don't want that.

How can I use this setup without creating a chapter header for the table of content ?

Thank you in advance for any advice.

4
  • 1
    tex.stackexchange.com/a/619719/38080 explains how to do it (notice the \makeatletter\@startoc\makeatother trick...)
    – Rmano
    Oct 24, 2021 at 20:27
  • Thank you ! I didn't find it when I searched. Do this work with \listoffigures and \listoftables ?
    – Elyo
    Oct 24, 2021 at 20:33
  • i don't know... The trick is to find the internal command of the main class that generates the body of the lists. You can ask a specific question, somebody here will know...
    – Rmano
    Oct 24, 2021 at 20:44
  • Found it, I answered my post to make this information available.
    – Elyo
    Oct 24, 2021 at 20:59

1 Answer 1

2

I think it will be useful if I answer my own question. Here is a piece of code that does the job :

\begin{tcolorbox}[breakable,enhanced jigsaw,title={Table },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} % Replace it with \@starttoc{lot} for tables and \@starttoc{lof} for figures.
\makeatother
\end{tcolorbox}

You must log in to answer this question.

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