[Tex/LaTex] LaTeX: chapter & section title (background) colour

chapterscolorsectioning

I wanted to make my chapter and ((sub)sub)section titles as follows (compiling by XeTeX-ing):

  • White chapter title on background RGB 10,30,96 (defined as "ugentblauw")
  • (Sub(sub))section title RGB 10,30,96

But I have no clue how to do this… Here's the full code of my file:

\documentclass[11pt]{report}
\usepackage[left=1.5in,right=1.5cm,top=2cm,bottom=2.5cm]{geometry}
\usepackage[dutch]{babel}
\usepackage{graphicx}
\usepackage{framed}
\usepackage{url}
\newlength\longest
\usepackage[draft]{pdfpages}
\usepackage{xcolor}
\usepackage{sectsty}                
\usepackage{fancyhdr}
\usepackage{tocloft}
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}
\usepackage{ragged2e}
\usepackage{cite}
\usepackage[T1]{fontenc}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[scaled=0.92]{helvet}    
\usepackage[parfill]{parskip}
\usepackage[square,sort,comma,numbers,sort&compress]{natbib}
\usepackage[nottoc]{tocbibind}
\bibliographystyle{vancouver}
\usepackage{multicol}
\usepackage{titlesec}
\usepackage{titling}
\usepackage{tikz}\usetikzlibrary{shapes.misc}
\usepackage{xunicode}
\usepackage{slantsc}
\usepackage{amsmath}  
\definecolor{ugentblauw}{rgb}{10,30,96}  
\titleformat{\chapter}{\bf\huge}{\thechapter}{20pt}{\bf\huge}
\begin{document}
\normalfont\normalfont
\setcounter{page}{1}
\pagenumbering{arabic}
\chapter{Chapter}
This is some text.
\section{Section}
Indeed, text it is.
\bibliography{bibinflu}
\end{document}

Thank you in advance!

Best Answer

Is that what you want? I used the framed package, which cooperates with titlesec, and removed sectsty, which conflicts with titlesec. I also removed a few other packages, which were unused in this code fragment.

\documentclass[11pt, x11names, xetex]{report}
\usepackage[left=1.5in,right=1.5cm,top=2cm,bottom=2.5cm]{geometry}
\usepackage[dutch]{babel}
\usepackage{framed}

\usepackage{xcolor}
\usepackage{ragged2e}
\usepackage[T1]{fontenc}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[scaled=0.92]{helvet}

\usepackage[parfill]{parskip}
\usepackage[explicit]{titlesec}
\usepackage{xunicode}
\usepackage{xespotcolor} 
\usepackage{framed}
\definecolor{ugentblauw}{cmyk}{1 0.8 0.3 0.05}%
\colorlet{shadecolor}{ugentblauw}

\titleformat{\chapter}[display]{\normalfont\color{white} \begin {shaded*}\bfseries}{\huge\chaptername~\thechapter}{20pt}{\Huge#1\end{shaded*}}

\titleformat{\section}{\normalfont\large\bfseries\color{ugentblauw}}{\thesection}{1em}{#1}

\begin{document}
\setcounter{page}{1}
\pagenumbering{arabic}

\tableofcontents 

\chapter{Chapter}
This is some text.

\section{Section}
Indeed, text it is.
\bibliography{bibinflu}

\end{document} 

enter image description here

enter image description here