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  


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



  • 1
    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


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.


Based on egreg's response from Feb 29 '13, I believe this answers the question more concisely:

\usepackage{fancyhdr} % this goes in the preamble
% the next lines go in the body (i.e., between \begin{document} and \end{document}
\renewcommand{\headrule}{} % eliminate the default(?) ruled line in the header
  • 1
    I'm not convinced, since you haven't defined what the fancy page style looks like. Instead, you've only redefined what the plain page style should look like. Moreover, the original request was for a sans-serif font, while ptm (or Times) sets a serif font.
    – Werner
    Feb 16 '17 at 16:11
  • This is more concise only in the sense that it will only work on the first pages of chapters etc., as opposed to setting things up for all pages. It is just a verbatim excerpt from egreg's code, copied with the spurious claim that it omits unnecessary frivolities.
    – cfr
    Feb 24 '17 at 1:02
  • My code edit should take care of your concern about the font. I came to this page originally because of the title. I was working on a simple article, with no TOC, LOT, or LOF. So, while I have not answered the entire question, I do answer a special case---and important special case, I think (i.e., the answer another user was looking for).
    – Ana Nimbus
    Feb 24 '17 at 1:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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