# headings and footnotes in first page different

I want that the first page of each chapter has no headrule. Here is a MWE

\documentclass[a4paper,openright,10pt]{book}
\usepackage{vmargin}
\usepackage{fancyhdr}
\usepackage{emptypage}
\renewcommand{\footrulewidth}{0.5pt}}
\pagestyle{fancy}
\usepackage{afterpage}

\begin{document}
\pagestyle{plain}

\markboth{}{}
\chapter{In}
\vspace{-50pt}
\rule[0pt]{\textwidth}{1pt}

\sffamily

\thispagestyle{plain}{
%\markboth{I}{I}
\renewcommand{\footrulewidth}{0.5pt}
\rfoot[]{\thepage}
\cfoot[]{}
\lfoot[\thepage]{}}

\markboth{I}{I}
\rfoot[]{\thepage}
\cfoot[]{}
\lfoot[\thepage]{}
\section{M}
\end{document}


By doing so I get a headrule with "I" on the right side and I just want this last 2 things (headrule and "I") to not appear. Could someone please help me?

• Please post a compilable document, not just fragments that have to be glued together – user31729 Mar 7 '16 at 22:15
• We've had this question before - the first page of a \chapter usually issues the plain page style. You've redefined this rather than creating a new one and tapping into \chapter. Either way, this is discussed and solved in fancyhdr does not apply same header/footer on chapter and non-chapter pages – Werner Mar 8 '16 at 0:26

Something like this? I've defined a special chapterfirstpage style that deletes the headrule and all footers for the chapter start page, by replacing \thispagestyle{plain} with \thispagestyle{chapterfirstpage}

\documentclass[a4paper,openright,10pt]{book}
\usepackage{vmargin}

\usepackage{fancyhdr}
\usepackage{emptypage}
\usepackage{xpatch}

\fancypagestyle{plain}{%
\renewcommand{\footrulewidth}{0.5pt}
}

\fancypagestyle{chapterfirstpage}{%
\renewcommand{\footrulewidth}{0.5pt}%
\fancyhf{}%
\rfoot{\thepage}%
}

\usepackage{afterpage}
\pagestyle{fancy}
\usepackage{blindtext}

\xpatchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{chapterfirstpage}}{\typeout{Success}}{\typeout{Failed}}

\makeatletter
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\huge\bfseries \@chapapp\space \thechapter
\par\nobreak
\vskip 20\p@
\fi
\fi
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vspace{-10\p@}
\rule[0pt]{\textwidth}{1pt}
}}
\makeatother

\begin{document}

\markboth{}{}
\chapter{In}

\sffamily

\section{M}
\blindtext[10]

\chapter{Two}
\section{Foo}
\blindtext[10]

\end{document}


Note: vmargin has some issues and should be replaced with geometry, most likely.

I also incorporated the \rule... in the chapter heading \@makechapterhead command.

• It is almost perfect. but I would also like to insert the page number as footnote on the right side – Leila Mar 7 '16 at 22:56
• @Leila: See the update please. I added \rfoot{\thepage} in chapterfirstpage style – user31729 Mar 7 '16 at 22:58