0
\documentclass[twoside]{report}
\usepackage{lipsum}
\usepackage{fancyhdr}

\pagestyle{fancy}

\begin{document}

\chapter{First}
\lipsum[1-9]

\end{document}

Given the obove as a start. I see one approach to set fancyhdr on chapter initial page is to redefine plain style, Fancyhdr does not apply same header/footer on chapter and non-chapter pages and another approach makes use of etoolbox package:

\documentclass[twoside]{report}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{etoolbox}

\pagestyle{fancy}
\patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{fancy}}{}{}

\begin{document}

\tableofcontents

\chapter{First}
\lipsum[1-9]

\end{document}

How this can be used on a two side report? So that, for example, chapter initial page header will have "some title" and other page (side) will have "other title".

Also appreciated if someone can read command above for me, I checked page 13 of manual http://mirrors.huaweicloud.com/repository/toolkit/CTAN/macros/latex/contrib/etoolbox/etoolbox.pdf though was not able to understand it.

I don't go with these approaches because they are used elsewhere as well (beside chapter first page).

Perhaps another approach will be to define a new style (let's say name can be ChapterFirstPage) and following @John_Kormylo comment it could be tweaked e.g. by:

\fancypagestyle{ChapterFirstPage}{%
 \fancyhf{} % clear all header and footer fields
 \fancyfoot[C]{\textbf{\thepage}} % except the center
 \renewcommand{\headrulewidth}{0pt}
 \renewcommand{\footrulewidth}{0pt}}

Then how can I make first page of chapter use ChapterFirstPage style, instead of plain?

  • 3
    \patchcmd is just an editing tool. In this case it copies the existing macro \chapter but replaces \thispagestyle{plain} with \thispagestyle{fancy}. What you should be looking at is the source for \chapter (report.cls). – John Kormylo Jun 3 '19 at 13:06
  • 1
    A more common solution is to change the definition of plain using \fancypagestyle. See pages 10-11 of the fancyhdr manual. – John Kormylo Jun 3 '19 at 13:15
  • This will affect other document parts (besides chapter first page), right? – KcFnMi Jun 5 '19 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.