I would like to know how the \maketitle command works since I am creating my own class and I want to use my own commands.
For example, I already create certain commands like \a, \b and \c and I want that with a certain command we say \printabc a new page is created printing such commands.
Thanks in advance
EDIT 1: I try to define
\def\@mycover{%
\newpage\null
}
but get the error
! Use of \@ doesn't match its definition.
EDIT 2: I have made progress.
\documentclass{myclass}
\makeatletter
\newcommand*{\mytitle}[1]{\gdef\@mytitle{\MakeUppercase{#1}}}
\newcommand*{\myauthors}[5]{\gdef\@myauthors{
\begin{tabular}{c}
\MakeUppercase{#1} \\
\MakeUppercase{#2} \\
\MakeUppercase{#3} \\
\MakeUppercase{#4} \\
\MakeUppercase{#5}
\end{tabular}
}}
\newcommand*{\myafil}[5]{\gdef\@myafil{
\begin{tabular}{c}
\MakeUppercase{#1} \\
\MakeUppercase{#2} \\
\MakeUppercase{#3} \\
\MakeUppercase{#4} \\
\MakeUppercase{#5}
\end{tabular}
}}
\newcommand\makecover{\begin{titlepage}%
\thispagestyle{empty}\centering\bfseries
\@mytitle
\vfill
\@myauthors
\vfill
\@myafil
\end{titlepage}
\global\let\makecover\relax
\global\let\@mytitle\@empty
\global\let\@myauthors\@empty
\global\let\@myafil\@empty
\global\let\mytitle\relax
\global\let\myauthors\relax
\global\let\myafil\relax
}
\makeatother
\mytitle{The Title}
\myauthors{Author 1}{}{}{}{}
\myafil{University}{Faculty of exact and natural sciences}{Department of Mathematics}{City}{Year}
\begin{document}
\makecover
\end{document}
This is all right, but when I comment for example
%\myauthors{Author 1}{}{}{}{}
the following error arises
! Undefined control sequence.
something that does not happen in class book. why does that happen?
\authorcommand does\gdef\@author{<Something>}, then\maketitlecontains\@author, which will print<Something>. I suggest looking at LaTeX's base classes for some guidance: https://www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/base/article.cls?view=co – Phelype Oleinik Sep 28 '18 at 17:44@in their name you have to say\makeatletterbefore. See What do \makeatletter and \makeatother do? – Phelype Oleinik Sep 28 '18 at 18:00\newcommand*{\mytitle}[1]{\gdef\@mytitle{#1}}needs\makeatletter? – Joan Sep 28 '18 at 18:12\newcommand, but before it. But if you are writing a class in a.clsfile the\makeatletterthingy should already be active. If you are testing outside the.clsfile then yes, you need the\makeatletter. – Phelype Oleinik Sep 28 '18 at 18:14\makeatletter\newcommand...\makeatother. Thanks, i will try it – Joan Sep 28 '18 at 18:17book.clsfile, I see that they define two commands, namely,\maketitleand\@maketitle, so, why its that? what is the diference? – Joan Sep 28 '18 at 18:19\maketitlecommand is what the user will use. The\@maketitleis an implementation detail. It could be called (non intuitively)\@potato:P But in this case, the\@maketitleholds the actual formatting of the title and is called differently by\maketitlein case thetwocolumnoption is used. – Phelype Oleinik Sep 28 '18 at 18:23\myauthorscommand then the\@myauthorsmacro will never be defined, then TeX will complain that is isUndefined. You can add\def\@myauthors{}in your class file so you are sure that the macro exists. Or you can use the same approach as LaTeX and do\def\@myauthors{\@latex@warning@no@line{No \noexpand\myauthor given}}. Off-topic: I would go for a comma separated list of authors instead of{}{}{}{}{}... – Phelype Oleinik Sep 28 '18 at 20:16\def\@myauthors{\@latex@warning@no@line{No \noexpand\myauthor given}}\newcommand*{\mytitle}[1]{\gdef\@mytitle{\MakeUppercase{#1}}}is the correct form? and... how do I make the command understand that the arguments are the entries separated by commas? – Joan Sep 28 '18 at 20:31\def\@myauthors{\@latex@warning@no@line{No \noexpand\myauthor given}}you tell LaTeX to raise a (comprehensible) error if the user of the class doesn't provide an author. Alternatively you can use\def\@myauthors{}then, if the author doesn't use\myauthors, an empty string will be used. As for the comma thing, it's way more complicated than just using a\newcommand. New Question ;) – Phelype Oleinik Sep 28 '18 at 20:35