[Tex/LaTex] Formatting and Styling of Headers using titlesec in scrbook-class

formattingscrbooktitlesec

I'm trying to write a book in LaTeX with scrbook class. I'm not that experienced in typography with TeX, nevertheless I would like to give my chapter-headings a special style. I found a very nice style here: http://www.bradleymedia.org/latex-chapter-headings.

I was able to reproduce the style in my document, but I couldn't add some coloring and spacing I would like the header to have. My question is now, how to add a specific color to the "chapter", the chapter number, the line on the right side and the chapter title?

The code I would like to use for this is: (I hope this minimal example works :D)

\documentclass[a4paper]{scrbook}

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}

\title{Your Paper}
\author{You}

\usepackage{titlesec}
\usepackage{graphics}

\titleformat{\chapter}[display]
    {\normalfont\Large\raggedleft}
    {\MakeUppercase{\chaptertitlename}%
    \rlap{ \resizebox{!}{1.2cm}{\thechapter} \color{blue}\rule{15cm}{1.2cm} } }
    {10pt}{\Huge}

\titlespacing*{\chapter}{0pt}{30pt}{20pt}

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

As you can see I found an option to change the color of the line on the left. But I don't know how to change the color of the other elements in this header.

(Another small problem: A warning-message occurs when I use titlesec with KOMA scrbook).

Thanks to everyone who an help me to solve this problem!

Best Answer

Here is a suggestion without titlesec. Note, that the code needs KOMA-Script version 3.15 or newer.

\documentclass[a4paper,chapterprefix]{scrbook}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}

\colorlet{chaptercolor}{blue!80!black}

\setkomafont{chapter}{\normalfont\color{chaptercolor}\Huge}
\setkomafont{chapterprefix}{\Large}
\renewcommand*{\raggedchapter}{\raggedleft}
\renewcommand*{\chapterformat}{%
  \MakeUppercase{\chapappifchapterprefix{}}%
  \rlap{\enskip\resizebox{!}{1.2cm}{\thechapter} \rule{15cm}{1.2cm} }%
}

\RedeclareSectionCommand[beforeskip=30pt,afterskip=20pt]{chapter}
\renewcommand*\chapterheadmidvskip{\par\nobreak\vspace{10pt}}

%\usepackage{showframe}% to show the page layout
\usepackage{blindtext}% dummy text
\begin{document}
\blinddocument
\end{document}

enter image description here


With an older KOMA-Script Version you can try the following code to get a similar result.

\documentclass[a4paper,chapterprefix]{scrbook}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{xcolor}

\colorlet{chaptercolor}{blue!80!black}

\setkomafont{chapter}{\normalfont\color{chaptercolor}\Huge\raggedleft}
\setkomafont{chapterprefix}{\Large}
\renewcommand*{\chapterformat}{%
  \makebox[\linewidth][r]{\MakeUppercase{\chapappifchapterprefix{}}}%
  \rlap{\enskip\resizebox{!}{1.2cm}{\thechapter} \rule{15cm}{1.2cm} }%
}

\renewcommand*\chapterheadstartvskip{\vspace{20pt}}
\renewcommand*\chapterheadendvskip{\vspace{20pt}}

%\usepackage{showframe}% to show the page layout
\usepackage{blindtext}% dummy text
\begin{document}
\blinddocument
\end{document}