This code is inspired by the elegant article class designed by Harvey Sheppard.
I wanted to be able to change the image on the chapter title pages. In the code given below, I currently have just the odd page chapter title image change. I wanted to be able to put a new image each time on each chapter title page. Can you help me to accomplish this task? Thanks!
Here is the code: (A little beyond a MWE)
\documentclass[a4paper, 10pt, fleqn, openany, twoside]{report}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Basic settings, options processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage[l2tabu, orthodox]{nag}
\RequirePackage{polyglossia}
\setdefaultlanguage{english}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Needed packages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage[final=true,step=1]{microtype}
\RequirePackage{graphicx}
\RequirePackage{calc}
\RequirePackage[usenames,dvipsnames,svgnames,table]{xcolor}
\RequirePackage{ragged2e}
\RequirePackage{eso-pic}
\RequirePackage{fancyhdr}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Layout
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{changepage}
\patchcmd{\part}{\thispagestyle{plain}}{\thispagestyle{empty}}{}{\errmessage{Cannot patch \string\part}}
\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\setlength{\marginparpush}{1.5\baselineskip}
\RequirePackage[
xetex,
a4paper,
% showframe,
twoside,
top=27mm,
bottom=27mm,
inner=20mm,
outer=20mm,
ignorehead,
ignorefoot,
includemp,
marginparwidth=52mm,
marginparsep=8mm,
headsep=7mm,
footskip=14mm,
headheight=12.2pt,
]{geometry}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Colors
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{mainColor}{RGB}{211, 47, 47}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Utilities
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareDocumentCommand{\isOddPage}{mm}{%
\strictpagechecktrue%
\checkoddpage%
\ifoddpage%
#1%
\else%
#2%
\fi%
}
\DeclareDocumentCommand{\alignLeftOrRight}{O{} O{}}{%
\strictpagechecktrue%
\checkoddpage%
\ifoddpage%
\begin{FlushRight}%
#1%
\else%
\begin{FlushLeft}%
#2%
\fi%
}
\DeclareDocumentCommand{\alignLeftOrRightEnd}{O{} O{}}{%
\strictpagechecktrue%
\checkoddpage%
\ifoddpage%
\end{FlushRight}%
#1%
\else%
\end{FlushLeft}%
#2%
\fi%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Titling
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{titlesec}
\titleformat{\chapter}[block]
{} % format
{ % label
\backgroundThisPageColor%
\isOddPage{%
\begin{tikzpicture}[remember picture, overlay]
\coordinate[xshift=-\bigVerticalLineWidth/2, yshift=-5.8cm] (numberCenter) at (current page.north east);
\draw[White] (numberCenter) node{
\fontsize{6.5cm}{7.8cm}\selectfont
\color{White}
\thechapter
};
\end{tikzpicture}%
}{%
\begin{tikzpicture}[remember picture, overlay]
\coordinate[xshift=\bigVerticalLineWidth/2, yshift=-5.8cm] (numberCenter) at (current page.north west);
\draw[White] (numberCenter) node{
\fontsize{6.5cm}{7.8cm}\selectfont
\color{White}
\thechapter
};
\end{tikzpicture}%
}
}
{0pt} % sep
{ % code before
\isOddPage{
\begin{FlushRight}
\vspace*{-1.5mm}
}{
\begin{FlushLeft}
\vspace*{-10mm}
}
\fontsize{2.5cm}{3cm}\selectfont%
}[ % code after
\alignLeftOrRightEnd
]
\titleformat{name=\chapter, numberless}[block]
{} % format
{\backgroundThisPageColor} % label
{0pt} % sep
{ % code before
\alignLeftOrRight
\fontsize{2.5cm}{3cm}\selectfont
}[ % code after
\alignLeftOrRightEnd
]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TikZ
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{tikz}
\usetikzlibrary{fit}
\usetikzlibrary{calc}
\usetikzlibrary{matrix}
\pgfdeclarelayer{bg} % declare background layer
\pgfsetlayers{bg,main} % set the order of the layers (main is the standard layer)
\newlength{\bigVerticalLineWidth}
\setlength{\bigVerticalLineWidth}{\evensidemargin + 1in + \hoffset}
\newlength{\bigVerticalLinePartOfMarginParSep}
\setlength{\bigVerticalLinePartOfMarginParSep}{\marginparsep/8}
\setlength{\bigVerticalLinePartOfMarginParSep}{5\bigVerticalLinePartOfMarginParSep}
\addtolength{\bigVerticalLineWidth}{-\bigVerticalLinePartOfMarginParSep}
\newcommand{\bigVerticalLine}[1]{
\strictpagechecktrue
\checkoddpage
\ifoddpage%
\AddToShipoutPictureBG*{
\begin{tikzpicture}[remember picture, overlay]
\fill[fill=#1] (current page.south east) rectangle ++(-\bigVerticalLineWidth, \paperheight);
\end{tikzpicture}
}
\else%
\AddToShipoutPictureBG*{
\hspace{-2.6pt}\includegraphics[width=7.7cm,height=\paperheight]{example-image-a}}
\fi%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Backgrounding commands
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Vertical lines
\newcommand{\backgroundThisPageGrey}{\bigVerticalLine{bigVerticalLineGrey}}
\newcommand{\backgroundThisPageColor}{\bigVerticalLine{mainColor}}
% Entire page area
\newcounter{background}[page]
\renewcommand{\thebackground}{\arabic{page}-\arabic{background}}
\DeclareDocumentCommand{\startBackgroundPageTop}{O{\thebackground}}{\begin{tikzpicture}[overlay, remember picture]%
\node at (current page.north west) {\backgroundAnchor{begin-#1}};
\end{tikzpicture}}
\usepackage{lipsum}
\begin{document}
\chapter{Introduction}
\lipsum[2]
\chapter{Content}
\lipsum[2]
\lipsum[3]
\section{First Section}
\subsection{Subsection}
\lipsum[2]
\end{document}
