1

I'm writing a report with memoir and would like to set the color of the title page. The pagecolor package looks promising but I can't figure out how to set the color of only the first of two pages in a twoside report.

As an example, here's a MWE but notice how the first two pages are red.

\documentclass{memoir}

\usepackage{lipsum}
\usepackage{pagecolor}
\title{Test}

\begin{document}

\newpagecolor{red}
\begin{titlingpage}
  \maketitle
\end{titlingpage}

\newpagecolor{white}
\chapter{First chapter}
\lipsum[1]

\end{document}

Any ideas?

  • Why did you not say that you did not stick to titlingpage? It would be much easier then. – user31729 Apr 27 '15 at 14:15
  • The accepted solution still works with the titlingpage environment. flav's answer used \maketitle on its own, but either way, aftepage was what I was looking for. Thanks for your behind-the-scenes solution though. Might come in handy for other problems. – jkeirstead Apr 27 '15 at 17:08
0

You can use afterpage package :

\documentclass{memoir}

\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{pagecolor}
\usepackage{afterpage}

\title{Test}
\author{flav}
\begin{document}

 \newpagecolor{gray}\afterpage{\restorepagecolor}
 \maketitle

 \chapter{First chapter}
 \lipsum[1]

 \end{document}

see : How to change the background color only for the current page?

  • Great, this works with a few minor edits as proposed. – jkeirstead Apr 27 '15 at 14:08
2

The relevant portion of memoir.cls for the title is

\newcommand{\@maketitle}{%
  \let\footnote\@mem@titlefootkill
  \ifdim\pagetotal>\z@
    \newpage
  \fi
  \null
  \vskip 2em%
        \vspace*{\droptitle}
  \maketitlehooka
  {\@bspretitle \@title \@bsposttitle}
  \maketitlehookb
  {\@bspreauthor \@author \@bspostauthor}
  \maketitlehookc
  {\@bspredate \@date \@bspostdate}
  \maketitlehookd
  \par
  \vskip 1.5em}

As such, \maketitlehookd is basically the last thing, which should be on the first titlepage. A \clearpage after this hook should do, but is not the best solution. If there is more content on the first page, such that the content of the hooks go to the 2nd page, the clearpage should be there, but in this sense, the 2nd page is still a titlepage and should be in the same colour, in my point of view. Patching the end of \@maketitle is perhaps the better way.

\documentclass{memoir}

\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{pagecolor}

\usepackage{xpatch}
% Patching the end of `\@maketitle` -- Assume that nothing is on the second page. 
\xpatchcmd{\@maketitle}{\par
\vskip 1.5em}{%
\par
\vskip 1.5em
\clearpage\newpagecolor{white}}{}{}%


\title{Test}

\begin{document}

\newpagecolor{red}
\begin{titlingpage}
  \maketitle
\end{titlingpage}

\newpagecolor{white}
\chapter{First chapter}
\lipsum[1]

\end{document}

enter image description here

  • That doesn't answer the question about the first two pages being red, versus only the true title page. – jkeirstead Apr 27 '15 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.