Including an appendix chapter using \include{chapter_appendixA} results in a 'weird error' in overleaf (compiling with XeLaTeX):

! Missing number, treated as zero. p l.1 \chapter{chapter_appendixA} A number should have been here; I inserted `0'.

! Package PGF Math Error: Unknown function `A' (in '-A*\LabelSize '). See the PGF Math package documentation for explanation. Type H for immediate help.

The chapter_appendixA.tex file only includes the following:

Some text

Other appendix examples do not include a number there. The error arises when activating the gray chapter label boxes using \AddLabels from "Show current chapter number on each page margin" Does anyone have an idea?

My main code is the following:




% avoid annoying errors when using Koma-Script with bibtex





\rehead{\small{Chapter \thechapter}}

\chapter{A chapter}
    Some text




With accompanyingpreamble.tex:

%% FONTS %%
\setmainfont{Linux Libertine O} 
\setsansfont{Linux Biolinum O}

%Set chapter titles and numbering

%% chapter numbering %%


% Create header for odd (o) and even (e) pages

\usepackage[times]{quotchap}   % fancy chapter beginning


% Gray boxes for chapter numbering on pages



        \ifodd\value{page} %
          angle=90, position={current page.east|-current page text area.north  east}, vshift=8pt, hshift=-\thechapter*\LabelSize,
          \tikz\node[fill=gray!30,anchor=west,text width=\LabelSize,
            align=center,text height=15pt,text depth=10pt,font=\large\sffamily] {\thechapter};  }%
          angle=90, position={current page.west|-current page text area.north west}, vshift=-8pt, hshift=-\thechapter*\LabelSize,
          \tikz\node[fill=gray!30,anchor=west,text width=\LabelSize,
            align=center,text height=15pt,text depth=10pt,font=\large\sffamily] {\thechapter}; }%

  • I'm not able to reproduce the problem with what you have provided, but I've given my best guess – see the notes on how to produce a minimum working example. – Andrew Dunning Jan 22 '19 at 21:40
  • Thank you for your comment! I have edited the question. Compilation is with XeLaTeX. The problem only appears if I include a chapter \chapter{A chapter} Some text and \AddLabels for creating the gray chapter number boxes. – TGterpa Jan 23 '19 at 7:36
  • Take a look at that link on MWEs – essentially you want to cut out everything that isn't relevant to the problem (e.g. all the extra bits in your separate preamble). You want to have one (ideally short) piece of text that respondents can paste into their computer to test. – Andrew Dunning Jan 24 '19 at 14:20
  • 1
    In \AddLabels you are using hshift=-\thechapter*\LabelSize. Here you use \thechapter as a number which is wrong, because it need not be an arabic number. For example in the appendix it is A, B etc. So you have to use either \value{chapter} or the value of another counter related to \chapter. – Schweinebacke Jan 24 '19 at 15:27

KOMA-Script has a more robust approach to adding chapter thumbs using its scrlayer-scrpage package. Download the examples from the KOMA-Script book, and use the files in the Anhang-B folder. Here is a translated version of the example with an appendix added, which will work if the chapterthumb.sty file from the examples is in the same folder:


\chapter{In the beginning it starts}\dots
\chapter{and even further}\dots
\chapter{And always on}\dots
\chapter{Goes the journey}\dots
\chapter{And further out}\dots
\chapter{Always further out}\dots


\chapter{Until the end}\dots


KOMA-Script chapterthumb example: chapter

KOMA-Script chapterthumb example: appendix

If you wish to customize it, this has been addressed several times before; see the chapterthumb tag.

| improve this answer | |
  • Thank you for your suggestion. I have removed the inclusion of the appendixpackage. However, I just found out that the problem arises when including the gray chapter boxes in the margin using AddLabels. I have edited the question accordingly. – TGterpa Jan 23 '19 at 8:10
  • I've modified my answer to show a cleaner method of adding chapter thumbs. – Andrew Dunning Jan 24 '19 at 14:46

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.