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?

  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries \@chapapp\space \thechapter
        \vskip 20\p@
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@

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.

1 Answer 1


Inside the definition of \appendix, #1 would be the first parameter of \appendix that does not exists, \appendix is defined without parameters. For the parameters of a definition inside a definition you need to double the hash char:

    ... ##1 ...

If \@makechapterhead contained another definition with a parameter, then #### would be needed for the inner parameter.

  • 1
    This really helped me with the todonotes package. If you want \todo{Here is some \lstinline{SomeClass#SomeMethod}}, you have to escape the # or todonotes gets confused e.g. \todo{Here is some \lstinline{SomeClass\#SomeMethod}}. HTH future travelers
    – Hamy
    Aug 26, 2013 at 14:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .