TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)?



\fancyhf{} % remove everything     
\fancyhead{} % clear all header fields  

\renewcommand{\chaptermark}[1]{\markboth{\if@mainmatter\chaptername\     \thechapter~~~\fi#1}{}}

\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}}



share|improve this question
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 {} {} {} {} – yo' Feb 9 '13 at 14:41

You can use \fancypagestyle:

\fancyhf{} % remove everything     
\fancyhead{} % clear all header fields  

\renewcommand{\chaptermark}[1]{\markboth{\if@mainmatter\chaptername\ \thechapter\quad\fi#1}{}}

\newcommand{\vertline}{\smash{\rule[-.5ex]{1pt}{5in}}}  % head line


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

share|improve this answer

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:

\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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.