# [Tex/LaTex] How to change the color of the foot page using fancyhdr package

etoolboxfancyhdr

I'm using "facyhdr" to add a footer on all my pages, and I also use the extension "etoolbox" to color it, but the problem is that it also color the page number, do you know how to color only the footer ?

Here is the code I'm using:

\usepackage{fancyhdr}
\usepackage{etoolbox}
\pagestyle{fancy}
\fancyfoot[R]{confidential}

\makeatletter
\patchcmd{\@fancyfoot}{\rlap}{\color{red}\rlap}{}{}
\patchcmd{\footrule}{\hrule}{\color{red}\hrule}{}{}
\makeatother


Thank you

From your code it looks like you want to color the foot rule and the word confidential, but not the page number that also appears in the footer. To color the the foot rule you want to append \color{green} to it. That can be dome as in the previous answer, or as below which gives roughly the same result but without knowing the definition of \footrule. Then, you can put in whatever you like in the header and footer, so why not color it directly?

\documentclass{article}
\usepackage{xcolor}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot[R]{\textcolor{red}{confidential}}
\footrulewidth=1pt
\futurelet\TMPfootrule\def\footrule{{\color{green}\TMPfootrule}}
%%
\usepackage{lipsum}
%%%%%%%
\begin{document}
\section{First}
\subsection{First sub}
\lipsum
%%%%%%%
\end{document}


This gives the footer below.