[Tex/LaTex] Edit page headers

fancyhdrformattingheader-footer

I am trying to edit my page titles with fancyhdr package. I want the top left of the page to present [section number]. [section name]
in boldface and small caps. for example:

3.2. PYTHAGORAS THEOREM

I noticed that \leftmark puts the small-caps letter in a nice way (with proper space between them, and also straight, which doesn't happen with some other methods) but if I try to edit it

\renewcommand{\leftmark}{...}

I lose the small caps.
What is the best way to achieve what I want?

An example code to build on:

\documentclass[a4paper,11pt,english]{book}
\usepackage{fancyhdr}
\usepackage[english]{babel}
\fancyhead[LE,LO]{\leftmark}
\fancyhead[RE,RO]{\bfseries \thepage}
\pagestyle{fancy}

\usepackage{blindtext}
\begin{document}
    \chapter{My first chapter}
    \blindtext
    \section{My first section}
    \blindtext[10]  
\end{document}

Best Answer

I recommend using formatting commands within fancyhdr commands, such as in \fancyhead, instead of redefining \leftmark. More important, you need to use a font with bold small caps. The default font doesn't have small caps. This could be the reason why you notice you loose small caps when switching to bold.

In your example, with kpfonts, you would get bold small caps text in the header:

\usepackage{kpfonts}
\fancyhead[LE,LO]{\textsc{\textbf{\nouppercase{\leftmark}}}}

heading with bold small caps