# Problem

I use a tcolorbox as a Chapter's summary, and thanks to this answer I am able to include it in the TOC as well.

## MWE

\documentclass[
]{scrbook}

\usepackage[most]{tcolorbox}
\usepackage{hyperref}
\usepackage{lipsum}
\hypersetup{
}
% ---------------------------
\begin{document}
\tableofcontents

\chapter{First}
\section{one}
\lipsum
\section{two}
\lipsum

\begin{tcolorbox}[
fonttitle=\ttfamily\bfseries\large,
width=\textwidth+10mm,
left skip=10mm,
before skip=10mm,
toptitle=4mm,
boxsep=2mm,
coltitle=white,
colback=orange!5!white,
colframe=orange,
]

Lorem Ipsum

\end{tcolorbox}

\end{document}



The result is as follows:

## My goal

All is fine, except that I would like to change the font family, size and color of the Summary title, but I can't: it always reverts to the default Section's. Unless I use a standard title, e.g. title=Summary of the Chapter, but then I lose the TOC entry that I need.

## Workarounds that don't really work

If I use titlesec then I can successfully change the section/tcolorbox title style, but then the link in the TOC points to the wrong section:

\documentclass[
]{scrbook}

\usepackage[most]{tcolorbox}
\usepackage{hyperref}
\usepackage{lipsum}
\hypersetup{
}
\usepackage{titlesec}
\usepackage{fix-cm}

\makeatletter
\newcommand\ChapterSize{\@setfontsize\Huge{25}{27}}
\makeatother

\makeatletter
\newcommand\SectionSize{\@setfontsize\Huge{22}{24}}
\makeatother

\titleformat{\chapter}[block]
{\ChapterSize\bfseries\sffamily}%
{\thechapter{}}
{5mm}
{}

\titleformat{\section}[block]
{\Large\bfseries\sffamily}%
{\thesection}
{5mm}
{}

% ---------------------------
\begin{document}
\tableofcontents

\chapter{First}
\section{one}
\lipsum
\section{two}
\lipsum

\begin{tcolorbox}[
fonttitle=\color{white},
width=\textwidth+10mm,
left skip=10mm,
before skip=10mm,
toptitle=4mm,
boxsep=2mm,
coltitle=white,
colback=orange!5!white,
colframe=orange,
]

Lorem Ipsum

\end{tcolorbox}

\end{document}



The same result (offset link in the TOC entry) happens if I change the title of the tcolorbox removing the \protect, like:

title={Summary\addcontentsline{toc}{section}{Summary}}


How do I change the font title (family-size-color) keeping the same functionality I've already implemented? Thank you.

• Did you already try something like title={Summary\addcontentsline{toc}{section}{Summary}}? Apr 5 at 15:39
• It fixes the formatting but it messes up the links in the TOC (via hyperref), the Summary entry in the TOC points to the section before it. I guess the \protect is useful there for that reason. Apr 5 at 16:55

According to this comment you have to add \phantomsection before \addcontentsline in order to set the anchor for the link properly—in case the TOC points to a wrong section. This, in conjunction with the use of the titlesec package, let me change the font style while having a not-numbered entry in the TOC which link points to the right place. 🍾

## Working example

\documentclass[
]{scrbook}

\usepackage[most]{tcolorbox}
\usepackage{hyperref}
\usepackage{lipsum}
\hypersetup{
}
\usepackage{titlesec}
\usepackage{fix-cm}

\makeatletter
\newcommand\ChapterSize{\@setfontsize\Huge{25}{27}}
\makeatother

\makeatletter
\newcommand\SectionSize{\@setfontsize\Huge{22}{24}}
\makeatother

\titleformat{\chapter}[block]
{\ChapterSize\bfseries\sffamily}%
{\thechapter{}}
{5mm}
{}

\titleformat{\section}[block]
{\Large\bfseries\sffamily}%
{\thesection}
{5mm}
{}

% ---------------------------
\begin{document}
\tableofcontents

\chapter{First}
\section{one}
\lipsum
\section{two}
\lipsum

\begin{tcolorbox}[
fonttitle=\color{white},
width=\textwidth+10mm,
left skip=10mm,
before skip=10mm,
toptitle=4mm,
boxsep=2mm,
coltitle=white,
colback=orange!5!white,
colframe=orange,
]

Lorem Ipsum

\end{tcolorbox}

\end{document}


• This seems good. Sep 5 at 4:23