3

I've been using some style file to write my thesis and it contains some weird macro definition I don't seem to understand, specifically it contains the following code to make a custom title page:

\let\origin@lmaketitle\maketitle
\def\makethesistitle{
  \def\@titlehead{\centering\st@logo\\\smallskip\large\st@university}
  \def\@title{\st@title}
  \def\@subject{\@fordegree\\\st@subject}
  \def\@author{{\normalsize\@by}\\{\st@author} \\[1.5\bigskipamount]%
    {\normalsize\@undersup}\\{\itshape\st@supervisor}%
    \\[1.5\bigskipamount]}
\def\@date{\ifdefined\st@date\st@date\else\if@Latin\latintoday\else\today\fi\fi}
  \origin@lmaketitle
  \newcommand\date[1]{\def\st@date{##1}}
  \newcommand\title[1]{\def\st@title{##1}}
  \newcommand\author[1]{\def\st@author{##1}}
  \newcommand\subject[1]{\def\st@subject{##1}}}

\renewcommand\date[1]{\def\st@date{#1}}
\renewcommand\title[1]{\def\st@title{#1}}
\renewcommand\author[1]{\def\st@author{#1}}
\renewcommand\subject[1]{\def\st@subject{#1}}
\newcommand\logo[1]{\def\st@logo{#1}}
\newcommand\university[1]{\def\st@university{#1}}
\newcommand\supervisor[1]{\def\st@supervisor{#1}}
\def\@undersup{\if@Latin Supervisor\else استاد راهنما\fi}
\def\@by{\if@Latin By\else نگارش\fi}
\def\@fordegree{\if@Latin B.Sc Thesis\else پایان‌نامه کارشناسی\fi}

These commands are then used as usual to define the content of that page:

\begin{document}
\logo{\includegraphics{logo}}
\date{
today
}
\title{
some title
}
\author{
me
}
\university{%
there
}
\subject{%
that
}
\supervisor{
you
}
\frontmatter \makethesistitle

As the style definition only seems to be defining macros that define new macros, I don't really get what is going on here. There is seemingly no problem with this code as it outputs just what its supposed to. I'd appreciate if someone could enlighten me a little bit.

1
  • Note that \makethesistitle calls \origin@lmaketitle which has been set to \maketitle; that's where the actual title is constructed on the page.
    – Werner
    Jun 28 '17 at 11:21
4

The various commands defined using the pattern:

\renewcommand\field[1]{\def\st@field{#1}}

simply introduce a way to store a value for a field in a corresponding \st@field macro that can be used later. The effect of writing \field{value} is defining \st@field to be value. At any later point you can use \st@field to typeset value.

The actual typesetting of these values takes place in the \makethesistitle macro.

Specifically, \makethesistitle calls \origin@lmaketitle which at the beginning is let to be \maketitle which, presumably, is where the various elements \st@field are typeset in the final title page.

Consider for example:

\renewcommand\title[1]{\def\st@title{#1}}
\renewcommand\subtitle[1]{\def\st@subtitle{#1}}

\def\maketitle{
   Thesis\vfill
   \begin{center}
      \bfseries
      \complete@title
   \end{center}
   \vfill
}
\def\makethesistitle{
   \def\complete@title{\LARGE\st@title\\\large\st@subtitle}
   \maketitle
}

when in your document you write

\title{Bla}
\subtitle{blabla}
\makethesistitle

you roughly obtain

\def\st@title{Bla}
\def\st@subtitle{#1}
\def\complete@title{\LARGE\st@title\\\large\st@subtitle}
   Thesis\vfill
   \begin{center}
      \bfseries
      \complete@title
   \end{center}
   \vfill

As you can see the definitions of the intermediate macros is just in preparation for the actual typesetting. This is especially useful if you are reusing the same information (for example author names) for setting up other parts of the document as the headings etc.

There is a further aspect here. In the code you provide, the class writers are reusing some default implementation of \maketitle. Since the class you are using introduces non-standard fields that are not known by the default \maketitle (which in the standard classes only uses \@title, \@author and \@date), the \makethesistitle macro is setting up the macros that the default \maketitle uses in terms of the custom \st@ prefixed ones defined by the class. (for example you see \def\@title{\st@title}).

7
  • Presumably \maketitle uses \@titlehead, \@title, \@subject, etc... So \makethesistitle fills them before calling \origin@lmaketitle. That is why, as specifically asked in the question, it is a macro defining new macros. Jun 28 '17 at 11:25
  • @TonioElGringo hopefully my answer is clearer now?
    – Bordaigorl
    Jun 28 '17 at 11:29
  • I still don't get it, could you augment your answer with an example of how this is expanded at compile time?
    – Paghillect
    Jun 28 '17 at 11:29
  • @Parsoa Maybe it would be clearer for you if you had a look at the source of the\maketitle macro. Specifically, the \@maketitle macro is where typesetting occurs. Jun 28 '17 at 11:34
  • @TonioElGringo If I get it correctly, all of this convoluted macro definitions is a hack to inject user specified values into the definition of \makethesistitle ?
    – Paghillect
    Jun 28 '17 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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