1

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}

\geometry{bottom=30pt,includeheadfoot, showframe}

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

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

\begin{document}

\pagestyle{plain}

Hello!  

\end{document}

How can I avoid it?

(I am compiling this on LuaTeX)

5
  • 1
    Use \fancyfoot[CO]{\textcolor{customcolor}{\thepage}}.
    – Bernard
    Commented Feb 12, 2018 at 0:51
  • You should load fancyhdr after loading/setting your geometry. See geometry, fancyhdr: \fancyfoot[C]{\thepage} is not really centered
    – Werner
    Commented Feb 12, 2018 at 0:53
  • @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
    Commented Feb 12, 2018 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
    Commented Feb 12, 2018 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
    Commented Feb 12, 2018 at 1:20

1 Answer 1

1

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}
\geometry{bottom=30pt,includeheadfoot, showframe}

\begin{document}

\pagestyle{plain}

Hello!

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .