# Changing the \title in amsart

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?

The macro \title in amsart is defined in a very indirect way:

\renewcommand*{\title}[2][]{\gdef\shorttitle{#1}\gdef\@title{#2}}
\edef\title{\@nx\@dblarg
\@xp\@nx\csname\string\title\endcsname}


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:

\documentclass{amsart}

\usepackage{xparse}
\makeatletter
\RenewDocumentCommand{\title}{om}{%
\IfNoValueTF{#1}
{\gdef\shorttitle{My default running title}}
{\gdef\shorttitle{#1}}%
\gdef\@title{#2}%
}
\makeatother

\title{Article title here}
\author{Author name here}

\begin{document}
\maketitle
\end{document}


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 be

\def\title{\@dblarg\title@}
\def\title@[#1]#2{%
\gdef\shorttitle{#1}\gdef\@title{#2}%
}


because \@dblarg takes care that a call such as

\title{Title}


will substitute Title both for #1 and #2, while a call such as

\title[Short]{Long title}


will do the expected thing. Instead of \title@ anything else could be used.

The definition in amsart exploits the fact that

\renewcommand*{\title}[2][]{\gdef\shorttitle{#1}\gdef\@title{#2}}


defines \title to expand to

\@protected@testopt\title\\title{}


and \\title (a command with a backslash in its name) as if

\def\\title[#1]#2{\gdef\shorttitle{#1}\gdef\@title{#2}}


The next instruction, with \@nx and \@xp replaced by the more comprehensible \noexpand and \expandafter, is

\edef\title{%
\noexpand\@dblarg\expandafter\noexpand\csname\string\title\endcsname
}


that is essentially the same as saying

\def\title{\@dblarg\\title}


(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 the letltxmacro 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.

• Thank you very much for the helpful answer! I suppose there are other people like me who are too lazy to chase back definitions. So, could you explain in a couple of sentences how the indirect definition works (or perhaps say it is not possible to do so), please? Jul 13 '14 at 20:45
• @LawrenceWong Your wish is my command Jul 13 '14 at 21:08
• Very clear and detailed. Thank you very much! Jul 16 '14 at 12:13

you can change the title for just one article by adding, after \maketitle,

\markright{My default running title}


or, if you want it on both sides,

\markboth{My default running title}


this does have the disadvantage that it doesn't automatically uppercase the string, so you either need to type it in fully "cased", or apply \MakeTextUppercase{...}.