3

In the question Footer ruler on first page in fancyhdr with `book` I asked about the possibility to get a footer ruler on the first page of a chapter. The answer https://tex.stackexchange.com/a/566047/44119 gave the required result for this problem.

I now have a similar problem, where I want to have the footer ruler and footer text on the first page of a chapter but when I have a part I don't want to have the footer ruler and footer text on that page.

The suggestion by @Bernard in comment on https://tex.stackexchange.com/a/566047/44119 was to use \thispagestyle{empty} but thiis didn't work, so I thought using of a \newenvironment for this but this didn't work either (my try is commented out at the moment. My MWE:

\documentclass[twoside]{book}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancyplain}
\renewcommand{\footrulewidth}{0.4pt}
%
\fancypagestyle{fancyplain}{
\fancyhf{}
\fancyhead[LE, RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\fancyfoot[LE, RO]{\bfseries\thepage}
\fancyfoot[LO, RE]{\bfseries\scriptsize Generated}
}
%
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LE, RO]{\textbf{\thepage}}
\fancyfoot[LO, RE]{\bfseries\scriptsize Generated}
\renewcommand{\headrulewidth}{0pt}}

\pagestyle{fancyplain}

\newenvironment{MyPart}{
  \fancyfoot[LO, RE]{}
  \renewcommand{\footrulewidth}{0.0pt}
}{
  \fancyfoot[LO, RE]{\bfseries\scriptsize Generated }
}

\begin{document}

%% test based on suggestion by @Bernard in comment on https://tex.stackexchange.com/a/566047/44119:
\part{Manual}
\thispagestyle{empty}

%% my own idea:
\begin{MyPart}
\part{Manual}
\end{MyPart}

\chapter{My Chapter}
\lipsum[1]
\newpage
\lipsum[1]
\newpage
\lipsum[1]

\end{document}

2 Answers 2

4

The trouble is that also \part uses the plain page style, which you have redefined to suit your needs. Worse, \part does issue a \newpage in order to force an empty verso page; your manual \thispagestyle{empty} comes thus too late.

I think the only way here is to patch the definition of \part. Either copy/paste the original definition from book.cls in your preamble with the suitabile substitution

\renewcommand\part{%    <-- use \renewcommand here
  \if@openright
    \cleardoublepage
  \else
    \clearpage
  \fi
  \thispagestyle{empty}%   <-- empty instead of plain
  \if@twocolumn
    \onecolumn
    \@tempswatrue
  \else
    \@tempswafalse
  \fi
  \null\vfil
  \secdef\@part\@spart}

or you let e.g. xpatch do the work for you

\usepackage{xpatch}
\xpatchcmd{\part}{plain}{empty}{}{}

A MWE based on your code with the second solution is

\documentclass[twoside]{book}

\usepackage{lipsum}
\usepackage{fancyhdr}

\renewcommand{\footrulewidth}{0.4pt}

\fancypagestyle{fancyplain}{
\fancyhf{}
\fancyhead[LE, RO]{\bfseries\thepage}
\fancyhead[LO]{\bfseries\rightmark}
\fancyhead[RE]{\bfseries\leftmark}
\fancyfoot[LE, RO]{\bfseries\thepage}
\fancyfoot[LO, RE]{\bfseries\scriptsize Generated}
}

\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[LE, RO]{\textbf{\thepage}}
\fancyfoot[LO, RE]{\bfseries\scriptsize Generated}
\renewcommand{\headrulewidth}{0pt}}

\pagestyle{fancyplain}

\usepackage{xpatch}
\xpatchcmd{\part}{plain}{empty}{}{}

\begin{document}

\part{Manual}

\chapter{My Chapter}
\lipsum[1]
\newpage
\lipsum[1]
\newpage
\lipsum[1]

\end{document}

enter image description here

3
  • I tested the xpatch solution for my case and this works as expected.
    – albert
    Commented Oct 9, 2020 at 11:45
  • I have a subsequent question about the word "Part" that appears and for the second part (in my case it is appendices) I would like to remove the word "Part". I'd probably best create a new question for this...
    – albert
    Commented Oct 9, 2020 at 11:50
  • Solved the removal of the "Part": \renewcommand{\thepart}{} \renewcommand{\partname}{}
    – albert
    Commented Oct 9, 2020 at 11:57
3

Using xpatch differently:

\usepackage{ xpatch} 
\makeatletter
\xpatchcmd{\@part}{#2}{#2\thispagestyle{empty}}{}{}
\makeatother

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .