Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a document with a short main-body but a huge appendix. The body just has a couple of short sections, so I wouldnt like to have any Table of Contents for them. The Appendix on the other hand contains about 50 pages of a lot of different programs used to generate the results. Without a TOC it is a navigational mess. I want a TOC only for the Appendix which starts at the page the appendix starts.

\documentclass{book}
\begin{document}

\chapter*{Main Body}
So here is what I found out...

\appendix
\tableofcontents

In case you wish to reproduce these fantastic results here is the code

\chapter*{Appendix A} Program A
\chapter*{Appendix B} Program B
\chapter*{Appendix C} Program C
\chapter*{Appendix D} Program D
% and so on...

\end{document}

I tried the above and it wasnt working, though I havent found a workaround for it over the itnernet.

share|improve this question
add comment

3 Answers

You could set the tocdepth counter to -2 at the beginning, for not displaying chapters in the table of contents, and change the value of tocdepth to 0 or higher right before the appendix chapters. So you can use non-starred chapters.

\documentclass{book}
\setcounter{tocdepth}{-2}
\begin{document}
\chapter{Main Body}
So here is what I found out...

\appendix
\addtocontents{toc}{\setcounter{tocdepth}{0}}
\tableofcontents

In case you wish to reproduce these fantastic results here is the code

\chapter{Appendix A} Program A
\chapter{Appendix B} Program B
\chapter{Appendix C} Program C
\chapter{Appendix D} Program D
% and so on...

\end{document}

Alternatively, you could use the tocvsec2 package for adjusting the numbering depth:

\documentclass{book}
\usepackage{tocvsec2}
\settocdepth{part}
\begin{document}
\chapter{Main Body}
So here is what I found out...

\appendix
\settocdepth{section}
\tableofcontents
In case you wish to reproduce these fantastic results here is the code

\chapter{Appendix A} Program A
\chapter{Appendix B} Program B
\chapter{Appendix C} Program C
\chapter{Appendix D} Program D
% and so on...

\end{document}
share|improve this answer
add comment

The starred chapter commands doesn't appear in the TOC. If you use the unstarred version in the appendix, but the starred version in the main body, your example will work, I guess.

If you want the first appendix to start immediately below the TOC, the hack I added to the example will do that.

\documentclass{book}
\begin{document}

\chapter*{Main Body}
So here is what I found out...

\appendix
\tableofcontents

\begingroup
\let\clearpage\relax
\chapter{Appendix A}
\endgroup
\chapter{Appendix B} Program B
\chapter{Appendix C} Program C
\chapter{Appendix D} Program D
% and so on...

\end{document}
share|improve this answer
add comment
\documentclass{book}
\def\Chapter#1{\chapter*{#1}%
  \addcontentsline{toc}{chapter}{#1}}
\begin{document}
\chapter*{Main Body}
So here is what I found out...

\appendix
\tableofcontents

In case you wish to reproduce these fantastic results here is the code

\Chapter{Appendix A} Program A
\Chapter{Appendix B} Program B
\Chapter{Appendix C} Program C
\Chapter{Appendix D} Program D
% and so on...

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.