[Tex/LaTex] titlesec: \assignpagestyle problem with part

header-footertitlesec

According to the titlesec documentation (section 3.5):

You can assign a page style to levels of class top and page, as well
as the default chapter with the following command:
\assignpagestyle{command}{pagestyle}

It then states (section 3.9) that

There are three classes: page is like the book \part, in a single
page, top is like \chapter …

However using \assignpagestyle with \part doesn't seem to work:

\documentclass{book}

\usepackage[pagestyles]{titlesec}  
\assignpagestyle{\part}{empty}     % Doesn't work
\assignpagestyle{\chapter}{empty}  % Works

\begin{document}

\part{Bar}
\chapter{Foo}

\end{document}

I know I can change the \part and \chapter pagestyles doing the following in the preamble

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

but since I'm using the titlesec package for my headers I wanted to simply use the \assignpagestyle command.

Best Answer

It works once you define a format for \part (the reason for this is not clear to me, but in the past I've found that the behaviour for \part commands is rather singular when using titlesec):

\documentclass{book}
\usepackage[a6paper]{geometry}% just for the example
\usepackage[pagestyles]{titlesec}  

\assignpagestyle{\part}{empty}     % Works
\assignpagestyle{\chapter}{empty}  % Works
\titleformat{\part}[display]
  {\normalfont\huge\bfseries\filcenter}{\partname\ \thepart}{22pt}{\Huge}

\begin{document}

\part{Bar}
\chapter{Foo}

\end{document}

enter image description here