TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to set the background color specifically for the page created for each "Part" section in my document (e.g. Part I xxx, Part II xxxx). I am using the book document class. Solutions for setting (and resetting) the background colour were not able to specifically color the page with Part I xxxx on it, but also coloured the page after that.



First page

\part{Example for pagecolor}

Last page

The "Part" page and the page following it are both colored green.

share|improve this question
Welcome to TeX.SX. Note that you don't have to sign with your name since it automatically appears in the lower right corner of your post. Usually, we don't put a greeting or a "thank you" in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Upvoting is the preferred way here to say "thank you" to users who helped you. – Claudio Fiandrino Jan 22 '13 at 16:25
related question how-to-change-the-background-color-only-for-the-current-page? – Kurt Jan 22 '13 at 21:40

You can patch the part command to add the page color instead of adding it manually. But since a newpage is issued at the end of \part internally (when openright option is used (default)) the page color is applied to the next page also. This can be avoided by patching the \@endpart command. You can do it the hard way or the smart way as shown in the following code.

%%-----------------Hard coding----------------------
%  \if@openright
%    \cleardoublepage
%  \else
%    \clearpage
%  \fi
%  \pagecolor{green}   %% Added line here
%  \thispagestyle{plain}%
%  \if@twocolumn
%    \onecolumn
%    \@tempswatrue
%  \else
%    \@tempswafalse
%  \fi
%  \null\vfil
%  \secdef\@part\@spart}

%                \pagecolor{white}   %%% Added line here
%              \if@twoside
%               \if@openright
%                \null
%                \thispagestyle{empty}%
%                \newpage
%               \fi
%              \fi
%              \if@tempswa
%                \twocolumn
%              \fi}
%%--------- end of hard coding ---------------------

%%---smart coding ----------------------------------
%%--------- end of smart coding ---------------------

First page

\part{Example for pagecolor}

Last page

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.