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.

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

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

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.