General ⇒ Print document-title given by \title
Print document-title given by \title
Hello,
I'd like to print out the document title at certain points in the document. For this, I'd like to print out (I thought of \thetitle but it doesn't work) the title I defined via \title. Just to clarify: It's a string of words, maybe only one word, but it's not the titlepage.
Is that possible?
I've searched for a solution for good 15 minutes now, but it seems my queries were too general for Google and Bing.
I'd like to print out the document title at certain points in the document. For this, I'd like to print out (I thought of \thetitle but it doesn't work) the title I defined via \title. Just to clarify: It's a string of words, maybe only one word, but it's not the titlepage.
Is that possible?
I've searched for a solution for good 15 minutes now, but it seems my queries were too general for Google and Bing.
Last edited by Montag on Tue Mar 08, 2011 6:38 pm, edited 1 time in total.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
NEW: TikZ book now 40% off at Amazon.com for a short time.

- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Print document-title given by \title
The arguments of \author and \title are stored in special internal macros. Save them to another macro and you can use them wherever you want. If I understand you right, the code below should do what you want.
Note that the sequence of commands is very important. The title and author have to be declared first to make the new commands work.
Thorsten
Code: Select all
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\title{Using the document title wherever needed}
\author{Montag}
\makeatletter
\let\thetitle\@title
\let\theauthor\@author
\makeatother
\begin{document}
\maketitle
The title of this short document is: »\thetitle«.
Author of this document is: \theauthor.
\end{document}
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: Print document-title given by \title
Thanks a lot, Thorsten, that is what I looked for.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
Re: Print document-title given by \title
Is there a way these internal commands could be nullified somehow? I just noticed in one document the author and title field are empty and I can't figure out why, that's why I'm asking.
OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Re: Print document-title given by \title
Do you mean accidentally or user intended? Can you give a short example?
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Print document-title given by \title
Accidentally!localghost wrote:Do you mean accidentally or user intended?
I'd like to, but like I said, I defined the title and author like you showed above and so far I had no problems.Can you give a short example?
But in one document of mine, the fields stay empty. And I already made a "folder search" in TXC and can't find some second definitions for \title{This is the title} and \author{My name} anywhere. So I guess this code
Code: Select all
\makeatletter
\let\thetitle\@title
\let\theauthor\@author
\makeatother
I don't really understand it. :/
EDIT:
Got it. Clear case of Luser. :/
I accidentally switched the order of the commands you provided in your answer, in which you also underlined the importance of their order.

OS: Win 7 64-bit LaTeX: MikTeX 2.9 64-bit Editor: TXC 1 RC1
Print document-title given by \title
They're cleared by \maketitle, to save memory.Montag wrote:Is there a way these internal commands could be nullified somehow? I just noticed in one document the author and title field are empty and I can't figure out why, that's why I'm asking.
You could do
Code: Select all
\makeatletter
\let\m@ketitle=\maketitle
\def\maketitle{\let\@@author=\@author\let\@@title=\@title
\m@ketitle
\let\author=\@@author\let\title=\@@title}
\makeatother