I have a one page document like below. I would like the background color would be green, then I would like change it to yellow. Is it possible?
\documentstyle{article}
\begin{document}
\pagecolor{green}
I would like the background color of the page until here would be green.\\
\pagecolor{yellow}
Then from now on, I would like the background would be yellow.
\end{document}
Best Answer
A command, which changes the page color from the current position does not need to know the exact location. Instead a large colored rectangle can be drawn. The following example moves
\paperwidth
to the left and draws a rectangle with width2\paperwidth
and height\paperheight
. This covers the whole of the remaining page regardless of the current position on the page. An additional LaTeX run is not needed.After drawing the rectangle,
\pagecolor
is used inside\afterpage
to also get the real page color changed.The command
\changepagecolor
supports the full syntax of\color
or\pagecolor
including the optional argument.