2

I want to change original header of book in the latex,

for even page number :

From enter image description here become enter image description here (Page number on the black square with shadow and add line below the chapter name & page number)

for odd page number :

from enter image description here become enter image description here (Page number on the black square with shadow and add line below the subchapter name & page number)

My code is :

\documentclass[a4paper,12pt,twoside]{book}
\usepackage[left=3.00cm, right=2.00cm, bottom=2.00cm, top=2.00cm]{geometry}
\usepackage[Lenny]{fncychap}
\usepackage{amsmath}
\usepackage{newtxtext,mathptmx}

\begin{document}
    \chapter{CHAPTER TEST}
    \section{TEST1}
    $$\Gamma(n)=\int\limits_0^\infty x^{n-1}e^{-x}dx$$
    This is Gamma function.
    \subsection{SUBTEST}
    \newpage
    \section{TEST2}
    blablabla
    \newpage
    \section{TEST3}
\end{document}

How to do that? Please help me. Thank you.

1 Answers1

1

Based on fancy header and footer

\documentclass{book}

\usepackage[top=3cm,bottom=3cm,left=2.5cm,right=2.5cm,headheight=23pt,headsep=25pt,heightrounded,footskip=1.5cm]{geometry}
\usepackage[table]{xcolor}
\usepackage{lipsum}

% Page style
\usepackage{fancyhdr}
\fancyhead{}
\fancyfoot{}
\colorlet{myfancycolor}{black}

\fancypagestyle{mystyle}{
    \renewcommand*\headrulewidth{1pt}
    \fancyhead[OR]{%
      \color{myfancycolor}\rule{2em}{2em}\raisebox{0.5em}{\hspace{-2em}\color{white}\makebox[2em][c]{\textsf{\thepage}}}%
      \vspace*{-0.8em}%
    }
    \fancyhead[OL]{%
        \leftmark
    }    
    \fancyhead[EL]{%
      \color{myfancycolor}\rule{2em}{2em}\raisebox{0.5em}{\hspace{-2em}\color{white}\makebox[2em][c]{\textsf{\thepage}}}%
      \vspace*{-0.8em}%
    }   
    \fancyhead[ER]{%
        \rightmark
    }
}


\pagestyle{mystyle}

\begin{document}


\chapter{Revue de littérature}
\lipsum[1-7]
\lipsum[1-7]
\lipsum[1-7]

\section{Définition}
\lipsum[1-7]

\chapter{Les hypothèses}
\lipsum[1-7]



\end{document}

enter image description here