1

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!

  • 1
    Indeed, titlesec and KOMA classes are not fully compatible. – Gonzalo Medina Feb 28 '15 at 15:02
  • Thank you, do you know a better option? At the time the formatting is working and does not produce any further errors. Thus I decided to stick along with this package. Can you help me to find a possibility to change the colors as I wrote above? – Arne H. Feb 28 '15 at 15:08
  • The better option is to use the commands provided by KOMA rather than a package which breaks KOMA. See Sveinung's comment below. – cfr Feb 28 '15 at 15:56
7

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}
  • Thank you for this suggestion! Unfortunately I don't use Version 3.15 but an older version. Would it be possible to rearrange your example to make it compatible with older KOMA-Script-Versions? – Arne H. Feb 28 '15 at 17:01
  • I found another interesting layout on Stack-Exchange: tex.stackexchange.com/questions/194163/…. The thread is closed but I would be interested to find a solution to create this layout for the scrbook-class. – Arne H. Feb 28 '15 at 17:44
  • Which KOMA-Script version do you use? The current version on CTAN and in TeX Live is 3.16. In MiKTeX it is 3.15. I have added an example that should work with an older version. – esdd Mar 1 '15 at 7:18
  • Thank you for the second example, esdd! It works very well and it's operating characteristics do not collide with any KOMA-class features. I downloaded MikTeX about one year ago and did no updates. I dont really know which KOMA-Script version I use, but I suggest it is a really old one :D. Thanks again for your quick and well done help! Arne H. – Arne H. Mar 1 '15 at 12:24
0

I found a solution to achieve the coloring of all elements: I just added \color{myblue} with a predefined color to the settings of the fonts.

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

The next formatting thing I would like to apply is a smaller distance from the heading to the top of the page. Does anyone know how to achieve this?

Thanks for your help again!

  • 1
    If you are using KOMA-Script, why are you not using the very advanced build in formatting commands. setkomafont, addtokomafont etc. As you will see from the manual, titlesecis not compatible. Colouring all heading: \addtokomafont{disposition}{\color{myblue}} – Sveinung Feb 28 '15 at 15:52
  • @Sveinung: Thanks for your answer. As I wrote above I am not that experienced in using TeX. Could you provide a minimal example which shows that it would be possible to achieve the same result for the chapter headings with "setkomafont" etc? – Arne H. Feb 28 '15 at 16:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.