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
General ⇒ Removing chapter titles for the appendix only from the ToC
Removing chapter titles for the appendix only from the ToC
Last edited by jason2 on Thu Feb 17, 2011 1:56 am, edited 1 time in total.
Removing chapter titles for the appendix only from the ToC
Without a minimal working example to test with, I imagine you want something like this:
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:
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.
Code: Select all
\appendix
\cleardoublepage
\addcontentsline{toc}{chapter}{Appendices}
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
\chapter{First appendix}
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
For more control and more options, see the appendix package.
Removing chapter titles for the appendix only from the ToC
Hi,
Thank you very much. The first part of the code worked excellently, but when I try to use:
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:
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.
And inside the Appendix.tex file I have:
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!
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
Code: Select all
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
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}
Code: Select all
\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
\chapter{Appendix 1}
\chapter{Appendix 2}
\chapter{Appendix 3}
Removing chapter titles for the appendix only from the ToC
From my tests, it seems to work OK if you move:
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.
Code: Select all
\addcontentsline{toc}{chapter}{Appendices}
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.
Re: Removing chapter titles for the appendix only from the T
Thank you very much; that works great. Strange though that it should be so temperamental.