0

I'm writing a book in two parts, but for some (silly if you ask me) reason whoever designed the book document class in TeX decided part pages needed numbers. How can I remove them?

I tried the following code, which I found here:

\usepackage{epigraph}
\usepackage{lettrine}
\makeatletter
\renewcommand\part{%
\***@openright
\cleardoublepage
\else
\clearpage
\fi
\thispagestyle{empty}%
\***@twocolumn
\onecolumn
\@tempswatrue
\else
\@tempswafalse
\fi
\null\vfil
\secdef\@part\@spart}
\makeatother
\setlength{\epigraphwidth}{9.5cm}

(I have no idea what the epigraph and lettrine packages do or whether they're needed.) However, this returns the following error when attempting to compile (XeLaTeX, for compatibility with other preamble code I have):

Extra \else.

(It did seem odd to me when I looked at that bit of code that there are \elses and \fis but no \ifs.)

I've also (perhaps naïvely) tried adding \thispagestyle{empty} immediately before or after the \part{} command in my document, but that didn't work.

MWE:

\documentclass[11pt,oneside=off,chapterprefix=on,appendixprefix=on]{book}
\usepackage{titletoc}
\begin{document}
\part{Teil eins}
\chapter{Kapitel eins}
\end{document}

If possible, I would like to keep the book class. I've read that scrbook and memoir make it easier to achieve what I want, but I have code in my preamble which is incompatible with those classes and I really don't want to start debugging that.

Rain
  • 194
  • 2
    The code you found is a really bad attempt at redefining \part in book.cls, and it leaves out some very important \if components. It is not at all a good model (aside from its being 15 years old). The page style in the current book.cls is \pagestyle{plain}, which can simply be patched (based on what's done in the post https://tex.stackexchange.com/a/19741): \usepackage{etoolbox} \patchcmd{\part}{plain}{empty}{}{} – barbara beeton Nov 08 '22 at 01:05
  • Here's the link again. I hope it solves the problem: https://tex.stackexchange.com/questions/19738/why-doesnt-pagestyleempty-work-on-the-first-page-of-a-chapter – Celdor Nov 08 '22 at 01:09
  • I think that this has nothing to do with the epigraph package (don't know about letrine); try not using them or anything based on them and see if things improve. – Peter Wilson Nov 08 '22 at 19:55
  • @barbarabeeton Yep, that works. Thanks! – Rain Nov 09 '22 at 23:15

1 Answers1

1

The easiest way to banish the page number from a \part page when using the book class is to patch the definition of \part using the patch command defined in etoolbox:

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

(More details regarding similar patching of the first page of a chapter can be found in the post https://tex.stackexchange.com/a/19741 from which I adapted this answer.)