I am using the titlesec
package to format the titles of sections. I would like to change the background color of the frame shape.
Concretely, I would like to obtain a solid (that is, the same color for the frame and background) blue frame and white text.
I tried the naive approach of using \colorbox
as a format in\titleformat
but it does not seem to work:
\documentclass{article}
\usepackage{xcolor}
\usepackage{titlesec}
\setcounter{secnumdepth}{0}
\newcommand{\mybox}[1]{
\colorbox{blue}{\textcolor{white}{#1}}
}
\titleformat{\section}
[frame]
{
\vspace{.8ex}%
\color{blue}\Large\normalfont\sffamily\mybox
}
{\thesection.}
{.5em}
{}
\begin{document}
\section{First section}
The first section begins here\ldots
\section{Second section}
The second section begins here\ldots
\end{document}
I would be very grateful if someone could explain how I can obtain the desired result.