Using afterpage to set a page style after some page only works for \thispagestyle, but not for \pagestyle. Why is that? How can I make it work?
\lipsum[1-20] produces 4 pages of text, Lorem Ipsum style. So, the following document consists of 8 pages.
\documentclass{article}
\usepackage{fancyhdr,afterpage,lipsum}% http://ctan.org/pkg/{fancyhdr,afterpage,lipsum}
\fancypagestyle{pagestyleA}{
\fancyhf{}% Clear header/footer
\fancyhead[C]{pagestyleA}% Header
\fancyfoot[C]{A--\thepage}% Footer
}
\fancypagestyle{pagestyleB}{
\fancyhf{}% Clear header/footer
\fancyhead[C]{pagestyleB}% Header
\fancyfoot[C]{B--\thepage}% Footer
}
\pagestyle{empty}
\begin{document}
\afterpage{\thispagestyle{pagestyleA}}\lipsum[1-20]
\clearpage
\afterpage{\pagestyle{pagestyleB}}\lipsum[1-20]
\end{document}
Using \afterpage{\thispagestyle{pagestyleA}} at the start prints page 2 with page style pagestyleA.

It is expected that the second \afterpage{\pagestyle{pagestyleB}} should deliver pages 6-8 with page style pagestyleB. However, it does nothing...

\afterpageis processed in a group. The difference is that\thispagestyleacts globally, while\pagestyledoesn't. – egreg Dec 06 '12 at 07:54