I'm trying to redefine the \appendix
command so that my appendix headings go to the top of the pages. To do this, I tried the following code, but I get the error ! Illegal parameter number in definition of \appendix
. Why am I getting this error and how to get rid of it?
\documentclass{book}
\makeatletter
\renewcommand\appendix{\par
\def\@makechapterhead#1{%
\vspace*{0\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\setcounter{chapter}{0}%
\setcounter{section}{0}%
\gdef\@chapapp{\appendixname}%
\gdef\thechapter{\@Alph\c@chapter}}
\makeatother
\begin{document}
\appendix
\chapter{Foo}
\end{document}
Please keep in mind that, I know that a solution is to put the redefinition of the \@makechapterhead
at the beginning of the \appendix
command in the document body, but I want to do the job in the preamble. Also, I'd prefer not to use extra packages to do the job.