[Tex/LaTex] Change aspect of headrule and footrule on chapter pages

header-footertitlepstitlesec

I want to customize the aspect of headrule and footrule in my document, using report class and titlesec.
Unfortunatly, my redefinition of \makeheadrule and \makefootrule is not taken into account for chapter pages.
Please find below a basic example with code and picture, the rule lines should be blue on both pages.

rule color on chapter page

  \documentclass{report}
    \usepackage{xcolor}
    \usepackage{lipsum}
    \usepackage[pagestyles]{titlesec}

\newpagestyle{normalStyle}
{\sethead{}{Header}{}\headrule
  \setfoot{}{Footer}{}\footrule}
\pagestyle{normalStyle}

\newpagestyle{chapterStyle}
{\sethead{}{Header}{}\headrule
  \setfoot{}{Footer}{}\footrule}
\pagestyle{chapterStyle}

\assignpagestyle{\chapter}{chapterStyle}

\renewcommand\makeheadrule{\color{cyan}\rule[-.3\baselineskip]{\linewidth}{0.4pt}}
\renewcommand\makefootrule{\color{cyan}\rule[\baselineskip]{\linewidth}{0.4pt}}

\begin{document}

\chapter{Some Chapter Title}

\lipsum

\end{document}

Best Answer

The problem is that \headrule calls \setheadrule, which then redefines \makeheadrule. This is done when the page style is set by \pagestyle or \thispagestyle (used for chapter pages). The same applies to \footrule.

Moving the redefinitions of \makeheadrule and \makefootrule into the definitions for the page styles, after \headrule and \footrule, solves this problem.

\documentclass{report}
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage[pagestyles]{titlesec}

\newpagestyle{normalStyle}{%
  \sethead{}{Header}{}\headrule
  \setfoot{}{Footer}{}\footrule
  \renewcommand\makeheadrule{\color{cyan}\rule[-.3\baselineskip]{\linewidth}{0.4pt}}
  \renewcommand\makefootrule{\color{cyan}\rule[\baselineskip]{\linewidth}{0.4pt}}
}

\newpagestyle{chapterStyle}{%
  \sethead{}{Header}{}\headrule
  \setfoot{}{Footer}{}\footrule
  \renewcommand\makeheadrule{\color{cyan}\rule[-.3\baselineskip]{\linewidth}{0.4pt}}
  \renewcommand\makefootrule{\color{cyan}\rule[\baselineskip]{\linewidth}{0.4pt}}
}

\assignpagestyle{\chapter}{chapterStyle}

\pagestyle{normalStyle}

\begin{document}

\chapter{Some Chapter Title}

\lipsum

\end{document}
Related Question