# Page number misplaced using fancyhdr, custom color and “includefoot” geometry-option

If I color the page number with the packages fancyhdr and xcolor, I get the page number out of the space defined as "footskip" in the geometry package.

I am enclosing a MWE where you can see that if the page number is colored with \color{customcolor}, it gets misplaced (it is below the line drawn by geometry):

\documentclass{book}
\usepackage{fancyhdr}
\usepackage{geometry}
\usepackage{xcolor}

\definecolor{customcolor}{RGB}{112,112,112}

\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[CO]{\color{customcolor}\thepage}
\renewcommand{\footrulewidth}{0pt}}

\begin{document}

\pagestyle{plain}

Hello!

\end{document}


How can I avoid it?

(I am compiling this on LuaTeX)

• Use \fancyfoot[CO]{\textcolor{customcolor}{\thepage}}. – Bernard Feb 12 '18 at 0:51
• @Werner I got the same mistake in another file where I inverted the packages loading order, but thanks anyway for pointing that issue out. – oibaFox Feb 12 '18 at 1:09
• @Bernard it works perfectly, thanks! Could you please explain me why in this context there is this difference between \color{.} and \textcolor{.}? By the way, would you write your comment as an answer so that I can mark it as correct? – oibaFox Feb 12 '18 at 1:12
• I have no idea why there's a difference. I tested just in case… But I hac=ve a simpler solution with titleps that I'll add. – Bernard Feb 12 '18 at 1:20

Using \fancyfoot[CO]{\textcolor{customcolor}{\thepage}} solves the problem.

However, the titleps package, used in the place of fncyhdr doesn't have this drawback, and has a simpler syntax, with the \renewpagestyle{plain}{...} command:

\documentclass{book}

\usepackage{xcolor}
\definecolor{customcolor}{RGB}{112,112,112}

\usepackage{titleps}
\renewpagestyle{plain}{%
\setfoot{}{\color{customcolor}{\thepage}}{}
}%
\usepackage{geometry}
`