# avoid \headrulewidth appearing at chapter beginning

I am using the following code set my headers.

\fancypagestyle{plain}
\fancyhf{}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[L]{\textit{\sffamily\ifthenelse{\isodd{\value{page}}}{\leftmark}{\rightmark}}}
\fancyhead[R]{\textit{\sffamily\thepage}}
\fancyfoot[C]{}
%\headrulewidth{0.1pt}

\renewcommand{\headrulewidth}{0.1pt}


The \headrulewidth (line below the head) is also appearing at the beginning of a chapter and I WANT TO DISABLE this.

How can I change the behaviour of the headrulewidth for the first page of a chapter?

• Please complete your code until you get a MWE for understand better your problem. – Aradnix Aug 20 '14 at 17:15
• Delete the line \fancypagestyle{plain}. – cfr Aug 20 '14 at 18:06

## 1 Answer

You have to redefine the plain pagestyle

\documentclass{report}
\usepackage{blindtext}
\usepackage{ifthen}
\usepackage{fancyhdr}

%Redefine plain
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[C]{\thepage}%
\renewcommand{\headrulewidth}{0.0pt}%
}

\pagestyle{fancy}
\fancyhead{}
\fancyhead[L]{\textit{\sffamily\ifthenelse{\isodd{\value{page}}}{\leftmark}{\rightmark}}}
\fancyhead[R]{\textit{\sffamily\thepage}}
\fancyfoot[C]{}
%\headrulewidth{0.1pt}

\renewcommand{\headrulewidth}{0.1pt}
\begin{document}
\blinddocument
\end{document}