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) inarticle
do; what macros and environments does it change and how? I looked intoarticle.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.
Best Answer
As @Marco mentioned in his comment, "every documentclass" provides the
titlepage
environment - you won't find it as part oflatex.ltx
. However, it is probably best to view these macros and environments as they are defined in the class files:article.cls
,book.cls
andreport.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 optiontitlepage
(ornotitlepage
) modifies the waytitlepage
is defined. This option also affects the way theabstract
environment is typeset, since it is done insidetitlepage
. Also,\maketitle
is typeset insidetitlepage
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 thetitlepage
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
andtitlepage
: They shouldn't be mixed.Edit:
article.cls
(as well as the otherbook.cls
andreport.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 ofarticle.cls
, useThe 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 thetitlepage
environment. Assuming that one loads the standard document class(es) as-is,titlepage
is defined as follows:From this it is clear that the (traditional)
titlepage
environment does the following\begin{titlepage}
: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
;\thispagestyle{empty}
; and\setcounter{page}{@ne}
.\end{titlepage}
:\begin{titlepage}
), or issue another\newpage
; andtwoside
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.