I'm creating my own class based on article and I would like to add a parameter subtitle which users of my class can set similar to title, author and date, e.g.,
\documentclass{myclass}
\title{My title} % This sets `\@title` to `My title` somehow.
\subtitle{Some subtitle} % I want this to set `\@subtitle` to `Some subtitle`.
\begin{document}
\makebanner % this command uses @title and @subtitle under the hood
\end{document}
Looking at the source code of article.cls, the title command seems to be defined as follows.
\global\let\@title\@empty
\global\let\title\relax
This doesn't really make sense to me, so I think I'm missing something. Also, adding \global\let\@subtitle\@empty and \global\let\subtitle\relax doesn't work. What is a proper way to do this? How does article.cls do it?
\global\let\@subtitle\@emptyand\protected\long\def\subtitle#1{\gdef\@subtitle{#1}}does the trick. The\global\let\title\relaxis executed inside of\maketitle. The real definition of\titleis done by the kernel and not part ofarticle.cls. – Skillmon Jan 25 '22 at 17:55\title,article.clsjust uses an existing definition. – Skillmon Jan 25 '22 at 18:38