I've been receiving the error Undefined control sequence. <argument> \shorttitle
with the following code:
\author{MyName}
\title{ThisPaper}
\date{01 Jan 2015}
\documentclass[12pt]{amsart}
\begin{document}
\maketitle
Text
\end{document}
Is there something wrong with my packages?
Text
\end{document}
Best Answer
Put
\author
etc. after\documentclass
- not before.This way, you get the class's definitions of these macros and
\shorttitle
will be defined automatically when you define\title
. If you use\title
before,amsart
's definitions are not active and\shorttitle
will not be defined.Here's the definition of
\title
fromamsart.cls
:Notice the
\renewcommand
rather than\newcommand
. The class is replacing the standard LaTeX\title
with a definition of its own. The redefined version takes 2 arguments, rather than 1. But the first is optional. Moreover, the first argument is used to define\shorttitle
:This means that if you say just
then
Title
will be used for the title and\shorttitle
will be defined to be nothing because the default value of the optional argument is[]
in the\renewcommand
line above.But if you say
\title
before\documentclass
, you get the standard LaTeX definition:So, in this case, the title will be correctly set to
Title
but\shorttitle
is never defined. This is a problem because\maketitle
is used afteramsart.cls
has redefined it and it expects\shorttitle
to be available. Hence, you get the error.In general, very little, if anything, should go before
\documentclass
. Unless you are certain it should go before the class is loaded, assume that it either belongs in the preamble - the code after\documentclass
and before\begin{document}
- or in the document - the code after\begin{document}
and before\end{document}
.