2

As the title says. The heading on the page following the Abstract looks like this:

CHAPTER 0. ABSTRACT

How can I remove the unnecessary Chapter number from the headings in the frontmatter?

\documentclass{book}
\usepackage{fancyhdr}
\begin{document}
\frontmatter
\pagestyle{fancy}
\chapter{Abstract}
Why does it say ``Chapter 0.'' on the next page?
\tableofcontents
\mainmatter
\chapter{First}
\end{document}
1
  • fancy uses the ruled header style, with \thechapter etc. information. Since frontmatter disables the numbering, the chapter number is still 0. Either redefine the headings or apply \pagestyle{fancy} after the abstract chapter
    – user31729
    Commented Jan 31, 2016 at 17:08

1 Answer 1

3

The fancyhdr package provides, by default, the definition of \chaptermark used in report.cls when \pagestyle{headings} is in force.

The book class instead has a check for \if@mainmatter:

  \def\ps@headings{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty
      \def\@evenhead{\thepage\hfil\slshape\leftmark}%
      \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
    \def\chaptermark##1{%
      \markboth {\MakeUppercase{%
        \ifnum \c@secnumdepth >\m@ne
          \if@mainmatter
            \@chapapp\ \thechapter. \ %
          \fi
        \fi
        ##1}}{}}%
    \def\sectionmark##1{%
      \markright {\MakeUppercase{%
        \ifnum \c@secnumdepth >\z@
          \thesection. \ %
        \fi
        ##1}}}}

So you should supplement your code with the right definition. There's still a small problem, in that the pages of the table of contents will have two “CONTENTS” in the header, because \tableofcontents uses \@mkboth; you can fix it by redefining it.

\documentclass{book}
\usepackage{fancyhdr}
\begin{document}
\pagestyle{fancy}
\makeatletter
\renewcommand\chaptermark[1]{%
  \markboth{\MakeUppercase{%
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \@chapapp\ \thechapter. \ %
      \fi
    \fi
    #1}}{}%
}
\renewcommand\@mkboth[2]{\markboth{#1}{}}
\makeatother

\frontmatter
\chapter{Abstract}
Why does it say ``Chapter 0.'' on the next page?
\tableofcontents
\mainmatter
\chapter{First}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .