General ⇒ Removing chapter titles for the appendix only from the ToC
Removing chapter titles for the appendix only from the ToC
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
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Removing chapter titles for the appendix only from the ToC
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
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}
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
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.