# How to change header and page number style in book in latex?

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

for even page number :

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

for odd page number :

from become (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}


• The recent correct syntax is $...$ instead of $$...$$. Dec 18 '18 at 7:44
• That is equation, so using $$...$$ Dec 18 '18 at 7:50
• $$...$$ it is the old syntax. Have you seen the link on my previous comment? Dec 18 '18 at 8:00
• @OngkyDennyWijaya Only use $$..$$ in tex documents. As you are not using tex, but latex, you should use $...$ Dec 18 '18 at 10:18
• You can find similar headers here: tex.stackexchange.com/q/450864/36296 Dec 18 '18 at 10:21

Based on fancy header and footer

\documentclass{book}

\usepackage[table]{xcolor}
\usepackage{lipsum}

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

\fancypagestyle{mystyle}{
\color{myfancycolor}\rule{2em}{2em}\raisebox{0.5em}{\hspace{-2em}\color{white}\makebox[2em][c]{\textsf{\thepage}}}%
\vspace*{-0.8em}%
}
\leftmark
}
\color{myfancycolor}\rule{2em}{2em}\raisebox{0.5em}{\hspace{-2em}\color{white}\makebox[2em][c]{\textsf{\thepage}}}%
\vspace*{-0.8em}%
}
\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}


• @OngkyDennyWijaya You're weclome! Dec 18 '18 at 13:45