2

In the previous question, I tried to ask for one style per chapter. This time I would like to ask for customise the chapter opening. However, my case is a bit complicated, let us see the MWE first.

\documentclass[12pt,a4paper,headinclude,openright]{scrbook}
\usepackage{etoolbox}
\usepackage[usenames,dvipsnames,svgnames,x11names,table]{xcolor}
\usepackage{microtype}
\usepackage{graphicx}
\definecolor{color00}{HTML}{3F3A7D}
\definecolor{color01}{HTML}{660033}
\definecolor{color02}{HTML}{DC143C}
\definecolor{color03}{HTML}{FF4500}
\definecolor{color04}{HTML}{FF8000}
\definecolor{color05}{HTML}{FFD700}
\definecolor{color06}{HTML}{CCCC00}
\definecolor{color07}{HTML}{176C2E}
\definecolor{color08}{HTML}{20B2AA}
\definecolor{color09}{HTML}{00CED1}
\definecolor{color10}{HTML}{1E90FF}
\definecolor{color11}{HTML}{0000CD}
\definecolor{color12}{HTML}{800080}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{backgrounds}
\usetikzlibrary{fit}
\usetikzlibrary{shapes}
\usetikzlibrary{scopes}
\clearscrheadfoot
\usepackage{scrpage2}
\usepackage{tikz}
\lehead{\begin{tikzpicture}[remember picture,overlay]
  \node[
    inner sep=0pt,
    fill=\chapterbackcolor,
    font=\fontsize{40}{48}\selectfont\color{white}\sffamily,
    anchor=north east,
    align=center
    ]
    (chapimage)
    at (current page.north east) 
    {\includegraphics[height=1.5cm,width=3cm]{\hdicons}};
   \node[
     inner sep=0pt,
     anchor=south east,
     font=\color{\chapterbackcolor}\sffamily
   ] 
   (mark)
       at ([xshift=-1em]chapimage.south west) 
       {\rightmark};
       \draw[\chapterbackcolor,line width=1pt] 
     ([xshift=12em]mark.south east) -- ++(-\paperwidth-12em,0);
  \end{tikzpicture}%}
\lohead{\begin{tikzpicture}[remember picture,overlay]
  \node[
    text width=2cm,
    text height=0.5cm,
    text depth=1.5cm,
    fill=\chapterbackcolor!20,
    font=\Large\sffamily,
    anchor=north east,
    align=center
    ]
    {\thepage};
  \end{tikzpicture}}
\lefoot{...}
\rofoot{...}
\pagestyle{scrheadings}
% chapter style
\newcommand\hdicons{}
\renewcommand\hdicons{%
\ifcase\value{chapter}Icon00\or Icon01\or Icon02\or Icon03\or Icon04\else Icon\fi}
\renewcommand\chapterbackcolor{%
\ifcase\value{chapter}color00\or color01\or color02\or color03\or color04\or color05\or color06\or color07\or color08\or color09\or color10\or color11\else color12\fi}
\def\@chapter[#1]{\begin{tikzpicture}[remember picture,overlay]
                  \node(hd)at (current page.north west){\thechapter};
                  \begin{scope}[on background layer]
                  \node[text width=21cm,minimum height=10cm,fill=\chapterbackcolor,fit=(hd)]at(current page.north) {};
                  \end{scope}
              \end{tikzpicture}%
              \ifnum \c@secnumdepth >\m@ne
                     \refstepcounter{chapter}%
                     \typeout{\@chapapp\space\thechapter.}%
                     \addcontentsline{toc}{chapter}%
                               {\protect\numberline{\thechapter}#1}%
                \else
                  \addcontentsline{toc}{chapter}{#1}
                \fi
                \addtocontents{lof}{\protect\addvspace{10\p@}}%
                \addtocontents{lot}{\protect\addvspace{10\p@}}%
                }
\usepackage[listings,theorems,skins,breakable]{tcolorbox}
% for examples
\begin{document}
\frontmatter
\chapter*{Table of contents, figures and tables}
\tableofcontents
\mainmatter
\part{Part ONE}
\chapter{Sample Chapter 1}
\section{Section ONE}
\backmatter
\end{document}

The MWE is about the code I would like customise for a chapter opening. Given that I know in order to change the chapter opening style per each one is by define style variables (e.g. bgcolors etc.), I would like to know the followings:

  • Does \thechapter represents the chapter heading in the opening?
  • I would like to make a background under the chapter heading, how would the MWE modified so makes this possible?

Note:

  • As I am sticking on the koma-script, I would like the answer using the koma-script-compatible packages.
  • Please allow me acknowledge where the code comes from, which are here and here.
SHY.John
  • 427
  • Your MWE is just part of a complete MWE. Would be better if your examples start with \documentclass{...}, finishes with \end {document} and include all relevant (only relevant) packages to show the problem you want to solve. – Ignasi May 30 '14 at 06:39
  • @Ignasi I have edited the MWE, is this possible to solve the question? – SHY.John May 30 '14 at 06:54
  • It's going better, but this is just the preamble, there is no \begin{document} some text where we can test your problem \end{document}. And in any case, it stops working with ! Undefined control sequence. l.26 \clearscrheadfoot. So, something is still missing. – Ignasi May 30 '14 at 09:19
  • @Ignasi I have expanded the MWE, but it is just ordinary chapters and paragraphs (Since I haven't start to author the book yet). Sometimes I prefer to compile it in two clicks, as I occasionally got errors but solved through by compile it again. – SHY.John May 30 '14 at 10:51

1 Answers1

2

While I was waiting someone could answer this question, I could (sort of) figure it out. However, I have to answer some of the questions at first.

Does \thechapter represents the chapter heading in the opening?

I found that this question makes every one confused, while I was experimenting the codes, the \thechapter does nothing with my scope.

I would like to make a background under the chapter heading, how would the MWE modified so makes this possible?

This is the content of while one would like to know about chapter-opening decorations. Should assert that there are may possible choices, this is one of the possibilities.

My option is to use \setchapterpreamble from KOMA-Script and the option o for above the chapter heading. \begin{tikzpicture} therefore can be used inside the command.

A sample page of my new writing

Bonus

  1. Since I experiment not only the decorations of chapter opening, but also the opening of each parts. What I would like to do is to make the double page with an image background and the text color as white. Such as the image below. The MWE is as:

    % changing the font of part heading
    \renewcommand{\partformat}{\textcolor{white}{\partname~\thepart\autodot}}
    \setkomafont{part}{\Huge\bfseries\color{white}}
    \renewcommand*{\partpagestyle}{empty}
    
    % cont'd from above MWE
    % NOTE: the openright option can only switch manually to the left page, depends on the previous page
    \includepdf[openright=false,pages={1}]{Cover04_1}
    \setpartpreamble{%
    \ThisURCornerWallPaper{1.0}{Cover04_2}
    }
    \part{Blah, blah, blah}
    

    As well as the sample image:

    A sample part opening spread of my new writing

  2. As I said, there are many options to do so. However, I have not experimented with these.

Please let me reference the image I have used in here, they are from Flickr by Wendy Piersall.

SHY.John
  • 427