Please how I can create fancy header like the header from page 7 and above in this book: Her
2 Answers
As the sources are online (e.g. here) you may compile the following into your preamble:
\documentclass{scrreprt}
\usepackage[svgnames]{xcolor}
\usepackage{geometry}
\geometry{papersize={180mm,210mm},%
includehead,includemp,reversemp,marginparwidth=4em,%
vmargin={1.5mm,3mm},hmargin=1.75mm}%
\usepackage{scrlayer-scrpage}%
\makeatletter
\clearpairofpagestyles
\ihead{%
\smash{%
\hspace*{.5em}\rule[-\dp\strutbox]{0pt}{\headheight}\leftmark
}%
}%
\ohead*{\smash{\pagemark\hspace{2mm}}}%
\colorlet{headbackground}{DarkBlue}%
\colorlet{headline}{white}%
\setkomafont{pageheadfoot}{\small\sffamily\bfseries\color{headline}}%
\setkomafont{pagenumber}{}%
\DeclareNewLayer[head,background,
hoffset=0pt,
width=\paperwidth,
addheight=\dimexpr \topmargin+1in+\dp\strutbox\relax,
addvoffset=2\dp\strutbox,
contents={%
\color{headbackground}\rule{\layerwidth}{\layerheight}}]
{headbackground}%
\AddLayersAtBeginOfPageStyle{scrheadings}{headbackground}%
\renewcommand*{\chaptermark}[1]{%
\markleft{\ifnumbered{chapter}{\chaptermarkformat}{}#1}%
}%
\renewcommand*{\chaptermarkformat}{%
\makebox[\dimexpr \oddsidemargin+1in-.5em][r]{%
\chapapp~\thechapter:~%
}%
}%
\renewcommand*{\chapterformat}{}%
\renewcommand*{\chapterpagestyle}{scrheadings}%
\setlength{\@tempdimc}{\oddsidemargin}%
\addtolength{\@tempdimc}{1in}%
\setheadwidth[-\@tempdimc]{paper}%
\renewcommand*{\chapterheadstartvskip}{}%
\makeatother
\usepackage{blindtext}
\begin{document}
\chapter{Test}
\blinddocument
\end{document}
Thank You. I Test it, but not worked with me. I used this code:
\fancyhf{}
\fancyhead[LE,RO]{{\noindent\hspace*{\dimexpr-\oddsidemargin-1in\relax}%
\colorbox{MidnightBlue}{\makebox[\dimexpr\paperwidth-2\fboxsep\relax]{
\textcolor{white}{\rightmark}}}}%
\hspace*{-\paperwidth}}
\fancyhead[LO,LE]{\leftmark}
its worked but,
1- I can't use \noindent with :
fancyhead[LO,LE]{\leftmark}
2- the \rightmark in the center, i want it in the right side.