1

I found that I can change current pagecolor with

\newpagecolor{color}\afterpage{\restorepagecolor}

so I tried to use

\newpagecolor{color}\newpagecolor{color}\afterpage{\restorepagecolor},

that unfortunately changes the color for all pages after this command. Any ideas how to limit this command only to the current and the next page?

1
  • The second \newpagecolor{color} after \newpagecolor is wrong since the restore color is overwritten with that value, so if the previous colour was white, and \newpagecolor{red} is used, then \restorepagecolor would restore to white, since this is the previous color information. \newpagecolor{red}\newpagecolor{red} would first save white, but then then 2nd usage would save red, so \restorepagecolor would restore to red for the rest of the document (or until another \newpagecolor is used)
    – user31729
    Oct 15, 2017 at 7:18

1 Answer 1

3

Set the page colour, and then \restore it using a nested \afterpage:

enter image description here

\documentclass{article}

\usepackage{pagecolor,afterpage}
\usepackage{lipsum}

\begin{document}

\lipsum[1-20]
\newpagecolor{red}
\afterpage{\afterpage{\restorepagecolor}}
\lipsum[1-40]

\end{document}

Exactly the same approach can be followed using xcolor's \pagecolor command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .