I am using the report class. And all I want that after the use of \chapter{...}
the marco \thispagestyle{onlypagenumber}
is added.
I fixed this with just defining a new macro \Chapter{...}
\newcommand{\Chapter}[1]{\chapter{#1}\thispagestyle{onlypagenumber}}
However I would rather like to still use \chapter{...}
since people are used to typing \chapter{...}
instead of \Chapter{...}
. How can I make this small alteration? Note also that \thispagestyle{onlypagenumber}
should not be added to star chapters e.g. \chapter*{...}
I tried also using the etoolbox which provides the some of "appto" commands on page 9.
\appto This command appends arbitrary hcodei to a hhooki. If the hcodei contains any parameter characters, they need not be doubled. This command is robust.
This failed however but probably I am doing something wrong. I would prefer a solution of the etoolbox.
Example
\documentclass{book}
\usepackage{fancyhdr}
\usepackage{lipsum}
\fancypagestyle{onlypagenumber}{%
\fancyhf{}
\fancyhfoffset[RO,EL]{2.5cm}
\fancyhead[OR]{%
\sffamily
\quad\smash{\rule[-.2ex]{1pt}{4cm}}\quad
\thepage
}
\fancyhead[EL]{%
\sffamily\thepage
\quad\smash{\rule[-.2ex]{1pt}{4cm}}\quad
}
}
\pagestyle{fancy}
\fancyhf{}
\fancyhfoffset[OR,EL]{2.5cm}
\fancyhead[OR]{%
\sffamily\MakeUppercase{\leftmark}
\quad\smash{\rule[-.2ex]{1pt}{4cm}}\quad
\thepage
}
\fancyhead[EL]{
\sffamily\MakeUppercase{\thepage}
\quad\smash{\rule[-.2ex]{1pt}{4cm}}\quad
\MakeUppercase{\chaptername}~\thechapter
}
\renewcommand\headrulewidth{0pt}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{#1}}{}}
\newcommand{\Chapter}[1]{\chapter{#1}\thispagestyle{onlypagenumber}}
\begin{document}
\Chapter{Test chapter}
\lipsum[1-40]
\end{document}