152

I am trying to create a title page of my own.

Is there a way to make use of the \title, \author and \date commands inside the title page?

For instance:

...
\title{Something Cool}
\author{Cool Dude}
\date{\today}

\begin{document}
\begin{titlepage}

The title is \title
It was written by \author on \date

\end{titlepage}
\end{document}

Basically I just want to know if there is a way to leverage the information stored in \title, \author and \date inside the title page.

2
  • 1
    Also, note that \date{\today} is redundant since if you don't provide a \date command, \maketitle will automatically use the current date. Jan 4, 2020 at 15:47
  • I'm not sure it's worth using these commands. I think that if the titlepage is created manually, title, author and date don't need to be used at all. Oct 8, 2020 at 18:28

5 Answers 5

121

The \title, \author and \date macros save their argument into \@title, \@author, and \@date, respectively. You can use these macros after \makeatletter. Afterward, use \makeatother. Note that they are cleared by \maketitle.

\title{Example}
\author{Me}
\date{\today}

% ...

\makeatletter
\begin{titlepage}

The title is \@title
It was written by \@author\space on \@date

\end{titlepage}
\makeatother
89

The titling package provides various user-friendly ways to modify title pages.

It provides the macros \thetitle, \theauthor and \thedate which can be reused anywhere in your document.

It allows you to have multiple instances of \title, \author and \date and \maketitle itself in a single document. (If you don't use titling, \maketitle clears the values of \@title, \@author and \@date [cf. Martin's answer] after it has used them.)

It also provides various hooks for modifying the formatting of all of the component parts.

5
  • I just noticed I should rather have added my edit of August 24 as a comment. Sorry, I hope you didn't mind.
    – doncherry
    Sep 4, 2011 at 16:10
  • @doncherry Not at all. It added a nice piece of clarification to the answer.
    – Alan Munn
    Sep 4, 2011 at 16:35
  • 6
    Note that you have to load titling (\usepackage{titling}) before \title, \author and \date are defined.
    – doncherry
    Sep 4, 2011 at 16:58
  • 5
    To me, this seems obvious, or am I missing something? Load all packages, then start supplying content...
    – Alan Munn
    Sep 4, 2011 at 17:01
  • 4
    Well, for me, it wasn't. I guess it's because in learning LaTeX, I used \title{...} etc. before I used any packages, so they came first in the source; then, I liked seeing the meta-data at the very top of the source. The question I linked to describes the first (and so far only) time this meant trouble for me. Your "1) setup 2) content" approach makes a lot of sense, though. (Obviously, the note wasn't meant for you personally, but as a general pointer.)
    – doncherry
    Sep 4, 2011 at 17:11
27

I understand your question as follows: How can I access the values of the title, author, and date fields somewhere in the document. I suggest the following MWE as an answer, which dispenses with the need to use \makeatletter ... \makeatother outside of the preamble:

\documentclass{article}
\title{Something}
\author{Somebody}
\date{Sometime}

\makeatletter
\let\newtitle\@title
\let\newauthor\@author
\let\newdate\@date
\makeatother

\begin{document}
\maketitle

Later in the document \ldots we access the variables again:
\newtitle, \newauthor, and \newdate.

\end{document}
17

There exists a package exactly for this purpose: authoraftertitle

\documentclass{article}
\usepackage{authoraftertitle}
\title{Something}
\author{Somebody}
\date{Sometime}

\begin{document}
\maketitle

Later in the document \ldots we access the variables again:
\MyTitle, \MyAuthor, and \MyDate.

\end{document}
16

Another possibilty is to define metadata. Something like

\def\myauthor{Author} % Author
\def\mycoauthor{} % co-author
\def\mytitle{Title} % title
\def\mydate{Date} % date
%....
\begin{titlepage}

The title is \mytitle
It was written by \myauthor on \mydate

\end{titlepage}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .