How to change the color of the background on the chapter style in fncychap? (\usepackage[Bjornstrup]{fncychap})

fncychapoverleaf

I'm working on a university project, where I would like to change the color of the box obtained by the chapterstyle Bjornstrup in the fncychap package. I have following now:

enter image description here

I would really like the gray box, to be a box with the color \definecolor{aaublue}{RGB}{33,26,82}. Ideally, since the color is quite dark, the text should be white.

The documentclass is as follows: \documentclass[12pt,a4paper,openright]{report}.

The document templete, which is used, can be found on this site: https://da.overleaf.com/latex/templates/aalborg-university-aau-report-template/ckfhtmfkpjvv

I’m really not an expert in latex, so I hope I’ve provided enough information to solve this problem.

Best Answer

Add this code bellow \usepackage[Bjornstrup]{fncychap} (and choose the colors you like):

\newcommand{\colortitlechap}{\color[rgb]{0.9,0.9,0.9}} % color of the chapter title <<<
\newcommand{\colornumberchap}{\color[rgb]{0.6,0.6,0.6}} % color of the chapter number <<<<
\newcommand{\colorbackchap}{\colorbox[rgb]{.129,0.1,0.82}} % color of the background rules <<<

\makeatletter

\renewcommand{\DOCH}{%
    \settowidth{\py}{\CNoV\thechapter}
    \addtolength{\py}{-10pt}% 
    \fboxsep=0pt%
    \colorbackchap{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}%
    \kern-\py\raise20pt%
    \hbox{\colornumberchap\CNoV\thechapter}\\%
}

\renewcommand{\DOTI}[1]{%
    \nointerlineskip\raggedright%
    \fboxsep=\myhi%
    \vskip-1ex%
    \colorbackchap{\parbox[t]{\mylen}{\CTV\FmTi{\colortitlechap#1}}}\par\nobreak%
    \vskip 40\p@%
}

\renewcommand{\DOTIS}[1]{%
    \fboxsep=0pt%
    \colorbackchap{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}\\%
    \nointerlineskip\raggedright%
    \fboxsep=\myhi%
    \colorbackchap{\parbox[t]{\mylen}{\CTV\FmTi{\colortitlechap#1}}}\par\nobreak%
    \vskip 40\p@%
}

\makeatother

d

c

This is the complete code.

\documentclass[a4paper,12pt]{report}

\usepackage[Bjornstrup]{fncychap}
%%%% ******************************************************* added
\newcommand{\colortitlechap}{\color[rgb]{0.9,0.9,0.9}} % color of the chapter title <<<
\newcommand{\colornumberchap}{\color[rgb]{0.6,0.6,0.6}} % color of the chapter number <<<<
\newcommand{\colorbackchap}{\colorbox[rgb]{.129,0.1,0.82}} % color of the background rules <<<

\makeatletter

\renewcommand{\DOCH}{%
    \settowidth{\py}{\CNoV\thechapter}
    \addtolength{\py}{-10pt}% 
    \fboxsep=0pt%
    \colorbackchap{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}%
    \kern-\py\raise20pt%
    \hbox{\colornumberchap\CNoV\thechapter}\\%
}

\renewcommand{\DOTI}[1]{%
    \nointerlineskip\raggedright%
    \fboxsep=\myhi%
    \vskip-1ex%
    \colorbackchap{\parbox[t]{\mylen}{\CTV\FmTi{\colortitlechap#1}}}\par\nobreak%
    \vskip 40\p@%
}

\renewcommand{\DOTIS}[1]{%
    \fboxsep=0pt%
    \colorbackchap{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}\\%
    \nointerlineskip\raggedright%
    \fboxsep=\myhi%
    \colorbackchap{\parbox[t]{\mylen}{\CTV\FmTi{\colortitlechap#1}}}\par\nobreak%
    \vskip 40\p@%
}

\makeatother
%%*******************************************************************************
\begin{document}

    \tableofcontents   
    \chapter{Introduccion}
    \section{One}   
    \chapter{Technical content}
    \section{Two}
    
\end{document}