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. Dastitling
Paket von Peter Wilson und Will Robertson stellt entsprechende Befehle bereit, die dies ermöglichen.