5

Currently I am adding an appendix to my thesis. I want the different appendices appear in the ToC as follows:

Chapter 1
-- Section 1.1
-- Section 1.2

Chapter 2
-- Section 2.1

Appendices
-- Appendix A
-- Appendix B
-- Appendix C

Bibliography

I figured out how to do this by using the answers to this question. However, when I compile the document the ToC appears to be correct but the listing in my PDF viewer's navigation bar has the following listing

Chapter 1
-- Section 1.1
-- Section 1.2

Chapter 2
-- Section 2.1

Appendices
Appendix A
Appendix B
Appendix C
Bibliography

I would guess that this is due to the fact that every appendix is a \chapter, but in any case: How do I tell LaTeX what I want? Thanks in advance!

0

1 Answer 1

4

Maybe this is what you want to get (some more work is needed for accomplishing the same treatment for the bookmarks).

\documentclass{book}
\usepackage{appendix}

\makeatletter
\AtBeginDocument{\let\book@l@chapter\l@chapter}
\newcommand{\demotechaptersintoc}{%
  \addtocontents{toc}{\let\protect\l@chapter\protect\l@section}%
}
\newcommand{\promotechaptersintoc}{%
  \addtocontents{toc}{\let\protect\l@chapter\protect\book@l@chapter}%
}

\begin{document}

\tableofcontents

\chapter{One}

\section{A section}

\section{Another}

\chapter{Two}

\section{A section}

\section{Another}

\cleardoublepage
\appendix
\addappheadtotoc
\demotechaptersintoc

\chapter{One}

\chapter{Two}

\cleardoublepage
\promotechaptersintoc
\backmatter

\chapter{\bibname}

\end{document}

enter image description here

Of course, you shouldn't have sections in the appendices.

3
  • I upvoted because this works for me. I have one problem. Inside the appendix if I use \input{appendix_01} everything is fine. If I use \include{appendix_01} then the TOC isn't correct. Apr 29, 2018 at 5:39
  • 1
    @eflanigan00 It’s a known problem. Avoid \include
    – egreg
    Apr 29, 2018 at 8:43
  • 1
    Thanks @egreg. Is general avoid include or only for this particular case? Apr 29, 2018 at 14:11

You must log in to answer this question.

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