# Fancyhdr and Epigraph Problem with page numbering

I used the fancyhdr package and put the page numbers on the left/right side at the bottom of the page. Then I used the epigraph package to put a quote on top of a chapter page. The problem is that when I insert the epigraph, the page numbering is in the middle of the page.

\documentclass[12pt,twoside]{report}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry}

\usepackage[T1]{fontenc}

\usepackage{fancyhdr}
\pagestyle{fancy}

\renewcommand{\chaptermark}[1]{\markboth{#1}{}} %chapter oben ohne Nummer
\renewcommand*\MakeUppercase[1]{#1} %macht das nich alles Großgeschrieben wird

\fancyfoot{}
\fancyfoot[LE,RO] {\thepage} %the page returns page number; R=Right O=Odd page L=LEft E=even page
\renewcommand{\footrulewidth}{0pt}
\fancypagestyle{plain}{} % empty pagestyle plan (für Seiten mit Chapter o.ä)
\fancypagestyle{plain}{
\fancyhf{} % clear all header and footer fields
\fancyfoot[LE,RO]{\thepage}
\renewcommand{\footrulewidth}{0pt}
}

\usepackage{epigraph} % für vorangestellte Zitate
\setlength{\epigraphrule}{0pt} %entfernt die Linie
\setlength{\epigraphwidth}{0.5\linewidth} % breite vom epigraph
\renewcommand{\textflush}{flushright} %rechtsbündig
\renewcommand{\epigraphflush}{flushright}

\usepackage{blindtext}
\begin{document}

\chapter{Title of Chapter one}
\epigraphhead[50]{\epigraph{\textit{This a famous quote.}}{--- Famous Person}}
\section{Section Title}
\blindtext
\subsection{Subsection Title}
\blindtext[15]
\end{document}
´´´


Not a complete answer, more a guide to a solution. The \epigraphhead macro changes the page style in order to print the epigraph in the correct left/right location. The epigraph pagestyle is a version of the plain page style which is the typical pagestyle for chapters. I think that you will have to redefine this page style (see the code in the manual texdoc epigraph). I have never used fancyhdr and it's far too late (in years) for me to try.

I think that this might be the way for you to go.

Copy epigraph.sty to epigraph2.sty (in your working directory). Then edit epigraph2.sty.

In the line \ProvidesPackage{epi...}[...] replace epigraphwithepigraph2 and suitable optional data.

Almost at the end of the file replace

\def\@oddfoot{\reset@font\hfil\thepage\hfil}
\let\@evenfoot\oddfoot}


with

\def\@oddfoot{\reset@font\hfil\thepage}
\def\@evenfoot{\reset@font\thepage\hfil}}


And then in your document \usepackage{epigraph2}

The new definitions of \@oddfoot and \@evenfoot for the epigraph pagestyle match, I hope, your document's pagestyle.

I feel that it would be too difficult (i.e., I have no idea how to do it) to extend epigraph` to cater for all the pagestyles that might be applied for chapter pages so I'll recommend that it just stays going for the typical style regarding footers.

• Thanks for the answer. I had a look at the epigraph manual, but could not find code to redefine the page style. (But I am also a bit lost in all the code) Jun 16 '20 at 20:03
• @Knallbert I have extended my answer which requires you to do some work. Please never edit the code of a package but instead make a copy and edit that. Jun 19 '20 at 18:26
• Thank you, that is working perfectly! Jun 22 '20 at 13:25