[Tex/LaTex] Redefining fancyhdr for “plain” changes non-chapter pages’ header/footer

fancyhdr

Relevant definition of fancy headers and footers for all pages, followed by redefinition of the footer for chapter pages:

\usepackage{fancyhdr}

\fancyhead[R]{\leftmark}
\fancyhead[C,L]{}
\fancyfoot[R]{\thepage}
\fancyfoot[C]{}
\fancyfoot[L]{\textit{\thesistitle}}
\renewcommand{\footrulewidth}{0.4pt}

\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[R]{\thepage}
\fancyfoot[L]{\textit{\thesistitle}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}}

If I use this without the second part (the redefinition of plain style), all non-chapter pages have the correct \leftmark (current chapter). However, if I add the bit concerning the fancyhdr for chapter pages, the command \leftmark gets ignored throughout the entire document.

Ideally, I want the \leftmark (current chapter) to show up in every non-chapter page, and have chapter page carry an empty header.

What am I doing wrong?

Best Answer

You have to add \pagestyle{fancy} before, say, \begin{document}

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

\fancyhead[R]{\leftmark}
\fancyhead[C,L]{}
\fancyfoot[R]{\thepage}
\fancyfoot[C]{}
\fancyfoot[L]{\textit{thesistitle}}
\renewcommand{\footrulewidth}{0.4pt}

\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[R]{\thepage}
\fancyfoot[L]{\textit{thesistitle}}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0.4pt}}

\pagestyle{fancy}   %%<----------- this added
\begin{document}
  \Blinddocument
\end{document}

enter image description here