GeneralCan't change fancy Header Color!!

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

Can't change fancy Header Color!!

Post by juliette »

Hello,

I'm using the fancy header package, and applying the following command:

Code: Select all

\lhead{}
\rfoot{\thepage\ of \pageref{LastPage}}
\lfoot{}
\cfoot{}
gives me "1 of 3" in the bottom right corner just as I like, except the 3 is blue for some reason. On all three pages. I'm also using \usepackage{lastpage} to detect the last page. Does anyone know how I can change that 3 from blue to black ??

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Can't change fancy Header Color!!

Post by gmedina »

Hi juliette,

that's not the standard behaviour, can you please post a minimal working example showing the mentioned problem?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Can't change fancy Header Color!!

Post by gmedina »

I apologize for the obvious double-posting, but I have new information regarding this issue.

My guess is that the hyperref package is responsible for the color issue, as the following MWE illustrates:

Code: Select all

\documentclass{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\rfoot{\thepage\ of \pageref{LastPage}}
\lfoot{}
\cfoot{}
\usepackage{lastpage}
\usepackage{hyperref}
\hypersetup{colorlinks=true,linkcolor=blue}

\usepackage{lipsum}%just to automatically generate some text

\begin{document}

\lipsum[1-14]

\end{document}
If this is so, then a posible solution is to define a new command (that I called \mypageref in the example below) that temporarily sets the links color to black and then restores it to its original definition (which I asssumed to be blue) and to use this new command in the footer:

Code: Select all

\documentclass{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\lhead{}
\rfoot{\thepage\ of \mypageref{LastPage}}
\lfoot{}
\cfoot{}
\usepackage{lastpage}
\usepackage{hyperref}
\hypersetup{colorlinks=true,linkcolor=blue}

\newcommand*{\mypageref}[1]{%
   \hypersetup{linkcolor=black}\pageref{#1}\hypersetup{linkcolor=red}}

\usepackage{lipsum}%just to automatically generate some text

\begin{document}

\lipsum[1-14]

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
juliette
Posts: 75
Joined: Thu Nov 20, 2008 10:15 pm

Re: Can't change fancy Header Color!!

Post by juliette »

Thank you so much gmedina that worked out perfectly !! <3
apjackson
Posts: 1
Joined: Fri Oct 29, 2010 1:21 am

Re: Can't change fancy Header Color!!

Post by apjackson »

use \pageref*{LastPage} instead.
Post Reply