I am new to amsart
. I want to give myself a default running header. So I try to redefine \title
in the obvious way as follows.
\documentclass{amsart}
\let\AmStitle\title
\renewcommand{\title}[2][My default running title]{\AmStitle[#1]{#2}}
\title{Article title here}
\author{Author name here}
\begin{document}
\maketitle
\end{document}
This apparently ends up looping indefinitely. What is the reason for this?
Best Answer
The macro
\title
inamsart
is defined in a very indirect way:which is very clever, but simply disallows you to do that redefinition. In this case even
\LetLtxMacro
is not good, because of this nonstandard definition.You can do it with
xparse
:Actually, it's a bit mysterious why the definition of
\title
is that one. The standard way to define a macro of that kind would bebecause
\@dblarg
takes care that a call such aswill substitute
Title
both for#1
and#2
, while a call such aswill do the expected thing. Instead of
\title@
anything else could be used.The definition in
amsart
exploits the fact thatdefines
\title
to expand toand
\\title
(a command with a backslash in its name) as ifThe next instruction, with
\@nx
and\@xp
replaced by the more comprehensible\noexpand
and\expandafter
, isthat is essentially the same as saying
(with the difference that
\\title
needs wome weird trick for being input). So there is no gain whatsoever, because the definition is eventually exactly* the easier one I gave before, except perhaps that the internal macro (\\title
, here) is more difficult to get at for a casual user.The
\LetLtxMacro
from theletltxmacro
package can't work, because\\title
exists, but\title
is not defined as expected, that is, starting with\@protected@testopt
, so it gets confused.The
xparse
way is surely clearer.