1

I have a problem with the numbering of my appendix. This is my MWE:

\documentclass[oneside, openright, 12pt]{book}
\sloppy

\usepackage[plainpages=false,pdfpagelabels]{hyperref}
\hypersetup{
    pdftitle={title},
    pdfsubject={subject},
    pdfauthor={author},
    pdfborder={0 0 0}
}

\usepackage[titles]{tocloft}
\newcommand\tocentry[1]{\addcontentsline{toc}{chapter}{#1}}

\begin{document}
    \pagenumbering{Alph}

    \pagenumbering{roman}
    \setcounter{page}{1}
    \tableofcontents

    \listoffigures
    \tocentry{Figures}

    \pagenumbering{arabic}
    \chapter{chapter1}
    dsfdsfdsfsdf
    \section{section1} 
    dsafdsaffdasfdasfffadsfffadsff
    \section{section2} 
    gfsdcsdfdsf
    \section{section3}
    dsfdsfdsf

    \tocentry{Appendix}
    \chapter*{appendix}
    \section{appendix1}
    \section{appendix2}

    \bibliographystyle{alpha}
    \bibliography{mwe/lit} 
    \tocentry{Literature}

\end{document}

As you can see in the following screenshot the numbering in my appendix simply continues from the last chapter. wrong numbering I want it to be A, B,... I figured out that \chapter*{} does not increment the necessary counters - there are many similar questions on stackoverflow... I fixed my problem like this:

\setcounter{chapter}{\thechapter+1}
\setcounter{section}{0}
\renewcommand{\thesection}{\Alph{section}}  
\chapter*{appendix}

It solved my problem. correct numbering But now, I've observed another problem with my Hyperref table of contents within the pdf viewer: My appendix and literature are placed as a subsection of chapter1->section3. wrong numbering in pdf contents

Does anyone know how to solve this problem? Thanks in advance :-)

2

If you really want to add your appendices as sections instead chapters (I do not recommend this) you can use:

\usepackage{xpatch}
\xapptocmd\appendix
  {\chapter*{Appendix}\addcontentsline{toc}{chapter}{Appendix}\renewcommand\thesection{\Alph{section}.}}
  {}{\PatchFailed}

and

\appendix
\section{appendix1}
\section{appendix2}

Additional remarks:

Use package tocbibind for the ToC entrys of the lists and the bibliography to ensure the correct page numbers in the table of contents.

Use \cleardoublepage before \pagenumbering{...}.

\documentclass[oneside, openright, 12pt]{book}
\usepackage[nottoc]{tocbibind}% add a ToC entry for lists, index and bibliography

\usepackage{xpatch}
\xapptocmd\appendix
  {\chapter*{Appendix}\addcontentsline{toc}{chapter}{Appendix}\renewcommand\thesection{\Alph{section}.}}
  {}{\PatchFailed}

\usepackage[plainpages=false,pdfpagelabels]{hyperref}
\hypersetup{
    pdftitle={title},
    pdfsubject={subject},
    pdfauthor={author},
    pdfborder={0 0 0}
}

\begin{document}
\pagenumbering{roman}
\tableofcontents
\listoffigures

\cleardoublepage% <-must be added before \pagenumbering
\pagenumbering{arabic}
\chapter{chapter1}
Text
\section{section1} 
Text
\section{section2} 
Text
\section{section3}
Text

\appendix
\section{appendix1}
\section{appendix2}

\bibliographystyle{alpha}
\bibliography{mwe/lit} 
\end{document}

Result:

enter image description here

enter image description here

  • Thank you very much! I nevertheless decided to use Bobyandbob's solution. – lukasl1991 Aug 1 '17 at 18:32
  • Do I have to use \cleardoublepage before every \pagenumbering call ??? – lukasl1991 Aug 2 '17 at 6:54
  • The page numbering is changed on the page where \pagenumbering is called. You have to ensure that this is not the last page of the previous chapter (or list). For a onesided document or a twosided with openright it would be enough to shift \pagenumbering after \chapter, because \chapter starts a new page. But if you switch to a twosided document with openany, you have to ensure that the page numbering changes on a right page. – esdd Aug 2 '17 at 7:13

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.