Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the value of the document title in latex?

Tags:

latex

I am wondering how I can get the document title in LaTex, for use elsewhere in the document. I just want to be able to echo it.

like image 672
nedned Avatar asked Mar 26 '10 09:03

nedned


People also ask

How do you show titles in LaTeX?

You can define a title for your document using \title{} and then create the title itself using \maketitle . You can also add other information such as the author(s) and the date, e.g. Note the use of \today to automatically insert the date you created the document. Of course you can just write a date if you prefer!

Why is Maketitle used in LaTeX?

The \maketitle command generates a title on a separate title page - except in the article style, where the title normally goes at the top of the first page.

What is Maketitle in overleaf?

\maketitle. This command will print the title, the author and the date in the format shown in the example. If it's not enclosed in a titlepage environment, it will be shown at the beginning of the document, above the first line. Open an example in Overleaf.

How do you center a title in LaTeX?

If you want to center some text just use \centering . If you want to align it differently you can use the environment \raggedleft for right-alignment and \raggedright for left-alignment.


1 Answers

Using \@title does not work because \maketitle clears \@title. This seems silly to me but that's the way it is. One solution is to redefine \title to save the title somewhere else. For instance,

\def\title#1{\gdef\@title{#1}\gdef\THETITLE{#1}} 

then use \THETITLE.

You can do the other way around: \def\MYTITLE{...} then \title{\MYTITLE} and later use \MYTITLE again.

like image 167
lhf Avatar answered Sep 20 '22 13:09

lhf