# Why does titlesec make boxes thicker and how can I fix it?

I am trying to give my section headings a light grey box around the text. However, for some reason, when I add the titlesec package (which I am using to format chapter titles) it changes the thickness of the fcolorbox I placed around the text.

The Original (with normal thickness):

\documentclass[12pt]{scrbook}

\usepackage{graphicx}
\usepackage[pages=some]{background}

\begin{document}
\fcolorbox{gray!45}{gray!45}{\section*{{\small {\textsf{\bfseries{CHICKADEE IN THE NIGHT}}}}\hspace{1mm} {\small{| \hspace{1mm}
\scalebox{.8}[1.0]{
\texttt{FEBRUARY 20, 1980~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}}}}}}
\\
\end{document}


The one with titlesec included:

\documentclass[12pt]{scrbook}

\usepackage{graphicx}
\usepackage[pages=some]{background}
\usepackage{titlesec}
\begin{document}
\fcolorbox{gray!45}{gray!45}{\section*{{\small {\textsf{\bfseries{CHICKADEE IN THE NIGHT}}}}\hspace{1mm} {\small{| \hspace{1mm}
\scalebox{.8}[1.0]{
\texttt{FEBRUARY 20, 1980~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}}}}}}
\\
\end{document}


How can I get it to maintain the original, much narrower, grey box?

• First of all, remove all the errors, then the answer may be possible. – egreg Jul 20 '16 at 23:14
• And if you want boxed titles, use titlesec to to do the boxing. Don't put the \section command inside a box. – Alan Munn Jul 21 '16 at 0:15
• See How does one change the frame size and colors in the frame option of titlesec as in MWE? (which is probably a duplicate, if you are really asking how to make boxed section titles.) – Alan Munn Jul 21 '16 at 0:27
• And note that using titlesec will break functionality provided by KOMA. – cfr Jul 21 '16 at 0:45

Do not use titlesec with a KOMA-Script class. Here is a suggestion redefining the KOMA-Script command \sectionlinesformat:

\documentclass[12pt]{scrbook}
\usepackage{graphicx}
\usepackage{xcolor}
\colorlet{sectionbgcolor}{gray!45}
\colorlet{sectionbordercolor}{orange}

\makeatletter
\renewcommand\sectionlinesformat[4]{%
\ifstr{#1}{section}
{\fcolorbox{sectionbordercolor}{sectionbgcolor}{%
\parbox{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}{%
\raggedsection\@hangfrom{\hskip #2#3}{#4}}}}
{\@hangfrom{\hskip #2#3}{#4}}%
}
\makeatother