[Tex/LaTex] How to change the background color only for the current page

backgroundscolor

How can I change the background color only for the current page? I found that I can change the color with \pagecolor{color} but that unfortunately changes the color for all pages after this command. Any ideas how to limit this command only to the current page?

Best Answer

You could use the \afterpage command from the afterpage package to change the color back.

Here's an example:

\documentclass{article}
\usepackage{lipsum}% for auto generating text
\usepackage{afterpage}
\usepackage{xcolor}
\begin{document}
\lipsum[1-12]
\pagecolor{yellow}\afterpage{\nopagecolor}
\lipsum[22-30]
\end{document}