9

I am using the appendix package with the \appendixpage command to insert a "Appendices" title page. However, I was wondering how I could avoid that there is a pagenumber on this inserted page.

MWE:

\documentclass{book}
\usepackage[titletoc]{appendix}
\begin{document}

\tableofcontents

\appendix \appendixpage \noappendicestocpagenum \addappheadtotoc

\chapter{Some title} Some text

\end{document}

Mind that the \noappendicestocpagenum is about a page number in the ToC, not in the text, so this is unrelated to my question.

lockstep
  • 250,273
Matthias
  • 4,051

2 Answers2

9

The page style of that appendix page is plain. You could temporarily redefine it to be empty:

\appendix
\begingroup
\makeatletter
\let\ps@plain\ps@empty
\appendixpage
\makeatother
\endgroup
\noappendicestocpagenum
\addappheadtotoc

The important line is just

\let\ps@plain\ps@empty

\makeatletter and \makeatother have been used to be able to work with @ in macro names, \begingroup and \endgroup limit the scope of this redefinition. So afterwards, plain is normal plain again.

Referring to lockstep's comment, you can do this in the preamble instead. Define

\makeatletter
\newcommand*{\myappendixpage}{%
  \begingroup
  \let\ps@plain\ps@empty
  \appendixpage
  \endgroup}
\makeatother

and later in the document just use it:

\appendix
\myappendixpage
\noappendicestocpagenum
\addappheadtotoc

Or redefine \appendixpage in the preamble:

\let\plainappendixpage\appendixpage
\makeatletter
\renewcommand{\appendixpage}{%
  \begingroup
  \let\ps@plain\ps@empty
  \plainappendixpage
  \endgroup}
\makeatother

Note, if you use \let in situations with a macro with optional argument or one made by \DeclareRobustCommand, use \LetLtxMacro of the letltxmacro package instead. Here, \let is sufficient.

hildogjr
  • 103
Stefan Kottwitz
  • 231,401
  • 1
    I prefer "preamble-only" solutions. ;-) – lockstep Dec 06 '11 at 22:07
  • 1
    Like often, it's directly demonstrated in the body. Of course it can go to the preamble, for example just define \myappendixpage with this code in the preamble and use that instead. – Stefan Kottwitz Dec 06 '11 at 22:10
  • @Lockstep: I agree. But on the other hand, Stefan's solution is less dependent on the internals of the appendix package, right? – Matthias Dec 06 '11 at 22:16
  • @Stefan: I was about to ask that. Would it also be possible to redefine \appendixpage? – Matthias Dec 06 '11 at 22:17
  • @Matthias: a) Stefan's solution at least needs to check what the appendix package actually does (e.g., it could have defined an entirely new page style and used it) b) You're using the package, and therefore should not shy away from a solution that also "uses" its internals. – lockstep Dec 06 '11 at 22:20
  • @Lockstep: I disagree with b), this breaks the encapsulation/information hiding principle, which is a cornerstone of functional and object oriented programming. Anyway, if there is no other way, it is of course not a big problem to use internals. – Matthias Dec 06 '11 at 22:25
  • 1
    @Matthias Yes, I added a version. – Stefan Kottwitz Dec 06 '11 at 22:26
  • @Matthias: Re b) -- You may be right in general, but in the specific case the appendix package simply hardcodes a specific page style for the "Appendices" title page, which surely is also bad programming practice. – lockstep Dec 06 '11 at 22:28
  • @lockstep: Agreed :) – Matthias Dec 06 '11 at 22:30
  • @lockstep I like patching :) However, I hesitate recommending it, though it's often very short code. – Stefan Kottwitz Dec 06 '11 at 22:33
  • @Stefan: I'm using this in my book to create a plain appendix page and I like it. The only problem I'm having is that it seems to show up in my TOC looking like a chapter (with no number, which is good), but in the PDF TOC, it is a chapter. Is there any way to make it a part (but still plain) – Pete P Jun 04 '19 at 23:12
5

Use the etoolbox package to patch the \@chap@pppage macro.

\documentclass{book}

\usepackage[titletoc]{appendix}

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@chap@pppage}{\thispagestyle{plain}}{\thispagestyle{empty}}{}{}
\makeatother

\begin{document}

\tableofcontents

\appendix
\appendixpage
\noappendicestocpagenum
\addappheadtotoc

\chapter{Some title}

Some text.

\end{document}
lockstep
  • 250,273