7

We are working on a book (class scrbook) where we would like to have two separate table of contents: one at the beginning of the document for the actual "content" of the book and another one just before the first chapter of the appendix starts, which only contains the chapters and sections of the appendix. The appendix itself shall not appear in the main table of contents. (background: the content of the book will be printed, while the appendix will only be available online as a PDF file)

Something like that:

Table of Contents
1   First chapter .... 1
1.1 A section ........ 2

First chapter
text text text

A section
text text text

Appendix
1   Something ....... 5
1.1 Specific ........ 6

Appendix A
Something
text text text

A.1 Specific
text text text

I am a bit confused by the possibilities given by different packages like "appendix", "titletoc", "tocloft", ...

Does anyone know how to achieve this?

MattAllegro
  • 1,546
taocp
  • 343
  • 1
    Welcome to TeX.SX! Either it could be done with KOMA options, but I am no expert or you give minitoc or etoc packages a try. Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Aug 08 '15 at 20:41
  • This may be a duplicate of http://tex.stackexchange.com/questions/107506/separate-table-of-contents-for-appendices. But for sure, that question should provide the details on how to accomplish this. – R. Schumacher Aug 08 '15 at 22:09
  • @R.Schumacher: It might be, but the KOMA stuff is different to memoir –  Aug 08 '15 at 22:25

2 Answers2

9

Here is a solution using etoc package

\documentclass{scrbook}
\usepackage{etoc}

\begin{document}
\etocdepthtag.toc{mtchapter}
\etocsettagdepth{mtchapter}{subsection}
\etocsettagdepth{mtappendix}{none}
\tableofcontents‎‎
\chapter{First chapter}
text text text

\section{A section}
text text text

\subsection{A subsection}
text text text

\appendix

\etocdepthtag.toc{mtappendix}
\etocsettagdepth{mtchapter}{none}
\etocsettagdepth{mtappendix}{subsection}
\tableofcontents‎‎
\chapter{Appendix A}
text text text

\section{Specific}
text text text

\subsection{A subsection}
text text text

\end{document}
touhami
  • 19,520
  • 1
    Thank you very much, this is exactly how it is supposed to be. My Texlive 2012 installation did not contain the etocs package so I upgraded to Texlive 2015. I added another \etoctocstyle{1}{Appendix Heading} in order to get the table of contents for the appendix with a dedicated title. – taocp Aug 09 '15 at 12:28
5

Update Here is a suggestion without any additional package, but it needs KOMA-Script version 3.23 or newer.

\documentclass[appendixprefix]{scrbook}[2017/04/13]

\DeclareNewTOC[%
  owner=\jobname,
  listname={\contentsname~(\appendixname)},% title of the appendix ToC
]{atoc}

\makeatletter
\newcommand*\appendixwithtoc{%
  \appendix
  \renewcommand*{\ext@toc}{atoc}%
  \scr@ifundefinedorrelax{hypersetup}{}{\hypersetup{bookmarkstype=atoc}}%
  \listofatocs
}
\makeatother

\usepackage{blindtext}
\begin{document}
\tableofcontents
\chapter{Chapter I}
\section{Section I}
\chapter{Chapter II}

\appendixwithtoc
\chapter{Annex I}
\section{Section of Annex I}
\chapter{Annex II}
\end{document}

Original answer

Here is another suggestion using the KOMA-Script package scrwfile:

\documentclass[appendixprefix]{scrbook}
%
\usepackage{scrwfile}
\TOCclone[\contentsname~(\appendixname)]{toc}{atoc}
\newcommand\StartAppendixEntries{}
\AfterTOCHead[toc]{%
  \renewcommand\StartAppendixEntries{\value{tocdepth}=-10000\relax}%
}
\AfterTOCHead[atoc]{%
  \edef\maintocdepth{\the\value{tocdepth}}%
  \value{tocdepth}=-10000\relax%
  \renewcommand\StartAppendixEntries{\value{tocdepth}=\maintocdepth\relax}%
}
\newcommand*\appendixwithtoc{%
  \cleardoublepage
  \appendix
  \addtocontents{toc}{\protect\StartAppendixEntries}
  \listofatoc
}
%
\usepackage{blindtext}
\begin{document}
\tableofcontents
\chapter{Chapter I}
\section{Section I}
\chapter{Chapter II}

\appendixwithtoc
\chapter{Annex I}
\section{Section of Annex I}
\chapter{Annex II}
\end{document}

enter image description here

enter image description here

esdd
  • 85,675