Was helped briliantly before, here's another small problem I do not get fixed:

Using the fancyhdr package I get, as promised, fancy headers. However, a chapter in the frontmatter gets a 0. Chaptername and the Table of Contents simply Table of Contents.

So, the aim is to get rid of everything with a zero in my make-up.

I redefine the chaptermark command as follows:

\renewcommand{\chaptermark}[1]{\markboth{ \ifnum\thechapter>0 \thechapter.\space\fi #1}{}}}

But having Appendices, numbered A, B, C etc. this gives an error as follows:

Missing number, treated as zero.

Well, to be expected. How to solve this decently?

  • 2
    Why does a chapter in the frontmatter get a 0? Please provide a minimal working example.
    – lockstep
    Feb 6, 2012 at 16:52
  • 1
    Frontmatter in a document is typically associated with an Abstract, ToC, LoF, LoT, Preface, etc. These are set as \chapter* or numberless chapters. So, printing of 0. ChapterName in the header is expected since no chapter counter has been incremented. That's also why they don't show up in the ToC, since \chapter* doesn't by default (you need to do this manually via \addcontentsline). Finally, Appendices have \thechapter set as \Alph{chapter}. You should instead test for \value{chapter}>0, rather than \thechapter>0.
    – Werner
    Feb 6, 2012 at 17:01
  • Dang -- fancyhdr produces "CHAPTER 0", contrary to the bare book class.
    – lockstep
    Feb 6, 2012 at 17:11

1 Answer 1


You should think to \thechapter as the representation of the chapter number in some strange radix: a numeric test like 100>20 would give wrong results if the left hand side is in base two and the right hand side in base 10 and you're doing something similar. So what you want to test is the "abstract" value of the counter:

  \markboth{\ifnum\value{chapter}>0 \thechapter.\space\fi #1}{}}}

You must log in to answer this question.

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