I want to change the definition of \chapter[...]{...}
to \chapter[...]{...}\thispagestyle{empty}
. To do this, I'm using the code below:
\documentclass{book}
\let\origchapter\chapter
\renewcommand{\chapter}[2][]{%
\origchapter[#1]{#2}
\thispagestyle{empty}
}
\begin{document}
\tableofcontents
\chapter{Bla Bla}
Some text ...
\newpage
\chapter{Bla Bla}
\end{document}
Everything is ok, but when I call \tableofcontents
after the \begin{document}
, I'll get the following error:
! LaTeX Error: Something's wrong--perhaps a missing \item.
What am I doing wrong?
Best Answer
Addition to Werner's answer.
Unknown
\chapter
The definition of
\chapter
might not contain\thispagestyle{empty}
, because it is hidden in later called macros or this action looks different. Then the patching as in Werner's answer will fail, because{plain}
is missing in the definition text of\chapter
. Therefore the following example provides a generic solution, it redefines\chapter
with support of the star form and the optional argument:KOMA-Script
The
KOMA-Script
classes uses the following definition for\chapter
:It misses
plain
, because it is replaced by\chapterpagestyle
. However, this macro can be redefined, no need for redefining\chapter
:Class
memoir
Chapters in
memoir
support a special page stylechapter
:The page style can be changed by
\aliaspagestyle
:Full example
The following example catches five cases:
\chapter
is not available.memoir
.KOMA-Script
classes.etoolbox
's\patchcmd
(see Werner's answer).\chapter
.The code: