I'm looking for a way to change the page color of a float page. I'm using the [p]
placement for the respective figure. Consider the following MWE:
\documentclass{scrbook}
\usepackage{afterpage}
\usepackage{pagecolor}
\begin{document}
Text on a clean page. %The page is white by default.
\clearpage
Text before figure. %This page is red already.
\begin{figure}[p]
\pagecolor{red}\afterpage{\pagecolor{none}}
Figure text.
\end{figure}
Text after figure.
\clearpage %The float is placed, \afterpage kicks in and restores the page background
Again, text on a clean page.
\end{document}
The \pagecolor
command is carried out as soon as the float is reached in the source, so all the pages up to the float are already red. This question kind of deals with the same problem, however its solution hooks to any float page shipped out. I only want the colored background for certain float pages, not all of them. How can I change the page color for only a certain float page?
(Given the referenced question and solution, I was thinking of adding a conditional that must be set for \AddToShipoutPictureBG
to change the background, which I could set when I want a colored float page. But it seems inelegant and just too hacky...)