summaryrefslogtreecommitdiff
path: root/usergrps/uktug/baskervi/4_4/bailey.tex
blob: f7001cdd20912ec62cee1aaae82eec4e3476dbb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
\title{Topical Tip: making the TOC tick}
\author[R.~A. Bailey]{R.~A. Bailey\\Goldsmiths'
 College, University of London}
\begin{Article}
\renewcommand{\thepreanswer}{}

\begin{question}
I have a problem that I have not been able to solve by reading \lamport.
How can I force a table of contents to have entries for
`preface', `bibliography' and `index' (for example, like the table of contents
of \shortlamp\ itself has)? For example,  if I use the 
\verb+\chapter*{preface}+
sectioning command, no entry for the table of contents 
is generated; if I use
explicit commands such as 
\verb+\addcontentsline{toc}{chapter}{Preface}+, it
works for the preface but it generates incorrect page numbers for the
index and bibliography (maybe I put the commands in the wrong place,
but it is not obvious to me where exactly I should put them).
\label{fabrizzio}
\end{question}

\begin{answer}
The best way to get headings of funny `sections' like
prefaces in the the table of contents is to use the
counter \latexword{secnumdepth} described on pages~157 and~160 of 
\shortlamp. I use
\begin{verbatim}
     \setcounter{secnumdepth}{-1}
     \chapter{preface}
\end{verbatim}
Of course, you have to set \latexword{secnumdepth} back to its usual value
(which is~2 in the standard styles, I think) before you do
any `section' which you want to be numbered.

This is why it works. 
\verb+\chapter+
 without the star does
\begin{enumerate}
\item put something in the \latexword{.toc} file;
\item   write the chapter title;
\item if $\mbox{\latexword{secnumdepth}} \geq 0$
      then increase the counter for the
        chapter and write it out.
\end{enumerate}

The above behaviour is much more predictable than 
\verb+\addtocontents+,
which, in my opinion, should be avoided if at all possible.
\end{answer}
\end{Article}