# How to tweak the font of page number in the whole document?

First fancyhdr is loaded to change the font of page number.

The following commands are used to change the font to sans serif:

\fancyhead[LO]{ \sffamily \thepage }


However, in the first page of TOC, LOT, LOF and Chapter, the font is still serif.

Moreover, how to change the font of the page numbers (for chapters, sections, subsection, figures and tables) in TOC, LOT, LOF, including the Roman/roman number style for frontmatters as well?

Is the a simple command to change this font for the whole document (book, report or article)?

MWE:

\documentclass[12pt]{book}
\usepackage{kantlipsum}
\usepackage{libertine}

\usepackage[]{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % remove everything

\makeatletter
\renewcommand{\sectionmark}[1]{\markright{\thesection~~~#1}}
\renewcommand{\chaptermark}[1]{\markboth{\if@mainmatter\chaptername\     \thechapter~~~\fi#1}{}}
\makeatother

\fancyhead[LO]{ \sffamily  \thepage {} {} {}      {   \vertline   {} {}       \nouppercase \leftmark}  }
\fancyhead[RE]{ \sffamily { {  \nouppercase \rightmark {} {}   \vertline   {} {} {}  }\thepage } }  %

\newcommand{\myfig}{\begin{figure}\caption{A figure caption}\end{figure}}
\newcommand{\mytab}{\begin{table}\caption{A table caption}\end{table}}

\begin{document}
\tableofcontents
\listoffigures
\listoftables
\chapter{Coo1}
\kant[1]
\myfig\mytab\myfig\mytab\myfig\mytab
\section{Soo1}
\kant[2-5]
\section{Soo2}
\kant[6-9]

\chapter{Coo2}
\section{Soo3}
\kant[11-6]
\myfig\mytab\myfig\mytab\myfig\mytab
\section{Soo4}
\kant[22-25]

\end{document}

-
Are you sure about the code for \fancyhead? It's quite a mess. For the specific problem, look on the site for \fancypagestyle and plain. For instance, tex.stackexchange.com/questions/18653/… –  egreg Feb 8 '13 at 23:51
Concerning your code, you might be interested in \quad in place of {} {} {} {} –  tohecz Feb 9 '13 at 14:41

You can use \fancypagestyle:

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{} % remove everything

\makeatletter
\makeatother

\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[C]{\sffamily\thepage}
}


Instead of eye computed spacings, it's better to use known lengths, for instance \quad. Don't forget to set \headheight to a correct value, as recommended in the log file by fancyhdr

-

You have "discovered" that

in the first page of TOC, LOT, LOF and Chapter, the font is still serif

even though the fancy page style has been changed to use a sans-serif font for page numbers. This is the case because the first pages of chapters (and of chapter-like entities such as the ToC, LoT, and LoF) use the plain page style rather than the fancy style.

To modify the plain page style so that it uses a sans-serif font for page numbers, you could include the following code in your document's preamble:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\ps@plain}{\thepage}{\sffamily\thepage}{}{}
\makeatother
\pagestyle{plain} % execute this command to load the new settings


Alternatively, since you're already using the fancyhdr package, you could proceed along the lines of @egreg's answer and use that package's \fancypagestyle{plain}{...} macro to modify the plain page style.

-