[Tex/LaTex] Double line for header/footer rules

examfancyhdrheader-footerrules

I want to create a fancy header/footer rule in Exam document class. I have tried what is at https://tex.stackexchange.com/questions/89569/custom-header-footer-rules-fancyhdr and Custom header/footer rules (fancyhdr?) but they seem not to work in Exam document class. Any help please

Best Answer

exam.cls uses its own mechanism for headers/footers. To modify the default rules in headers, you can patch \@fullhead (for the first page) and \run@fullhead (for other pages) to use whatever you choose, instead of the default \hrule. A little example using a double rule:

\documentclass{exam}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\@fullhead}{\hrule}{\hrule\vskip2pt\hrule height 2pt}{}{}
\patchcmd{\run@fullhead}{\hrule}{\hrule\vskip2pt\hrule height 2pt}{}{}
\makeatother

\pagestyle{headandfoot}
\runningheadrule
\firstpageheadrule
\firstpageheader{Math 115}{First Exam}{July 4, 1776}
\runningheader{Math 115}
{First Exam, Page \thepage\ of \numpages}
{July 4, 1776}
\firstpagefooter{}{}{}
\runningfooter{}{}{}

\begin{document}
test\clearpage
test
\end{document}

enter image description here

In the case of footers, one has to patch \@fullfoot and \run@fullfoot and invoke \runningfootrule, \firstpagefootrule.