Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

5 Answers 5

up vote 25 down vote accepted

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
share|improve this answer
add comment

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.

share|improve this answer
    
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
    
Note that you have to load titling (\usepackage{titling}) before \title, \author and \date are defined. –  doncherry Sep 4 '11 at 16:58
4  
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
1  
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
add comment

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}
share|improve this answer
add comment

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}
share|improve this answer
add comment

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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