4

These are my settings for fancyhdr:

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE]{Chapter \thechapter}
\fancyhead[LO]{\textit{\nouppercase{\leftmark}}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
3

Under the default book document class, this is what \frontmatter does:

\newcommand\frontmatter{%
  \cleardoublepage
  \@mainmatterfalse
  \pagenumbering{roman}}

Note that it sets a conditional - \if@mainmatter - to false. We can use this as part of the header setting:

enter image description here

\documentclass{book}

\usepackage{fancyhdr,lipsum}

\pagestyle{fancy}
\fancyhf{}% Clear header/footer
\fancyhead[LE,RO]{\thepage}
\makeatletter
\fancyhead[RE]{\if@mainmatter Chapter \thechapter\fi}
\makeatother
\fancyhead[LO]{\textit{\nouppercase{\leftmark}}}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

\begin{document}

\frontmatter

\chapter{Front matter chapter}
\lipsum[1-10]

\mainmatter

\chapter{Main matter chapter}
\lipsum[1-10]

\end{document}
0

Simply instead of using this command :

fancyhead[RE]{Chapter \thechapter}

you only have to modify the case in which you would like to visualize the chapter :

\fancyhead[RE]{\ifnum \value{chapter}>0
Chapter \thechapter\fi}

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.