Accessing date, title, author in LaTeX documents

Per default there is no way to access the content of the \title, \author and \date variables from within the LaTeX document, since the \maketitle command clears their content. The following example illustrates this:

\documentclass{article}
 
\title{Some Title}
\author{Uwe Ziegenhagen}
 
\begin{document}
 
\makeatletter
Content: \@date, \@author, \@title
\makeatother
 
\maketitle
 
\makeatletter
Content: \@date, \@author, \@title
\makeatother
 
\end{document}

The solution is however pretty easy. One could define own commands which take the content of those variables or just use the titling package. It provides \thetitle, \theauthor and \thedate.

\documentclass{article}
\usepackage{titling}
\title{Some Title}
\author{Uwe Ziegenhagen}
\date{01.01.1901}
 
\begin{document}
 
\maketitle
 
\theauthor
 
\thetitle
 
\thedate
 
\end{document}

Deutsche Zusammenfassung: Nach dem Aufruf von \maketitle kann man nicht mehr auf die Inhalte von \date, \author und \title zugreifen. Das titling Paket von Peter Wilson und Will Robertson stellt entsprechende Befehle bereit, die dies ermöglichen.

Uwe

Uwe Ziegenhagen likes LaTeX and Python, sometimes even combined. Do you like my content and would like to thank me for it? Consider making a small donation to my local fablab, the Dingfabrik Köln. Details on how to donate can be found here Spenden für die Dingfabrik.

More Posts - Website