3

The titling package allows users to customise the appearance of the document title, to include multiple titles etc. In addition to allowing customisation of \maketitle, it defines a new environment, titlingpage, which is similar to titlepage but allows the use of \maketitle within the environment to typeset the title, author, date etc.

Here's an example based on code from page 5 of the manual:

\documentclass{article}
\usepackage{titling}
\title{Title}
\author{Author}

\begin{document}
  \begin{titlingpage}
    \setlength{\droptitle}{30pt}% lower the title
    \maketitle
    A few words\dots
    \begin{abstract}A few more words\dots\end{abstract}
  \end{titlingpage}
\end{document}

<code>titlingpage</code> environment

In trying to answer this question, I tried to use titlingpage to typeset the title below an image to be typeset first. When this failed, I produced the following modification of the above example:

\documentclass{article}
\usepackage{titling}
\title{Title}
\author{Author}

\begin{document}
  \begin{titlingpage}
    A few words\dots
    \setlength{\droptitle}{30pt} % lower the title
    \maketitle
    \begin{abstract}A few more words\dots\end{abstract}
  \end{titlingpage}
\end{document}

bug or feature?

Not what I expected based on the documentation....

Obviously, it is possible to use titlingpage, like titlepage, to typeset the title below other things here. But I cannot figure out how to do so using \maketitle.

Is this a bug or a feature? Either way, is there a workaround? (If a feature, is this a bug in the documentation?!)

Note that on page 4, the manual says that it defines \maketitle 'essentially' as follows:

\renewcommand{\maketitle}{%
\vspace*{\droptitle}
\maketitlehooka
{\pretitle \title \posttitle}
\maketitlehookb
{\preauthor \author \postauthor}
\maketitlehookc
{\predate \date \postdate}
\maketitlehookd
}

So, again, nothing to suggest that \maketitle will itself start a new page - especially in the titlingpage environment.

I'm assuming this is not really how it is defined. (And, indeed, the actual code when the titlepage option is not active and the document is in one-column mode includes a suspicious-looking newpage...)

It seems to me that titlingpage ought to do something like

\let\oldnewpage\newpage
\let\newpage\relax

and

\let\newpage\oldnewpage

