# Change horizontal line color on top of 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{\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.

• Using the code in Werner's answer to the linked question and changing \headrule to \footrule works for me – user31729 Jun 15 '17 at 14:41

This works....

\documentclass{article}

\usepackage{xcolor}
\usepackage{fancyhdr}
\renewcommand{\footrulewidth}{0.5pt}
\pagestyle{fancy}

\begin{document}
hello
\end{document}

• This seems to change the position of the separator, though? (the vertical space between the header and the line is larger) – Rastapopoulos Mar 14 '19 at 17:52
• @Rastapopoulos yes you are right, please how to decrease the vertical space between line-header? – Gallagher Nov 16 '19 at 20:27

JPi's answer works but adds extra space. This extra space is expected and accounted for in the standard definitions of \headrule and \footrule in fancyhdr.sty as follows.

\def\headrule{{\if@fancyplain\let\headrulewidth\plainheadrulewidth\fi

\def\footrule{{\if@fancyplain\let\footrulewidth\plainfootrulewidth\fi
\vskip-\footruleskip\vskip-\footrulewidth


Note the \vskip at the end of each definition above.

Here is a trick that does not redefine the line drawing, rather adds color to the standard definitions.

% Save standard definitions
\let\FootRule\footrule
% Add color to standard definitions.
\renewcommand\footrule{\textcolor{red}{\FootRule}}


You will notice that the renewed definitions of \headrule and \footrule do not use the same command for coloring. The redefinition of \headrule uses the \color command as using \textcolor ends up adding space. The redefinition of \footrule uses the \textcolor command as using \color ends up coloring any footer text.

Here is an MWE along the lines of JPi's answer.

\documentclass{article}

\usepackage{blindtext}
\usepackage{fancyhdr}
\usepackage{xcolor}

% Save standard definitions
\let\FootRule\footrule
% Add color to standard definitions.
\renewcommand\footrule{\textcolor{red}{\FootRule}}
\pagestyle{fancy}