How could I add a note … or a footnote at the beginning of the Table of Contents, something like 'Chapters with * can be skipped on a first reading'…?
[Tex/LaTex] Adding notes to Table of Contents
footnotestable of contents
Related Solutions
While I'm not sure why one would want to add a TOC entry for the table of contents, there can be a case where this is wanted: institutions that don't know better than imposing hilarious requirements for theses.
If you load the tocbibind
package with
\usepackage{tocbibind}
not only the table of contents will appear automatically, but also the list of figures, the list of tables, the bibliography and the index.
Just in case, it's easy to avoid the TOC in the TOC by adding the nottoc
option:
\usepackage[nottoc]{tocbibind}
Why didn't your method work? Because you probably are using a two-sided setup. So the \newpage
will simply end the current page (1) and \addcontentsline{toc}{chapter}{Table of contents}
appears at page 2, but \tableofcontents
starts on the next right hand page, which is number 3.
The "manual" method should be
\cleardoublepage
\addcontentsline{toc}{chapter}{\contentsname}
\tableofcontents
but a higher level method is preferable; for instance, tocbibind
works correctly also with hyperref
, while the manual method requires another intervention.
Note that with the memoir
class the declaration
\tableofcontents
adds the TOC in the TOC; the \tableofcontents*
variant doesn't.
Usually, \tableofcontents
uses a \chapter*
heading in book
, i.e. the heading formatter macro \@makeschapterhead
has to be slightly modified, and an injection of an 'arbitrary' \mytextbeforetocheading
command to executed.
In order to restrict the modifications to this toc
only (and not affecting any further \chapter*
), all has to be done a group.
\documentclass[12pt]{book}
\usepackage{xpatch}
\newcommand{\mytextbeforetocheading}{%
\begingroup
\centering%
\Huge \bfseries Some Text
\endgroup
\vskip3\baselineskip%
}
\makeatletter
\xpatchcmd{\tableofcontents}{%
\chapter%
}{%
\begingroup
\def\@makeschapterhead##1{%
\vspace*{50\p@}%
\mytextbeforetocheading%
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\Huge \bfseries ##1\par\nobreak
\vskip 40\p@
}}
\chapter%
}{\typeout{success}}{\typeout{failure}}
\xapptocmd{\tableofcontents}{\endgroup}{}{} % Close the group
\makeatother
\title{hello}
\begin{document}
\tableofcontents
\chapter{one}
\chapter{two}
\end{document}
Best Answer
You can use
\addtocontents
to add whatever you like (*) to the .toc file that is later read in by\tableofcontents
. (*) With the caveat that you adequately\protect
any fragile commands you might wish to include.Something like this might work for you:
The .toc file it produces looks like this:
which eventually leads to output that looks like this: