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'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.

share|improve this question
6  
You can't combine the environment titlepage with maketitle. maketitle based on the idea of documentclass and with titlepage you can define your own title. Every documentclass has the option titlepage. –  Marco Daniel Sep 5 '11 at 12:42
add comment

2 Answers

up vote 14 down vote accepted

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 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.

share|improve this answer
    
Thanks for the explanation, that's what I was looking for. After all, it seems to me that there isn't really a good reason for me to use titlepage. It might be a nice shortcut if you're writing a two-column document, but besides that, it's just easier to set everything correctly by hand. –  doncherry Oct 17 '11 at 17:12
add comment

You can cure both problems, that is, the page number on the title page and the message from hyperref by saying

\begin{titlepage}
\maketitle
\thispagestyle{empty}
\setcounter{page}{0}
\end{titlepage}

The page number will be set to one by \end{titlepage} for the following page.

The problems are:

  • \maketitle issues a \thispagestyle{plain} instruction, that we can countermand with another \thispagestyle;
  • hyperref doesn't like to have two pages with the same number, either it appears in print or not; setting the page number to 0 solves the issue.

This explains briefly how to cope with the major problem of using the environment with hyperref. Now I'll come to the reason why such an environment is provided with article. It was customary in many academic institutions to collect preprints with a cardboard cover page; a small window showed the title. With the titlepage environment the author could place the data so that it showed properly without tampering with the \maketitle command.

share|improve this answer
    
So, as opposed to @Marco's comment above, you're saying that titlepage was/is supposed to be used in combination with maketitle? –  doncherry Oct 17 '11 at 17:34
    
@doncherry No. Modifying \maketitle for printing a title suitable for those windows requires much more work than writing a minipage to be shifted in the correct place. –  egreg Oct 17 '11 at 17:36
    
Ah, I thought by "without tampering with the \maketitle command" you meant "without altering it", but you actually meant "without using it". So for that case, titlepage once again is (mostly) just a nice semantic wrapper? –  doncherry Oct 17 '11 at 17:41
    
@doncherry Yes, it takes care of temporarily reverting from a twocolumn setting in the class options, as Werner explained, and provides users with a blank sheet where to do whatever they want. –  egreg Oct 17 '11 at 17:52
    
I see the twocolumn advantage, but besides that, isn't any LaTeX'ed page a "blank sheet to do whatever I want"? (I'm sorry if I'm a bit slow here, I'm just really having a hard time seeing the point of this environment.) –  doncherry Oct 17 '11 at 18:07
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.