Greetings to the community!
My goal is to create the pdflatex
document using the memoir
class, which would have \chapter
s, \section
s, and \subsection
s have the following formatting (font is not important, placing heading on the colored background is important):
i.e. the \chapter*{Features}
has a colored background spread across the linewidth, and if there is a number, it is on the colored background as well.
After a bit of googling, I got smth like:
\renewcommand\chaptitlefont{%
\huge\bfseries%
\leavevmode\color{white}%
}
\renewcommand\printchapternum{
\huge\bfseries%
\leavevmode\color{white}%
{\thechapter}
}
with combination of defining chapter like this:
\chapter*{\colorbox{my-blue}{\strut\rlap{\textbf{Executive Summary}}\hspace{\linewidth}\hspace{-2\fboxsep}}}
Which results in the followings:
- The chapter title with a hack:
- ToC (white text over white background, I selected some of ):
My hack has the following problems:
Titles of the chapters that I do not create explicitly (e.g. Contents) have white font over white background;
Titles of the chapters that I do name explicitly in ToC got also blue background, which is not desired.
Chapter titles do not include the Chapter number. Instead of
Introduction
andSyntax
(i.e. all the chapters created with\chapter
) as a chapter title, my goal is to have1 Introduction
,2 Syntax
,3 Semantics
(when using\chapter
opposite to\chapter*
)
My questions are as follows:
How would I create the chapter titles, that have background color spanned over chapter title text, including chapter number.
How in this case (1) keep the formatting of chapters that I do not name explicitly (e.g. Contents, List of Figures, List of Tables, etc.) consistent?
How to avoid that the background color is also shown in the ToC?
Thanks in advance for any help / pointers!
The minimal example is below:
\documentclass[a4paper,12pt,oneside]{memoir}
\usepackage[english]{babel}
\usepackage{xcolor}
\definecolor{my-blue}{RGB}{0,150,226}
\renewcommand\chaptitlefont{%
\huge\bfseries%
\leavevmode\color{white}%
}
\renewcommand\printchapternum{
\huge\bfseries%
\leavevmode\color{white}%
{\thechapter}
}
\begin{document}
\frontmatter
\pagenumbering{arabic}
\tableofcontents*
\clearpage
\chapter*{\colorbox{my-blue}{\strut\rlap{\textbf{Summary}}\hspace{\linewidth}\hspace{-2\fboxsep}}}
\chapter{\colorbox{my-blue}{\strut\rlap{\textbf{Introduction}}\hspace{\linewidth}\hspace{-2\fboxsep}}}
\chapter{Syntax}
\chapter{Semantics}
\end{document}