1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| \documentclass{book}
\usepackage{fancyhdr,lipsum,xcolor,etoolbox}
\makeatletter
\patchcmd{\@part}% <cmd>
{\markboth{}{}}% <search>
{\partmark{#1}}% <replace>
{}{}% <success><failure>
\makeatother
\pagestyle{fancy}
\fancyhead{}
\renewcommand{\headrulewidth}{0.2pt}
\newcommand{\partmark}[1]{\markboth
{\color[gray]{.0}\thepart. #1}{}}
\renewcommand{\chaptermark}[1]{\markright
{\color[gray]{.0}\thechapter.\ #1}}
\renewcommand{\sectionmark}[1]{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[OL]{\nouppercase{\textbf{\leftmark}}}
\fancyhead[ER]{\nouppercase{\textbf{\rightmark}}}
\fancyfoot{}
\begin{document}
\part{A part}
\chapter{A chapter}
\lipsum[1-10]
\end{document} |
Partager