[Tex/LaTex] titling’s \thetitle, \theauthor and \thedate don’t work

errorstitlestitling

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}

Best Answer

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.