# titling's \thetitle, \theauthor and \thedate don't work

I was trying to use \thetitle, \theauthor and \thedate of the titling package, but none of them worked. MWE:

\documentclass{article}

\usepackage{titling}

\begin{document}
\thetitle \theauthor \thedate
\end{document}


(updated MWE see below)

returns three errors:

! Undefined control sequence.
l.6 \thetitle
\theauthor \thedate

! Undefined control sequence.
l.6 \thetitle \theauthor
\thedate

! Undefined control sequence.
l.6 \thetitle \theauthor \thedate

I'm using MiKTeX 2.9 (pdfTeX 1.40.12) with the most up-to-date version of titling, here's the \listfiles output:

 *File List*
article.cls    2007/10/19 v1.4h Standard LaTeX document class
size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
titling.sty    2009/09/04 v2.1d maketitle typesetting

## Edit:

Obviously, and stupidly, I forgot to define \title, \author and \date in above MWE. This wasn't the problem in my original document, though. The complete MWE (that still produces the same errors) would've looked like like this:

\documentclass{article}

\author{John Doe}
\title{Foo Bar}
\date{\today}

\usepackage{titling}

\begin{document}
\thetitle \theauthor \thedate
\end{document}

-
See my edited answer – egreg Sep 4 '11 at 17:50

This works:

\documentclass{article}

\usepackage{titling}
\author{A. N. Author}
\title{A title}
\date{\today}

\begin{document}
\maketitle
\thetitle \theauthor \thedate
\end{document}


You have to specify the data, otherwise they're not available.

Of course the titling package has to be loaded before defining title, author and date.

-
Ooops :D I totally forgot the data in my MWE. In the original document I'm working on, it was defined, however. I found the pitfall, however, I'll add it as an answer. Thanks for the hint! – doncherry Sep 4 '11 at 16:45
If you want to be minimal, \maketitle isn't even necessary. (I was considering this as the source of the error at some point, i.e. \maketitle must be executed in order for \thetitle to work, which is not the case.) – doncherry Sep 4 '11 at 17:13

The titling package needs to be called before \title, \author and \date are defined. To get the meta-data first in any source, I usually don't put any packages before it, but here it seems necessary. The following example works:

\documentclass{article}

\usepackage{titling}

\author{John Doe}
\title{Foo Bar}
\date{\today}

\begin{document}
\thetitle \theauthor \thedate
\end{document}


Interestingly, \thedate doesn't automatically function as \today, even though \maketitle will assume the date is today if you don't specify otherwise.

-

You need to define the values of author, title and date before these can be called, e.g.

\documentclass{article}

\usepackage{titling}
\title{this}
\author{him}
\date{13 July 2025}
\begin{document}
\thetitle \theauthor \thedate
\end{document}

-
+1 for being ahead of the time ;) – doncherry Sep 4 '11 at 17:15