With the code below:

hello world

I get the build error:

! LaTeX Error: Command \lhead already defined.
           Or name \end... illegal, see p.192 of the manual.

I need to manually set the header and foot in my page using fancyhdr. So is there any way to disable the header and foot setting in exam class?

1 Answer 1


The exam class has its own built-in fancy formatting of headers and footers. Since both the exam class and fancyhdr package use the same names for defining the headers and footers, you get the clash.

You can get the details on how to define headers and footers in the exam class in section 11 of the package document, titled Headers and footers.

So, without disabling the header and footer in exam class, it would be better to use the commands of that class. Since the basic concept is very similar to fancyhdr, you will not face much difficulty in mastering the techniques.

For the impatient, some quick examples are:

\lhead{CSE 101}
\chead[\bfseries\large Midterm Examination]{}
\rhead[January 01, 2020]{Midterm Examination Continued}

\rfoot[]{Page \thepage\ of \numpages}
  • Thanks, MMA. I solve my problem by reading the exam class documents.
    – ollydbg23
    Commented Oct 30, 2013 at 9:06

You must log in to answer this question.

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