In this one-sided document, insert the
\clearpage
command before changing the page style, so that the changed style will only take effect from the new chapter.
Since the page style of the first page of each chapter is set to
plain
, the style selected by pagestyle is not set until the second chapter page.
A suggestion:
Code: Select all
\documentclass{report}
\usepackage{etoolbox}
\newcommand*{\name}{plain}
% If the selected style should also apply to the first chapter page.
%\patchcmd{\chapter}{plain}{\name}{}{}
% or
%\patchcmd{\chapter}{\thispagestyle{plain}}{}{}{}
\begin{document}
\pagestyle{\name}
\chapter{\name}
Some stuff.
\newpage
{\Huge \name}
\clearpage% added
\renewcommand*{\name}{headings}
\pagestyle{\name}
\chapter{\name}
Some stuff.
\newpage
{\Huge \name}
\clearpage% added
\renewcommand*{\name}{empty}
\pagestyle{\name}
\chapter{\name}
Some stuff.
\newpage
{\Huge \name}
\end{document}
If I am right with my assumption concerning the first chapter page, it should work even much shorter:
Code: Select all
\documentclass{report}
\usepackage{etoolbox}
\newcommand*{\name}{plain}
% If the selected style should also apply to the first chapter page.
\patchcmd{\chapter}{\thispagestyle{plain}}{\pagestyle{\name}}{}{}
\begin{document}
\pagestyle{\name}
\chapter{\name}
Some stuff.
\newpage
{\Huge \name}
\renewcommand*{\name}{headings}
\chapter{\name}
Some stuff.
\newpage
{\Huge \name}
\renewcommand*{\name}{empty}
\chapter{\name}
Some stuff.
\newpage
{\Huge \name}
\end{document}
The source code I replaced can be found in the
report.cls
file.