# [Tex/LaTex] What does the titlepage environment do and what are its benefits

articleenvironmentstitles

I'm speaking about the article document class only, because report and book deal with titles in a different way.

Obviously, the titlepage environment triggers a new page after it, and it resets the page counter to start at 1 over again. As long as you don't use \maketitle on your titlepage, the page style is set to empty, i.e. no page number is shown on the title page. If, however, you do use \maketitle within the titlepage environment, that sets the pagestyle to plain (page number in the footer) again, resulting in two consecutive pages numbered "1".

If we go a step further and use hyperref, which is pretty standard package, we get a warning about the page number 1 being used twice:

pdfTeX warning (ext4): destination with the same identifier (name{page.1}) has
been already used, duplicate ignored

This shows how titlepage messes up internal references slightly.

This question is not about how to fix the things titlepage messes up, I've got all that figured out; I'm rather wondering what the point of using titlepage in a non-trivial document is – besides the nice semantic markup in the source. I could as well just use \newpage, considering that I've got to fix the page numbering at any rate. So:

What precisely does the titlepage environment do and what are its benefits?

If you want to see the phenomena I described, here's a MWE for you to copy. The lines appended with % * might be interesting to comment out.

\documentclass{article}

\usepackage{hyperref}% *

\author{John Doe}
\title{Foo Bar}

\begin{document}
\begin{titlepage}
\maketitle% *
Baz
\end{titlepage}
Hello World
\end{document}


Edit:

Thanks to Werner for the answer. I haven't accepted it though because I'm still not really clear on some things. Let me clarify my question – it'd be great if Werner or someone else could elaborate a bit on them:

• What exactly does the titlepage environment (not the document class option) in article do; what macros and environments does it change and how? I looked into article.cls but I didn't understand all of the relevant parts.
• What is the point of using this environment after all? Why don't I just write \newpage after the title page?

Edit 2:

It'd be interesting to hear if you personally are actually using the titlepage environment and perhaps to see a small example in which it is used advantageously.

As @Marco mentioned in his comment, "every documentclass" provides the titlepage environment - you won't find it as part of latex.ltx. However, it is probably best to view these macros and environments as they are defined in the class files: article.cls, book.cls and report.cls.

However, some discussion may also be warranted.

When looking at the titlepage environment in these document classes, it merely provides a shell that is used by some other macros/environments. For example, setting the documentclass option titlepage (or notitlepage) modifies the way titlepage is defined. This option also affects the way the abstract environment is typeset, since it is done inside titlepage. Also, \maketitle is typeset inside titlepage with this option set for the documentclass.

Finally, \maketitle is a macro that "self-destructs" after you use it, since it's definition includes \global\let\maketitle\relax towards the end. So, you use it and you lose it. Whereas the usage of the titlepage environment lives well beyond \maketitle; hence it's use in other parts of the document as a wrapper. And, the above definitions are similar across the document classes.

In terms of the usage difference between \maketitle and titlepage: They shouldn't be mixed.

Edit:

• article.cls (as well as the other book.cls and report.cls document classes) initiates loading of many of its basic functionality based on a compatibility condition \if@compatibility. That is, certain options/macros/environments are only available if \@compatibilitytrue, or vice versa. If you want a toned-down version of article.cls, use

\makeatletter\@compatibilitytrue\makeatother
\documentclass{article}


The default is to load article with \@compatibilityfalse, are just leaving out the compatibility requirement all together. For a complete discussion on this topic, see What's the use of the @compatibility condition?. This condition also governs the declaration of the titlepage environment. Assuming that one loads the standard document class(es) as-is, titlepage is defined as follows:

\newenvironment{titlepage}
{\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse\newpage
\fi
\thispagestyle{empty}%
\setcounter{page}\@ne
}%
{\if@restonecol\twocolumn \else \newpage \fi
\if@twoside\else
\setcounter{page}\@ne
\fi
}


From this it is clear that the (traditional) titlepage environment does the following

• at \begin{titlepage}:
• Conditions on whether the document is in twocolumn mode or not. If this is the case (\@twocolumntrue), then switch to one column mode (\onecolumn) and set a flag to restore to two column mode \@restonecoltrue. Otherwise, if already in one column mode, issue \newpage;
• Clear the page headings \thispagestyle{empty}; and
• Set the page counter to one \setcounter{page}{@ne}.
• at \end{titlepage}:
• Restore two column mode if need be (set at \begin{titlepage}), or issue another \newpage; and
• Reset the page counter to one if not in twoside mode \setcounter{page}{@ne}.

In essence, titlepage is meant for a single, one column page without headings. You're free to do inside of it what as you please. Perhaps that answers your second question as well.