I am trying to understand the following code:
\def\author{\@dblarg\beamer@author}
\long\def\beamer@author[#1]#2{%
\def\insertauthor{\def\inst{\beamer@insttitle}\def\and{\beamer@andtitle}#2}%
}
Patterns similar to the above example turn up in beamerbasetitle.sty.
What I understood so far
\def\author{\@dblarg\beamer@author}
This line is explained in the SE post q/56329. We need this line to define \beamer@author in a way that it handles the cases \author{abc} and \author[xyz]{abc}.
\long\def\beamer@author[#1]#2{%
This line (re-)defines the \beamer@author command (?)
\def\insertauthor{\def\inst{\beamer@insttitle}\def\and{\beamer@andtitle}#2}%
This line is the line that confuses me the most. The \def\insertauthor defines the \insertauthor command, and, from what I got from the question q/541515, a call like \insertauthor{J. Doe}
would then expand to
\def\inst{\beamer@insttitle}\def\and{\beamer@andtitle}J. Doe
Correct? Why do we need to add \def\inst{\beamer@insttitle}\def\and{\beamer@andtitle}? I feel like
\def\insertauthor{#2}%
would also do the job. I also noticed the following part in beamerbasetitle.sty.:
% Aux commands for \author
\def\beamer@insttitle#1{\textsuperscript{#1}}
\def\beamer@andtitle{\quad}
I would like to understand how the nested \defs are expanded and how to read the initial example.
a call like \insertauthor{J. Doe}no\insertauthoris not defined to take an argument, see the line you show, it is\def\insertauthor{...not\def\insertauthor#1{...– David Carlisle Mar 19 '22 at 09:09\def\insertauthor{..only defines the command\insertauthorwhich expands to\def\inst{\beamer@insttitle}\def\and{\beamer@andtitle}J. Doeif I call\author{J. Doe}? – el_tenedor Mar 19 '22 at 09:22\author[Hemaspaandra et al.]{L. Hemaspaandra\inst{1} \and T. Tantau\inst{2}}, your two \def ensure that \inst and \and then have locally the needed definition. – Ulrike Fischer Mar 19 '22 at 09:24\authorisn't directly used but whatever beamer template is being used can use\insertauthorwhere it wants to insert the author name – David Carlisle Mar 19 '22 at 09:24\instand\andfor a command like\authorthat should be able to handle these commands in its argument. – el_tenedor Mar 19 '22 at 09:41