I want to achieve two related designs for the chapter heading. Design 1 should have a vertical line at the outer (right) margin which has the chapter (or appendix) name and the title to the left and the chapternumber to the right in the margin. Design two is nearly the same but with an additional shaded colorbox for the chaptertitle.
Design 1
I started with this code and modified it the following way:
\documentclass[%
fontsize=11pt,%
chapterprefix=false,
numbers=noenddot,
]{scrbook}
\usepackage{xcolor}
\definecolor{chaptercolor}{cmyk}{.48, .05, .91, 0}
\renewcommand*{\chapterformat}{%
\smash{\textcolor{chaptercolor}{\rule[-5pt]{2pt}{10cm}}}%
\enspace
\textcolor{chaptercolor}{\fontsize{70pt}{60pt}\selectfont\rlap{\mdseries\thechapter\autodot}}%
}
\renewcommand*\chapterlinesformat[3]{%
\parbox[b]{\dimexpr\textwidth-0.5em\relax}{
\raggedleft{
\textcolor{chaptercolor}{\large\scshape\chapapp}
\par
\Huge\bfseries#3}
}%
\hfill
\makebox[0pt][l]{#2}%
}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\chapter{Chapter One}
\blindtext
\chapter{Chapter Two with a very long title to see how the heading looks with a linebreak}
\blindtext
\appendix
\chapter{First Appendix}
\blindtext
\end{document}
This shows what I get on the left side and what I want at the right side (I added some pink and blue lines for orientation).
As you can see, the short chaptertitle is perfect as I want it. The number is on the (blue) bottom line of the chaptertitle and a little higher than the (pink) top line of the chapterprefix. For long chaptertitles I would like to have the number aligned to the blue line, too, which should be the bottom of the first line.
For the unnumbered chapters, the vertical line is missing. In addition, I couldn't manage to remove the chapterprefix from the unnumbered chapters. When I use \chapappifchapterprefix
instead of \chapapp
I get error warnings. If I use chapterprefix=true
the whole layout gets messed up. The same happens, when I try to add the \chapapp
into the \chapterformat
definition.
Design 2
I tried to include the colorbox into Design 1 the following way:
\documentclass[%
fontsize=11pt,%
chapterprefix=false,
numbers=noenddot,
]{scrbook}
\usepackage{xcolor}
\usepackage[framemethod=TikZ]{mdframed}
\definecolor{chaptercolor}{cmyk}{.48, .05, .91, 0}
\newmdenv[
innertopmargin=\topskip,
hidealllines=true,
skipabove=0pt,
skipbelow=0pt,
apptotikzsetting={\tikzset{
mdfframebackground/.append style={
shade,
left color= white,
right color=chaptercolor,
}}},
]{chapterbox}
\tikzset{
headings/base/.style = {
outer sep = 0pt,
inner sep = 5pt,
align = left,
text = white,
},
headings/chapter/.style = {
headings/base,
shade,
left color= white,
right color=chaptercolor,
font = \Huge\bfseries,
align=right,
text = black,
},
}
\newcommand{\newcolorboxedsec}[1]{%
\tikz{\node[headings/chapter]{#1};}}
\renewcommand*{\chapterformat}{%
\smash{\textcolor{chaptercolor}{\rule[-5pt]{2pt}{10cm}}}%
\enspace
\textcolor{chaptercolor}{\fontsize{70pt}{60pt}\selectfont\rlap{\mdseries\thechapter\autodot}}%
}
\renewcommand*\chapterlinesformat[3]{%
\parbox[b]{\dimexpr\textwidth-0.5em\relax}{
\raggedleft{
\textcolor{chaptercolor}{\large\scshape\chapapp}
}\par
\tikz{\node[headings/chapter]{#3};}
}%
\hfill
\makebox[0pt][l]{#2}%
}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\chapter{Chapter One}
\blindtext
\chapter{Chapter Two with a very long title to see how the heading looks with a linebreak}
\blindtext
\appendix
\chapter{First Appendix}
\blindtext
\end{document}
And again what I get on the left side and what I want on the right side with some orientation lines.
The short numbered chapter is quite close to what I want. But I don't know how to align the box and the vertical line and spread the box onto the left margin. (I never worked with tikz before.) Ans I also wonder why the box color is brighter and hence different from the chaptercolor
I defined.
For unnumbered chapters and long chapters the same problems as for Design 1 persist. The number of long chapters should be at the same height as in short chapters, which this time is the (pink) baseline of the box (or the bottom line of letters like 'g' or 'p').
I would really appreciate if someone could help me fix these two designs. Thank you!