GeneralRemoving chapter titles for the appendix only from the ToC

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
jason2
Posts: 10
Joined: Fri Sep 24, 2010 1:47 am

Removing chapter titles for the appendix only from the ToC

Post by jason2 »

Hi,

I am using the Book class where appendices are included as chapters following the \appendix command. I am trying to remove chapter titles for the appendix only from the table of contents, leaving only the title "Appendices". This means I would like to suppress the chapter titles for each of the appendices, but I want to keep the letter numbering in the text (so using \chapter*{} is not an adequate solution).

I would like the final table of contents to look like this:

1 Introduction .............................1
1.1 Introduction section....................2

2 A substantive chapter.....................9
2.1 A section for the substantive chapter..10

Appendix...................................11

In text, I would like each appendix to start out with chapter titles of:
Appendix A
First appendix title

First appendix text....

Appendix B
Second appendix title

Second appendix text....

And so on.

My sense is that this involves two separate issues. The first issue is getting rid of the table of contents item for the appendices as is while keeping the numbering in text. I am totally clueless on how to do this.

The second issue is re-adding a new item in for the appendix section of the book (which I think I can do with a simple \addcontentsline{toc}{chapter}{Appendices} command).

Thank you!

Jason
Last edited by jason2 on Thu Feb 17, 2011 1:56 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Removing chapter titles for the appendix only from the ToC

Post by frabjous »

Without a minimal working example to test with, I imagine you want something like this:

Code: Select all

\appendix
\cleardoublepage
\addcontentsline{toc}{chapter}{Appendices}
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
\chapter{First appendix}
So here, we're sending a command to the table of contents to suppress entries whose depth is greater than -1 (-1 = part, 0 = chapter, 1 = section, and so on).

You may need to change it again later if you have any backmatter later on (e.g., a bibiography or index or whatever) that you do want in the table of contents:

Code: Select all

\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}% or 2 or whatever
But that may not work at all, depending on your set up. If it doesn't, please provide a minimal example to test with.

For more control and more options, see the appendix package.
jason2
Posts: 10
Joined: Fri Sep 24, 2010 1:47 am

Removing chapter titles for the appendix only from the ToC

Post by jason2 »

Hi,

Thank you very much. The first part of the code worked excellently, but when I try to use:

Code: Select all

\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}% or 2 or whatever
To put the table of contents of the bibliography back in, it ends up putting in the chapter headings for the the appendix chapters as well. So either everything gets suppressed, or nothing does. When I move the command:

Code: Select all

 \addtocontents{toc}{\protect\setcounter{tocdepth}{-1}} 
to inside the appendix file, I am able to see the bibliography item in the TOC, but not the "Appendices" item. The working example is below.

Code: Select all

\documentclass[11pt,a4paper,twoside,openright]{book}
\usepackage[lmargin=142pt,rmargin=95pt,tmargin=127pt,bmargin=123pt]{geometry}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\renewcommand*\oldstylenums[1]{{\fontfamily{fxlj}\selectfont #1}}
\usepackage{amsmath}%
\usepackage{amsfonts}%
\usepackage{amssymb}%
\usepackage{graphicx}
\usepackage{natbib}
\usepackage{setspace}
\usepackage{subfigure}
\usepackage{rotating}
\usepackage{hyperref}
\hypersetup{
    colorlinks,%
    citecolor=black,%
    filecolor=black,%
    linkcolor=black,%
    urlcolor=black}
\usepackage[all]{xy}
\usepackage{array}
\usepackage{multirow}
%TC:group table 0 1
%TC:group tabular 0 1

\title{Title}
\author{Me}
\date{\today}
\maketitle

\tableofcontents

\listoftables

\listoffigures

\mainmatter

\include{Introduction}

\include{Chapter1}
\include{Chapter2}
\include{Chapter3}
\include{Chapter4}

\appendix
\addcontentsline{toc}{chapter}{Appendices}
\include{Appendix}

\backmatter

\singlespacing

\bibliographystyle{apsr}
\addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
\addcontentsline{toc}{chapter}{Bibliography}
\bibliography{Bib7}{}

\end{document}
And inside the Appendix.tex file I have:

Code: Select all

\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
\chapter{Appendix 1}
\chapter{Appendix 2}
\chapter{Appendix 3}
As I mentioned, with this arrangement, I am able to see the bibliography item but not the Appendices item. When I move the first line of the previous code to the main tex file, I can see the Appendices file but not the bibliography item. Thanks!
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Removing chapter titles for the appendix only from the ToC

Post by frabjous »

From my tests, it seems to work OK if you move:

Code: Select all

\addcontentsline{toc}{chapter}{Appendices}
out of the main document and into the first line of Appendix.tex.

It is a bit funny why it doesn't work as you tried it, though. I may investigate more when I get a chance. Perhaps changing \include to \input would do the trick as well.
jason2
Posts: 10
Joined: Fri Sep 24, 2010 1:47 am

Re: Removing chapter titles for the appendix only from the T

Post by jason2 »

Thank you very much; that works great. Strange though that it should be so temperamental.
Post Reply