summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/generic/FAQ-en/html/FAQ-tocbibind.html
blob: 8055bf03dae7e7b46ebc18fbba12507d6a0097bb (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
53
54
55
56
57
58
59
60
61
62
<head>
<title>UK TeX FAQ -- question label tocbibind</title>
</head><body>
<h3>Bibliography, index, etc., in TOC</h3>
<p/>The standard LaTeX classes (and many others) use <code>\</code><code>section*</code> or
<code>\</code><code>chapter*</code> for auto-generated parts of the document (the tables of
contents, lists of figures and tables, the bibliography and the index).  As a
result, these items aren&#8217;t numbered (which most people don&#8217;t mind),
and (more importantly) they don&#8217;t appear in the table of contents.
<p/>The correct solution (as always) is to have a class of your own that
formats your document according to your requirements.  The macro to do
the job (<code>\</code><code>addcontentsline</code>) is fairly simple, but there is always
an issue of ensuring that the contents entry quotes the correct page.
Supposing that our the document is chapter-based (class <i>report</i>
or <i>book</i>, for example), the text:
<blockquote>
<pre>
\bibliography{frooble}
\addcontentsline{toc}{chapter}{Bibliography}
</pre>
</blockquote><p>
will produce the <em>wrong</em> answer if the bibliography is more than
one page long.  Instead, one should say:
<blockquote>
<pre>
\cleardoublepage
\addcontentsline{toc}{chapter}{Bibliography}
\bibliography{frooble}
</pre>
</blockquote><p>
(Note that <code>\</code><code>cleardoublepage</code> does the right thing, even if your
document is single-sided &#8212; in that case, it&#8217;s a synonym for
<code>\</code><code>clearpage</code>).  Ensuring that the entry refers to the right place is
trickier still in a <code>\</code><code>section</code>-based class.
<p/>If you are using <i>hyperref</i> (which will link entries in the
table of contents to the relevant place in the file), a slight
adjustment is necessary:
<blockquote>
<pre>
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Bibliography}
\bibliography{frooble}
</pre>
</blockquote><p>
The extra command (<code>\</code><code>phantomsection</code>) gives <i>hyperref</i>
something to &#8220;hold on to&#8221; when making the link.
<p/>The common solution, therefore, is to use the <i>tocbibind</i>
package, which provides many facilities to control the way these
entries appear in the table of contents.
<p/>Classes of the <i>KOMA-script</i> bundle provide this functionality
as a set of class options (e.g., <code>bibtotoc</code> to add the
bibliography to the table of contents); the <i>memoir</i> class includes
<i>tocbibind</i> itself.
<dl>
<dt><tt><i>hyperref.sty</i></tt><dd><a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/hyperref.zip">macros/latex/contrib/hyperref</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/hyperref/">browse the directory</a>)
<dt><tt><i>KOMA script bundle</i></tt><dd><a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/koma-script.zip">macros/latex/contrib/koma-script</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/koma-script/">browse the directory</a>)
<dt><tt><i>memoir.cls</i></tt><dd><a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/memoir.zip">macros/latex/contrib/memoir</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/memoir/">browse the directory</a>)
<dt><tt><i>tocbibind.sty</i></tt><dd><a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/tocbibind.zip">macros/latex/contrib/tocbibind</a> (or <a href="http://www.tex.ac.uk/tex-archive/macros/latex/contrib/tocbibind/">browse the directory</a>)
</dl>
<p/><p>This question on the Web: <a href="http://www.tex.ac.uk/cgi-bin/texfaq2html?label=tocbibind">http://www.tex.ac.uk/cgi-bin/texfaq2html?label=tocbibind</a>
</body>