Tables of contents

18.2.1 Tables of contents

What goes into the table of contents? For the amsbook document class—and the document classes built on it—all titles, not the short titles, of the sectioning commands, whether *-ed or not, subject only to the value of the tocdepth counter, as described in the last subsection of Section 15.5.1. For instance, if tocdepth is set to

2, the default, then the titles of chapters, sections, and subsections are included in the table of contents, and subsubsections are excluded. This leaves us with the problem, what do we do if the title is too long? You cannot break the line with \\, because this would the appear in table of contents. The AMS coded the following solution: enter the line break in the form

\except{toc}{\linebreak} For the book document class—and the document classes built on it—the title or

optional argument of the sectioning commands, subject to the value of the tocdepth counter, with the following exceptions:

In Section 10.4.1 we discuss the *-ed versions of sectioning commands. They are excluded from the table of contents.

If the sectioning command has a short title, then it is the short title that is utilized. The example in Section 11.2 shows why this is important. If you have \\ in the title,

you must have a short title without it, otherwise the linebreak would show up in the running head and the table of contents.

When you typeset your document with a table of contents, L A TEX creates a file with the toc extension. The next time the document is typeset, the toc file is typeset too and included in your typeset document at the point where the command

\tableofcontents appears in the source file, normally in the front matter. If your source file is named

myart.tex, the toc file is named myart.toc. This file lists all the sectioning units as well as their titles and page numbers.

If you already have a toc file, the \tableofcontents command typesets a table of contents using the previously created toc file and creates a new toc file. L A TEX adds a line to the table of contents, formatted like a section title, if you include the command

\addcontentsline{toc}{section}{text to be added } in your source file. There are three arguments:

474 Chapter 18 Books in L A TEX

1. The first argument informs L A TEX that a line, the third argument, should be added to the toc file.

2. The second argument specifies how the line should be formatted in the table of contents. In our example, the second argument is section, so the line is formatted as a section title in the table of contents. The second argument must be the name of

a sectioning command.

3. The third argument is the text to be added. You can add an unformatted line to the table of contents with the command

\addtocontents{toc}{text to be added } Such a command can also be used to add vertical spaces into the table of contents.

For instance, if you want to add some vertical space before a part, you should insert the following line before the sectioning command for the part:

\addtocontents{toc}{\protect\vspace{10pt}} The toc file is easy to read. The following are typical lines from the table of

contents file for a document using the book document class: \contentsline{section}{\numberline {5-4.}Top matter}{119}

\contentsline{subsection}{\numberline {5-4.1.} Article info}{119} \contentsline {subsection}{\numberline {5-4.2.} Author info}{121}

Section 15.5.1 explains how you can specify which levels of sectioning appear in the table of contents. Section 2.3 of The L A TEX Companion, 2nd edition [46] lists the style parameters for the table of contents. It also shows you how to define new toc-like files and use multiple tables of contents in a single document, for instance, adding a mini table of contents for each chapter.

Tip You may have to typeset the document three times to create the table of contents and set the numbering of the rest of the document right.

1. The first typesetting creates the toc file.

2. The second inserts the table of contents with the old page numbers into the typeset document, re-records in the aux file the page numbers, which may have changed as

a result of the insertion, and cross-references in the aux file, and generates a new toc file with the correct page numbers.

18.2 Tables of contents, lists of tables and figures 475

3. The third typesetting uses these new aux and toc files to typeset the document correctly and creates a new toc file.

Fragile commands in a movable argument, such as a section (short) title, must be \protect-ed (see Section 5.3.3). Here is a simple example using the table of contents. If the document contains the \section command

\section{The function \( f(x^{2}) \)} the section title is stored in the toc file as \contentsline {section}{\numberline

{1}The function\relax $ f(x^{2}) \relax \GenericError { } {LaTeX Error: Bad math environment delimiter}{Your command was ignored.\MessageBreak Type I <command> <return> to replace it with another command,\MessageBreak or <return> to continue without it.}}{1}

and the log file contains the message ! LaTeX Error: Bad math environment delimiter.

... l.1 ...continue without it.}}{1}

Error messages usually refer to a line in the source file, but in this case the error mes- sage refers to a line in the toc file.

The correct form for this section title is \section{The function \protect\( f(x^{2}) \protect\)}

or, even simpler, \section{The function $f(x^{2})$} Note that this example is merely an illustration of unprotected fragile commands in

movable arguments. As a rule, avoid using formulas in (sectioning) titles.

Dokumen yang terkait

c. Bridging Teknik memanjat pada celah vertikal yang lebih besar (gullies). Caranya dengan menggunakan kedua tangan dan kaki sebagai pegangan pada kedua celah tersebut. Posisi badan mengangkang kaki sebagai tumpuan dibantu juga tangan sebagai penjaga kese

0 1 10

2. Marah: adalah kunci setiap kejahatan. Nabi saw. telah berpesan pada seseorang untuk menjauhi sikap marah dengan sabda beliau: "Janganlah engkau marah". Beliau mengulanginya berkali-kali. (H.R Bukhari). - Kebersihan Hati

2 5 14

Object Oriented Programming dengan Delphi (

1 4 75

E volusi dan aplikasi sistem informasi berbasis komputer

1 8 18

b. Data Manipulation Language (DML) : Digunakan untuk memanipulasi data dengan menggunakan perintah : select, - SISTEM BASIS DATA 1.rar (7,386Kb)

1 3 15

Hubungan Pola Asuh Orang Tua dan Kesiapan Psikologis Anak dengan Kebersihan Toilet Traning pada Anak Usia Prasekolah di Paud Ab-Arisalah Kota Lubuklinggau

0 1 8

Hubungan Pengetahuan dsn Sikap dengan Tindakan Hygiene Penjual makanan Jajanan di Lingkungan Sekolah Dasar Kaamatan Baturaja Timur Kabupaten Ogan Komering UIU Tahun 2013 A. Gani

1 3 14

Faktor faktor yang berhubungan dengan manfaatan Posyandu lansia oleh kelompok usia lanjut didesa Kemalara dalam wilayah kerja Puskesmas Kemalaraja OKU Tahun 2013. Saprianto, M.Kes

3 3 21

Korelasi umur, pekerjaan, dan keberadaan kontainer dengan kejadian penyakit malaria di desa simpang Martapura wilayah Kabupaten Ogan Komering Ulu Selatan tahun 2014 – A. Gani

0 0 18

Pengaruh Ekstrak Daun Jambu Biji (Psidiu Guajava Linn) dan Ekstrak daun Teh Hijau (Camelia Sinensis) terhadap Pertumbuhan Escherichia Coli In Vitro dan Perbandingannya dengan Kotrimoksazol

2 16 20