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?

3
  • 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}.
    – user31729
    Commented Aug 8, 2015 at 20:41
  • This may be a duplicate of tex.stackexchange.com/questions/107506/…. But for sure, that question should provide the details on how to accomplish this. Commented Aug 8, 2015 at 22:09
  • @R.Schumacher: It might be, but the KOMA stuff is different to memoir
    – user31729
    Commented Aug 8, 2015 at 22:25

2 Answers 2

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}
1
  • 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
    Commented Aug 9, 2015 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

0

You must log in to answer this question.

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