97

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.

79

The \title, \author and \date macros are saving their argument into \@title, \@author, and \@date, respectively. You can use this macros after \makeatletter. Afterwards 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
63

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.

  • 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 '11 at 16:10
  • @doncherry Not at all. It added a nice piece of clarification to the answer. – Alan Munn Sep 4 '11 at 16:35
  • 6
    Note that you have to load titling (\usepackage{titling}) before \title, \author and \date are defined. – doncherry Sep 4 '11 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 '11 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 '11 at 17:11
15

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}
12

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}
8

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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.