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 }
\fancyhead[RE]{ \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
\fancyhead{} % clear all header fields
\makeatletter
\renewcommand{\sectionmark}[1]{\markright{\thesection~~~#1}}
\renewcommand{\chaptermark}[1]{\markboth{\if@mainmatter\chaptername\\
\thechapter~~~\fi#1}{}}
\makeatother
\newcommand{\vertline} {\smash{\rule[-.5ex]{1pt}{5in}}} % head line
\fancyhead[LO]{ \sffamily \thepage {} {} {} { \vertline {} {} \nouppercase \leftmark} }
\fancyhead[RE]{ \sffamily { { \nouppercase \rightmark {} {} \vertline {} {} {} }\thepage } } %
\renewcommand{\headrulewidth}{ 0.0 pt}
\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}
Best Answer
You can use
\fancypagestyle
: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 byfancyhdr