Theses, Books, Title pagesSection names in a tcolorbox

Classicthesis, Bachelor and Master thesis, PhD, Doctoral degree
Post Reply
bstex
Posts: 69
Joined: Mon Oct 23, 2017 10:22 am

Section names in a tcolorbox

Post by bstex »

Hi,
I'm trying to put all the section names of my book in a tcolorbox.
I have this code:

Code: Select all

\titleformat{\section}[hang]{\LARGE\bfseries\color{red}}{}{0pt}{\LARGE\bfseries\color{red}}
but I can't find out where to put the \begin{tcolorbox} and \end{tcolorbox} to make the section name (I don't mind about the section number) into a tcolobox.
Thank you in advance.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Section names in a tcolorbox

Post by Johannes_B »

The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Section names in a tcolorbox

Post by Stefan Kottwitz »

Hi Johannes,

it's now tcolorbox instead of colorbox but it could be the same. In the other topic it was made by redefining LaTeX' internal macro, not titlesec as it's mentioned here.

Stefan
LaTeX.org admin
bstex
Posts: 69
Joined: Mon Oct 23, 2017 10:22 am

Section names in a tcolorbox

Post by bstex »

I'm not using the same template yet.
I found out that the "\thesection" is referring to the section number.
What is the code for the section name? I can't find it to put it in a tcolorbox.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Section names in a tcolorbox

Post by Stefan Kottwitz »

In the other topic I patched the internal LaTeX macro \@ssect. It's default LaTeX, independent of the template, so you can use it in a similar way here. Just if a package redefines such internal stuff (titlesec may do) it can make a difference, but just test it with the \@ssect patch.

\@ssect is from kind of 25 old base LaTeX internals, that's why it doesn't look so user friendly like having a macro for the section name that could be redefined easily.

Stefan
LaTeX.org admin
Post Reply