TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

enter image description here

Here is my code to make this simple document:


\coursenumber{Course 101}
\semester{Winter 2013}
\studentname{My Name}
\studentid{My ID}



And here's my notes.cls file:




\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{\HRule}{\rule{\linewidth}{0.5mm}} % Defines a new command for the horizontal lines, change thickness here
    \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

% These commands follow the titling package format for titles
% They define user commands to format the subtitle
% 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
% Now we define the formatting for the subtitle
\presubtitle{\begin{center}\Large} % change this as needed

% 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}}
\rhead{\begin{tabular}{r@{}}Assignment \#\@assignment\\\today\end{tabular}}
% Set the width of the header rule. Make 0pt to remove the rule.
% Make the head height match the size of the header
% Remove "Chapter" from the marks
%  \markboth{\thechapter.\ #1}{}}
share|improve this question
Don’t use \makeatletter and \makeatother (around the subtitle stuff) in a class file, especially if you use macros with @ in it. \@coursenumber will be \@ and then just text “coursenumber”. – Qrrbrbirlbel Jan 24 '13 at 1:59
up vote 6 down vote accepted

While using \makeatletter is harmless inside a style (.sty) or class (.cls) file, \makeatother would unnecessarily change the category code of @ to other (12) (see What are category codes?), making subsequent use of @ in control sequences problematic. As such, remove (the pair \makeatletter and) \makeatother.

As a reference, see Is it really bad to use \makeatletter and \makeatother in a package or class file?

share|improve this answer
I'll look into that. I honestly had no idea what that command did; I just copied it from another source to make my header. I'm now just taking the time to learn how to make my own class proper, and trying to learn what everything does. – agent154 Jan 24 '13 at 2:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.