6

I am writing a book of puzzles in LaTeX, using the book class. The \thispagestyle{empty} command has successfully removed page numbers on all the \chapter pages, but so far no combination of \newpage and \thispagestyle{empty} before and/or after a \part command has been able to remove the page number at the center of the bottom of the \part page.

\newpage
\tableofcontents
\thispagestyle{empty}
\newpage
\thispagestyle{empty}
\newpage
\thispagestyle{empty}
\part{}
\thispagestyle{empty}
\chapter{}
\thispagestyle{empty}

The code above produces a table of contents page, then a blank page, then a \part page, then a blank page, then a \chapter page. There are no page numbers except on the \part page, and it appears to be incredibly reluctant to disappear, as you can see from the number of empty page commands surrounding the \part command!

Any help is appreciated.

Thank you.

  • 3
    Welcome to TeX.SX! Please provide a full MWE to show your situation (especially documentclass etc.) – TeXnician Mar 18 '17 at 12:27
  • 3
    If you're using book or report standard classes: Both apply \thispagestyle{plain} explicitly in the \part command, so \thispagestyle{empty} is useless here. – user31729 Mar 18 '17 at 12:33
8

The first page of a part or chapter explicitly uses the page style plain. If you want to change this behaviour, you can make plain to mean the same as empty by adding the following lines to your preamble:

\makeatletter
\let\ps@plain\ps@empty
\makeatother

After this, page style plain is no longer available. A more flexible solution is to define

\makeatletter
\let\origps@plain\ps@plain
\newcommand\MakePlainPagestyleEmpty{\let\ps@plain\ps@empty}
\newcommand\MakePlainPagestylePlain{\let\ps@plain\origps@plain}
\makeatother

Now you can equate plain with empty using \MakePlainPagestyleEmpty and revert it again by \MakePlainPagestylePlain.

Note that you can also switch the default page style using

 \pagestyle{empty}

and later switch back to

 \pagestyle{headings}

Try the following code:

\documentclass{book}
\makeatletter
\let\origps@plain\ps@plain
\newcommand\MakePlainPagestyleEmpty{\let\ps@plain\ps@empty}
\newcommand\MakePlainPagestylePlain{\let\ps@plain\origps@plain}
\makeatother
\usepackage{blindtext}
\begin{document}
\pagestyle{empty}
\MakePlainPagestyleEmpty
\tableofcontents
\part{part}
\chapter{chapter}
\Blindtext

% Revert to standard behaviour of the book class
\chapter{chapter}
\MakePlainPagestylePlain
\pagestyle{headings}
\Blindtext
\end{document}
4

Since you're using the book document class, all you need to do is issue the following two instructions in the preamble:

\usepackage{etoolbox}
\patchcmd{\part}{\thispagestyle{plain}}{\thispagestyle{empty}}{}{}

A full MWE:

\documentclass{book}

\usepackage{etoolbox}
\patchcmd{\part}{\thispagestyle{plain}}{\thispagestyle{empty}}{}{}

\begin{document}
\tableofcontents
\part{Uno}
\chapter{A}
\part{Due}
\chapter{B}
\chapter{C}
\end{document}
  • 1
    Actually I had \xpatchcmd in quite a similar way in my deleted post. (+1) – user31729 Mar 18 '17 at 15:26
  • 1
    @ChristianHupfer - I must confess I hadn't read your (deleted) posting closely before posting my own answer. Do you want to undelete yours (and I'll delete mine)? – Mico Mar 18 '17 at 15:57

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.