I am trying to make a custom class file for a SOP. I think I am running into issues when using fancyhdr package but I'm not sure why.
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{sop}[10/10/2014 article class for standard operating procedures]
% Passes and class options to the underlying article class
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClass{article}
% Redefine the page margins
\RequirePackage[left=1in,right=1in,top=.75in,bottom=.75in]{geometry}
% Modifications to the section titles
\renewcommand*\thesection{\arabic{section}.0}
\renewcommand*\thesubsection{\arabic{section}.\arabic{subsection}}
\renewcommand*\thesubsubsection{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}
% Modification of title block
\RequirePackage{titling}
\newcommand{\sopchaptertitle}[1]{\def\@sopchaptertitle{#1}}
\newcommand{\sopchapternumber}[1]{\def\@sopchapternumber{#1}}
%%% Drop before title
\setlength\droptitle{12cm}
%%% Define the internal variable \@title to be the supplied data
\renewcommand\maketitlehooka{%
\def\@title{\@sopchaptertitle\ \@sopchapternumber}}
%%% No author field, so \maketitlehookb gobbles what comes after it
\renewcommand\maketitlehookb[1]{}
%%% No date field, so \maketitlehookc gobbles what comes after it
\renewcommand\maketitlehookc[1]{}
%%% Formatting the title
\pretitle{\centering\sffamily\LARGE}
%%% Space after the title
\posttitle{\par\vspace{3cm}}
%%% The rest of the class
% For "Page N of M" and header/footer constructioe
\RequirePackage{lastpage}
% For easier construction of page headers/footers
\RequirePackage{fancyhdr}
\newcommand{\revision}[1]{\def\@revision{#1}}
\newcommand{\revisionMMYY}[1]{\def\@revisionMMYY{#1}}
\newcommand{\tcn}[1]{\def\@tcn{#1}}
\fancypagestyle{plain}{ % for first page
\fancyhf{}
\fancyhead[R]{%
SOP- \thesopchapternumber \ Page \thepage{} of \pageref*{LastPage}
}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{%
REV \therevision,\ \therevisionMMYY
}
\renewcommand{\footrulewidth}{0pt}
}
\pagestyle{fancy} % for other pages
\fancyhf{}
\fancyhead[R]{%
SOP-\thesopchapternumber \ Page \thepage{} of \pageref*{LastPage}
}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{%
REV \therevision,\ \therevisionMMYY
}
\renewcommand{\footrulewidth}{0pt}
% For easier customization of itemized, enumerated, and other lists
\RequirePackage{enumitem}
% For hyperlinked cross-references
\RequirePackage{hyperref}
% Ensure first page is correct style
\RequirePackage{appendix}
\RequirePackage{makebox}
\RequirePackage{nextpage}
\thispagestyle{plain}
\endinput
Here is a basic Tex file I'm trying to compile with it just to try and get it to work.
\documentclass[10pt]{sop}
%
% SOP Standard Form Data
\sopchaptertitle{john doe PROCEDURE}
\sopchapternumber{D.1}
\date{11/13/14}
\author{johndoe}
%...more of the above
%Here begins the actual document
\begin{document}
\maketitle
\section{Main Title}
\section{Approval}
Approval1....\makebox[1.5in]{\hrulefill}\\\vspace{1.5in}
Approval2....\makebox[1.5in]{\hrulefill}
\newpage
\section{Purpose and Discussion}
%...more of the above...
\end{document}
edit: Here is my log file. https://www.dropbox.com/s/qebydr5p1xt9ozq/text.log?dl=0
10/10/2014should be2014/10/10– David Carlisle Nov 13 '14 at 21:09\thesopchapternumberis not defined. If you want to use it like this,sopchapternumberneeds to be a counter defined with\newcounter. Similarly for\therevisionetc. They all need to be counters if you plan to access them this way. Not the problem, but consider using the updated alternative forlastpage. You'll see warnings about the use oflastpagein your compilation output, with recommendations for updating. – cfr Nov 13 '14 at 22:26\fancyhead[R]{% SOP- \@sopchapternumber \ Page \thepage{} of \pageref*{LastPage} }. Use the @versions you aredefing when using\sopchapternumber{my number}. The\theconstruct doesn't work here (it doesen't in the linked answer as well <-- @mikerenfro) – Johannes_B Nov 16 '14 at 15:45\theauthoris buggy (as far as i can tell). – Johannes_B Nov 16 '14 at 22:38\theauthorwill fail if I have thetitlingpackage included, and the author's name was inserted in the page headers as needed. – Mike Renfro Nov 17 '14 at 00:36titling. My test document didn't include an\authorcommand, hence\theauthoris completely undefined (i would have expected a warning or something similar). The OP here uses\thesopchapternumberwhich seems to be related to\theauthor. I understand that this can be confusing for a beginner. Want to write an answer? – Johannes_B Nov 17 '14 at 07:27