at the beginning and end of the environment if titlingpage is to work as advertised. (But I'm sure this particular suggestion would either not work at all or have horrible side-effects or both.)

1 Answer 1

3

As you suspected, the problem comes from \newpage, not just one of them but two \newpages are responsible here for the mentioned behaviour.

This is the definition of \maketitle contained in titling.sty:

\providecommand{\maketitle}{}
\if@titlepage
  \renewcommand{\maketitle}{\begin{titlepage}%
    \let\footnotesize\small
    \let\footnoterule\relax
    \let \footnote \thanks
    \@bsmarkseries
      \def\@makefnmark{\rlap{\@textsuperscript{%
         \normalfont\@bsthanksheadpre \tamark \@bsthanksheadpost}}}%
      \long\def\@makefntext##1{\makethanksmark ##1}
    \null\vfil
    \vskip 60\p@
    \vspace*{\droptitle}
    \maketitlehooka
    {\@bspretitle \@title \@bsposttitle}
    \maketitlehookb
    {\@bspreauthor \@author \@bspostauthor}
    \maketitlehookc
    {\@bspredate \@date \@bspostdate}
    \maketitlehookd
    \par
    \@thanks
    \vfil\null
    \end{titlepage}%
    \@bscontmark  %  \setcounter{footnote}{0}%
%%%    \@bsmtitlempty
  } % end titlepage defs
\else
  \renewcommand{\maketitle}{\par
    \begingroup
      \@bsmarkseries
      \def\@makefnmark{\rlap{\@textsuperscript{%
         \normalfont\@bsthanksheadpre \tamark \@bsthanksheadpost}}}%
      \long\def\@makefntext##1{\makethanksmark ##1}
      \if@twocolumn
        \ifnum \col@number=\@ne
          \@maketitle
        \else
          \twocolumn[\@maketitle]%
        \fi
      \else
        \newpage
        \global\@topnum\z@
        \@maketitle
      \fi
      \thispagestyle{plain}\@thanks
    \endgroup
    \@bscontmark  %  \setcounter{footnote}{0}%
%%%    \@bsmtitlempty
  } % end non-titlepage

  \def\@maketitle{%
    \newpage
    \null
    \vskip 2em%
          \vspace*{\droptitle}
    \maketitlehooka
    {\@bspretitle \@title \@bsposttitle}
    \maketitlehookb
    {\@bspreauthor \@author \@bspostauthor}
    \maketitlehookc
    {\@bspredate \@date \@bspostdate}
    \maketitlehookd
    \par
    \vskip 1.5em}
\fi

Basically, we have a conditional test for @titlepage; since in your case this is false (article.cls sets \@titlepagefalse by default), we can go to the \else part which redefines \maketitle which, if two-column mode is not active (as it is by default), has a \newpage:

      \else
        \newpage
        \global\@topnum\z@
        \@maketitle
      \fi

before calling \@maketitle which in its turn is defined by

  \def\@maketitle{%
    \newpage
    \null
    \vskip 2em%
          \vspace*{\droptitle}
    \maketitlehooka
    {\@bspretitle \@title \@bsposttitle}
    \maketitlehookb
    {\@bspreauthor \@author \@bspostauthor}
    \maketitlehookc
    {\@bspredate \@date \@bspostdate}
    \maketitlehookd
    \par
    \vskip 1.5em}

which has another \newpage command. Those are responsible for the behaviour you noticed.

To avoid this, one possibility is to patch \maketitle and \@maketitle to suppress the \newpages:

\documentclass{article}
\usepackage{titling}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\@maketitle}
 {\newpage}
 {}
 {}
 {}
\patchcmd{\maketitle}
 {\newpage}
 {}
 {}
 {}
\makeatother

\title{Title}
\author{Author}

\begin{document}
  \begin{titlingpage}
    A few words\dots
    \setlength{\droptitle}{30pt} % lower the title
    \maketitle
    \begin{abstract}A few more words\dots\end{abstract}
  \end{titlingpage}
\end{document}

enter image description here

Standard classes have the \newpage in the definition of \@maketitle, so I guess the author of the package kept this as a feature, though your example use perhaps suggests that these \newpages commands would be better left as optional and not hard-coded.

7
  • Thanks. That's was the suspicious \newpage I mentioned. Note that this is not specific to article, though. The same happens with book and report. Do you think the behaviour is intentional, then, and the documentation buggy? Or is the code intentional but not this effect? Or neither?
    – cfr
    Jul 8, 2014 at 2:36
  • Of course, the case of book or report will trigger the titlepage environment which will start a new page. But is this intended given the description of titlingpage and \maketitle in the manual? The code makes it look clearly intended but I'm not quite sure why it would be given the purpose of titlingpage.
    – cfr
    Jul 8, 2014 at 2:40
  • @cfr In my optinion the \newpages commands (I updated my answer showing that there are really two of them involved here) were intentional (as apparently they try to emulate the behaviour of the original definitions in standard classes), but perhaps the package should somehow make them optional and not hard-coded. Jul 8, 2014 at 2:48
  • I agree that the \newpages are intentional in a sense but I'm not sure that their effect in titlingpage is. Just before introducing that environment, the manual says Do not use \maketitle within the titlepage environment as it will start yet another page. The next paragraph then begins The titlingpage environment falls between the titlepage option and the titlepage environment. Within the titlingpage environment you can use the \maketitle command, and any others you wish. It seems an odd description if the effect is intended as a feature...
    – cfr
    Jul 8, 2014 at 2:55
  • @cfr Yes, I agree that the documentation should be more clear in this regard and should mention the effect of the \newpages. I have the impression that the package author assumed users are familiar with the behaviour of \maketitle from the standard classes and wanted to follow the \newpage feature. Jul 8, 2014 at 3:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .