TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Why does a chapter in the frontmatter get a 0? Please provide a minimal working example. – lockstep Feb 6 '12 at 16:52
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 '12 at 17:01
Dang -- fancyhdr produces "CHAPTER 0", contrary to the bare book class. – lockstep Feb 6 '12 at 17:11
up vote 5 down vote accepted

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}{}}}
share|improve this answer
That will do, I really learn something about all those engine commands of LaTeX A new world to me, should read more about it I think! – significant Feb 6 '12 at 19:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.