I'm typesetting a proceedings-style book that contains articles in their chronological order. Since the articles are also categorized, each category is assigned a color and the the chapter styles are supposed to use that color as background color for some fancy chapter art. This part works as expected with titlesec.
In addition to that, I'd like to also change the color of the headings, which should be the same "chapter color" for the current chapter.
The problem I observe with my naive approach is that the headings color is changed too early, i.e. the page before the new chapter is already printed with the new color.
Here is a MWE:
\documentclass[fontsize=12pt, paper=a4]{scrbook}
\usepackage[ngerman]{babel}
\usepackage{blindtext}
\usepackage[automark]{scrpage2}
\usepackage{xcolor}
\newcommand{\chaptercolor}{red}
\clearscrheadfoot
\pagestyle{scrheadings}
\ihead[\color{\chaptercolor}\leftmark]{\color{\chaptercolor}\leftmark}
\ohead[\color{\chaptercolor}\rightmark]{\color{\chaptercolor}\rightmark}
\cfoot[\color{\chaptercolor}\pagemark]{\color{\chaptercolor}\pagemark}
\begin{document}
\renewcommand{\chaptercolor}{blue}
\chapter{Ch1}
\Blindtext
\renewcommand{\chaptercolor}{green}
\chapter{Ch2}
\Blindtext
\end{document}
As you can see, on page 2 the heading is already green although this page still belongs to chapter 1, which is supposed to be blue.
What I also tried was to use two different variables (headercolor and chaptercolor), where I used \headercolor in the *head statements and used titlesec's \titelformat to assign the chaptercolor to the headercolor only when the chapter title itself is set. Unfortunately this didn't work either.
Update: I'm looking for a preamble solution. The MWE oversimplifies my current script and since the color is also used in the chapter title itself, it is important that the chapter color is defined before the chapter starts. I'd like to keep this kind of "interface" as stable as possible so that authors don't need to mess with details.
Any advise on how I can lazily set the color so that the color change in the headings happens only on the very first page of the new chapter is highly appreciated. Thanks!





\clearpagebeforehand or swap the colorchange afterchapter. – Johannes_B Sep 24 '14 at 08:28scrpage2calledscrlayer-scrpageallows to set backgroundcolors in easy way (there is an example in the documentation for yellow headers). You might find background colors with black text more readable. – Johannes_B Sep 24 '14 at 08:30fancyhdrmanual? – Sep 24 '14 at 09:32titlesecdoesn't work that well together with KOMA. You should receive a\Hugewarning. – Johannes_B Sep 24 '14 at 16:52titlesec: indeed I see a warning. Do you have pointers to a nice way to replace the default KOMA chapters by a custom tikz chapter style? – vanto Sep 24 '14 at 17:59