I'm making a custom document class and I've noticed that after my custom variables get typeset on the title page, they somehow get reset to nothing. They show up on the title page, but then my header isn't working.
Nevermind the assignment part - that's something I just didn't change yet. It's supposed to be lecture.

Here is my code to make this simple document:
\documentclass{notes}
\coursenumber{Course 101}
\semester{Winter 2013}
\lecture{1}
\studentname{My Name}
\studentid{My ID}
\begin{document}
\maketitle
asdf
\end{document}
And here's my notes.cls file:
\ProvidesClass{notes}
\LoadClass[10pt,letterpaper]{article}
\RequirePackage{ifthen}
\RequirePackage[left=1.25in,right=1.25in,top=1.25in,bottom=1.25in]{geometry}
\RequirePackage{setspace}
\RequirePackage{amsmath}
\RequirePackage{titling}
\RequirePackage{fancyhdr}
\RequirePackage{amsfonts}
\newcommand{\@coursenumber}{{\em No \textbackslash coursenumber specified}}
\newcommand{\@semester}{{\em No \textbackslash semester specified}}
\newcommand{\@studentname}{{\em \textbackslash studentname unknown}}
\newcommand{\@studentid}{{\em \textbackslash studentid unknown}}
\newcommand{\@school}{{\em \textbackslash school unknown}}
\newcommand{\@department}{{\em \textbackslash department unknown}}
\newcommand{\@lecture}{\textbackslash lecture}
\newcommand{\solutionstext}{\bfseries (Solutions)}
\newcommand{\coursenumber}[1]{\renewcommand{\@coursenumber}{#1}}
\newcommand{\semester}[1]{\renewcommand{\@semester}{#1}}
\newcommand{\studentname}[1]{\renewcommand{\@studentname}{#1}}
\newcommand{\studentid}[1]{\renewcommand{\@studentid}{#1}}
\newcommand{\school}[1]{\renewcommand{\@school}{#1}}
\newcommand{\department}[1]{\renewcommand{\@department}{#1}}
\newcommand{\lecture}[1]{\renewcommand{\@lecture}{#1}}
\renewcommand{\maketitle}{
\begin{titlepage}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % Defines a new command for the horizontal lines, change thickness here
\center
\leavevmode\\[4cm] % Center everything on the page
\HRule \\[0.4cm]
{ \huge \bfseries \@coursenumber}\\[0.0cm] % Title of your document
\HRule \\[1.5cm]
\textsc{\Large \@semester}\\[0.5cm] % Semester
\textsc{\Large \today}\\[0.5cm] % Date
\textsc{\Large Lecture \#\@lecture}\\[1.0cm] % Lecture
\HRule \\[1.0cm]
\Large \emph{Author:} \\ \@studentname \\
\@studentid \\[3cm]
\vfill % Fill the rest of the page with whitespace
\end{titlepage}
}
\makeatletter
% These commands follow the titling package format for titles
% They define user commands to format the subtitle
\newcommand\presubtitle[1]{\gdef\@presubtitle{#1}}
\newcommand\postsubtitle[1]{\gdef\@postsubtitle{#1}}
% This command takes the subtitle as its argument, and uses the titling command
% \maketitlehookb plus the previously defined formatting commands to insert
% the subtitle into the titlepage. It also generates \thesubtitle for subsequent use
\newcommand\subtitle[1]{%
\renewcommand{\maketitlehookb}{\@presubtitle#1\@postsubtitle}
\newcommand\thesubtitle{#1}}
\makeatother
% Now we define the formatting for the subtitle
\presubtitle{\begin{center}\Large} % change this as needed
\postsubtitle{\end{center}}
% These commands set up the headers. They are set up for even and odd pages the same
% Check the fancyhdr documentation for information on how to set them differently
% for odd and even pages
\lhead{\begin{tabular}{@{}l}\@coursenumber\ (\@semester)\\\@studentname\ (\@studentid)\end{tabular}}
\chead{}
\rhead{\begin{tabular}{r@{}}Assignment \#\@assignment\\\today\end{tabular}}
\lfoot{}
\cfoot{\thepage}
\rfoot{}
% Set the width of the header rule. Make 0pt to remove the rule.
\renewcommand{\headrulewidth}{.5pt}
\renewcommand{\footrulewidth}{0pt}
% Make the head height match the size of the header
\setlength{\headheight}{24pt}
\pagestyle{fancy}
% Remove "Chapter" from the marks
%\renewcommand{\chaptermark}[1]{%
% \markboth{\thechapter.\ #1}{}}

\makeatletterand\makeatother(around the subtitle stuff) in a class file, especially if you use macros with@in it.\@coursenumberwill be\@and then just text “coursenumber”. – Qrrbrbirlbel Jan 24 at 1:59