The normal way of dealing with different headers and footers on different pages is to use "page styles". The fancyhdr package allows you to re-define page styles like "plain". See, e.g., page 7 of its documentation. Since you're putting this into the documentclass itself, you could use \AtBeginDocument to set the pagestyle to plain for the first page. This would eliminate the need for most of your conditionals as well. E.g., something like this:
Code: Select all
% Setup the header and footer
\RequirePackage{fancyhdr}
%make the first page plain style
\AtBeginDocument{\thispagestyle{plain}}
% redefine plain style
\fancypagestyle{plain}{
\fancyhead[L]{%
\test@semester \hspace{15mm} \test@class\ \ --\ \ Test \test@test \\ Justify ALL work using complete sentences! Use only \underline{methods from class}.%
}
\fancyhead[C]{%
\test@testdate \linebreak%
}
\fancyhead[R]{%
NAME:\ \line(1,0){140} \\
CRN:\ \line(1,0){140}%
}
\fancyfoot[C]{%
\thepage/\pageref{LastPage}
}
\renewcommand\headrulewidth{0.5pt}
}
% other pages have fancy pagestyle
\pagestyle{fancy}
% define fancy style
\fancyhf{}
\fancyfoot[L]{
\if \thepage \getpagerefnumber{LastPage}
\textbf{Honor Pledge:} I have neither given nor received help on this exam. Signed: \line(1,0){130}
\else
\fi
}
\renewcommand\headrulewidth{0pt}
Actually you could probably get rid of the need for the last page conditional as well using another page style (...packages like
titlesec allow you to define new ones...) and the \AtEndDocument command.
If for some reason you really want to use fancy page style on every page, I guess you could give \headrule itself a conditional definition:
Code: Select all
\let\oldheadrule=\headrule
\renewcommand{\headrule}{\if\thepage 1\oldheadrule\else\fi}
Somehow that feels like a kludge, however.