# Customizing Chapter style in scrbook

I want to obtain styles like those showed in the next two images (I do not need the picture in the background (parabolas)):

My original LaTeX code (to be customized but should keep font as they are):

% !TEX TS-program = latex
\documentclass[11pt, pagesize=auto, version=last, chapterprefix=true]{scrbook}
%% En 12pt c'est possible aussi
%% packages utilises
%%---------------------
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc} % pour taper les lettres accentues
%====Perso====%
\usepackage{charter}
\usepackage[expert]{mathdesign}
%=================%
%\usepackage{etoolbox}
%\pretocmd{\ref}{\bgroup\small}{}{}
%\apptocmd{\ref}{\egroup}{}{}
%=============%
\usepackage[frenchb]{babel}
\usepackage[babel=true]{csquotes} % csquotes va utiliser la langue définie dans babel
\usepackage{titlesec}
%%%%%Chapter%%%%%%%
\setkomafont{chapter}{\usefont{T1}{qhv}{b}{n}\selectfont\huge}
%%%%%Section%%%%%%%%
\titleformat{\section}[hang]{
\usefont{T1}{qhv}{b}{n}\selectfont} % "qhv" - TeX Gyre Heros, "b" - bold
{}
{0em}
{\hspace{-0.4pt}\Large \thesection\hspace{0.6em}}
\begin{document}

\chapter{Test chapter}
\section{Test section}

\end{document}

-

In the follwing solution just replace the green rule - e.g. \color{green} \rule{0.4\textwidth}{0.4\textwidth} - with \includegraphics[width=0.4\textwidth]{yourpicname} while using the graphics or graphicx package. And you should apply the color theme you like. I just used plain old 'blue' for the demonstration.

## The Code

\documentclass[11pt, pagesize=auto, version=last, chapterprefix=true]{scrbook}
\setkomafont{chapter}{\usefont{T1}{qhv}{b}{n}\selectfont\huge}
\usepackage{xcolor,anyfontsize,realboxes}
\renewcommand\chapterformat{%
\hspace*{-1in} %customize this to your needs
\makebox[0.42\textwidth][c]{%
\raisebox{-.5em}[0.4\textwidth][0cm]{%
\color{green} \rule{0.4\textwidth}{0.4\textwidth}
\put(-52,24){%
\Colorbox{blue}{%
\parbox{0.11\textwidth}{%
\centering
\small\color{white}
\chaptertitlename\par
{\fontsize{38}{41}\selectfont\thechapter\par}
\vspace{.5em}
}}
}
}
}
}
\newcommand{\sectionformat}{%
\raisebox{-.65em}[0cm][0cm]{%
\Colorbox{blue}{%
\parbox{3em}{%
\centering
\color{white}
\thesection
}}
}
}
\usepackage[frenchb]{babel}
\usepackage{titlesec}
\titleformat{\chapter}
{\huge\bfseries\color{blue}}{\chapterformat}{0em}{}
\titleformat{\section}[hang]{%
\usefont{T1}{qhv}{b}{n}\selectfont\Large\color{blue}} % "qhv" - TeX Gyre Heros, "b" - bold
{\sectionformat}
{0em}
{\hspace{.75em}}
[\vspace*{-.75em}\rule{2.25em}{0pt}\rule{\textwidth}{2pt}]

\begin{document}
\chapter{Test chapter}
\section{Test section}
\end{document}


## Output

(Note that I don't changed the fonts as you requested, although the fonts in your example pic are slightly different. There are some small caps and italics.)

-
Thank you. But the result is quite different. The font applied to the chapter name and number still not the same. Also, the position of the line need to be much lower and fit the page's margins and the name of the section have to approach more the line (like what we see if we use an underline command). Finally, is there any way to move up the position of the block {chapter name, number} a little higher? Tank you again. –  SAKLY Dec 24 '13 at 11:49
I finally found how to change the chapter font. There no need to the command "\setkomafont{chapter}{\usefont{T1}{qhv}{b}{n}\selectfont\huge}". It suffice to use "\usefont{T1}{qhv}{b}{n}\selectfont\huge" into the \titleformat{\chapter}. –  SAKLY Dec 24 '13 at 12:48
@SAKLY Note, that titlesec is according to Markus Kohm, the KOMA-Script developer, not fully compatible to KOMA-Script classes (and scrextend). If you understand German, see my answer in Incompatibilities between KOMA-Script and titlesec. Perhaps you stumbled here over such an incompatibility. Maybe it would have worked, if the \setkomafont{chapter} line would have been set after all titlesec definitions. Your solution is the “raw” LaTeX version. –  Speravir Dec 24 '13 at 22:46

Here's another option:

\documentclass[
11pt,
pagesize=auto,
version=last,
chapterprefix=true
]{scrbook}
\usepackage[frenchb]{babel}
\usepackage[babel=true]{csquotes}
\usepackage[T1]{fontenc}
\usepackage[explicit]{titlesec}
\usepackage{xcolor}
\usepackage{charter}

\definecolor{mybluei}{RGB}{28,138,207}
\definecolor{myblueii}{RGB}{131,197,231}

\newcommand\ChapterFont{\usefont{T1}{qhv}{b}{n}\selectfont\huge}
\newcommand\SectionFont{\usefont{T1}{qhv}{b}{n}\selectfont}

\titleformat{\chapter}[display]
{\normalfont\ChapterFont\huge\color{myblueii}}
{}
{0pt}
{\parbox[b]{70pt}{\mbox{}}%
\parbox[b]{50pt}{\colorbox{mybluei}{%
\parbox[b][60pt][t]{45pt}{\centering%
\color{white}%
{\itshape\rmfamily\small\chaptertitlename}%
\vfill{\fontsize{50}{120}\selectfont\thechapter}%
}%
}%
}\hspace{15pt}%
\parbox[b]{\dimexpr\textwidth-150pt}{%
\raggedright\scshape#1\vskip6pt%
}%
}

\titleformat{name=\chapter,numberless}[display]
{\normalfont\ChapterFont\huge\color{myblueii}}
{}
{0pt}
{\parbox[b]{70pt}{\mbox{}}%
\hspace{15pt}%
\parbox[b]{\dimexpr\textwidth-150pt}{%
\raggedright\scshape#1\vskip6pt%
}%
}

\titleformat{\section}
{\normalfont\small\sffamily\SectionFont\color{myblueii}}
{\colorbox{mybluei}{%
\parbox[c][16pt][c]{40pt}{%
\centering\textcolor{white}{\SectionFont\Large\rmfamily\thesection}%
}%
}%
}
{1em}
{#1}
[\vspace{-1.2\baselineskip}%
\color{myblueii}\hspace*{\dimexpr40pt+2\fboxsep\relax}%
\rule{\dimexpr\textwidth-40pt-2\fboxsep\relax}{1pt}%
]

\begin{document}

\chapter{Preliminaries}
\section{Test section}

\end{document}


Since titlesec is used, a warning will be issued by the KOMA classes.

-