Header-Footer – Changing Horizontal Line Color on Top of Footer in LaTeX

fancyhdrheader-footer

I would like to change the colour of the horizontal line directly above the footer. I have referenced this question and copied the relevant code below. This successfully changes the color of the horizontal line at the bottom of the header. However, I am unable to manipulate it to change the color of the line at the top of the footer.

  \renewcommand{\headrulewidth}{0.5pt}
  \renewcommand{\headrule}{\hbox to\headwidth{\color{mycustomcolor}\leaders\hrule height \headrulewidth\hfill}}
  \renewcommand{\footrulewidth}{0.5pt}

I tried changing the \headrule to \footrule in the second line but it did not work and I do not have a solid understanding of how to make the correct changes to apply it to the footer.

Any help is greatly appreciated, thanks.

Best Answer

This works....

\documentclass{article}

\usepackage{xcolor}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\headrule}{\hbox to\headwidth{\color{red}\leaders\hrule height \headrulewidth\hfill}}
\renewcommand{\footrulewidth}{0.5pt}
\renewcommand{\footrule}{\hbox to\headwidth{\color{red}\leaders\hrule height \footrulewidth\hfill}}
\pagestyle{fancy}

\begin{document}
    hello
\end{document}