# Modify the chapter opening

I need help in the following, I am trying to make all pages facing the chapter openings contain a gray of x% when they do not contain text (exclusive condition) only for the mainmatter section. The frontmatter and the backmatter are excluded from this condition.

the image below shows the result in two openings

I get this result by reviewing the opening of each chapter and placing the instruction at the end of the chapter

\pagecolor{black!10}

and then at the beginning of the chapter

\pagecolor{white}

to retake the color white

But what I am looking for is that this can be achieved automatically, since it is common to modify the texts and the box widths, which leads to having to constantly check the chapter openings

• Please show us a short compilable code (that is usual here!) we can play with ... – Kurt Jan 9 at 1:31

Something like this?

\documentclass{book}

\usepackage{blindtext}
\usepackage{xcolor}

%% Adapted from fancyhdr, section 14
%% http://ctan.triasinformatica.nl/macros/latex/contrib/fancyhdr/fancyhdr.pdf
\makeatletter
\renewcommand*{\cleardoublepage}{\clearpage\if@twoside \ifodd\c@page\else
\hbox{}\pagecolor{black!10}%
\thispagestyle{empty}%
\newpage%
\if@twocolumn\hbox{}\newpage\fi\fi\fi\pagecolor{white}}
\makeatother

\begin{document}
\chapter{One}
\blindtext\blindtext

\chapter{Two}
\blindtext\blindtext

\chapter{Three}
\blindtext\blindtext

\end{document}