Difference between revisions of "Table of Contents"

From Wiki
Jump to navigation Jump to search
(new page on TOC (collecting and expanding existing info))
(No difference)

Revision as of 17:06, 8 October 2006

Using Table of Contents

To get the default table of contents use:

\completecontent % with title
\placecontent % without title

Modifing the default Table of Contents

You can customize the appearance, number of shown levels and other attributes of predefined TOC by

\setupcolors[state=start]
% turn off numbering of some levels
\setuphead[subsection][number=no]
\setuphead[subsubsection][number=no]
% TOC
% level=4, \subsubsubsections are not listed in TOC
% alternative=c, space to the page number is filled with dots
\setupcombinedlist[content][level=4,alternative=c]
%\setuplist[chapter][width=5mm,style=bold]
\setuplist[section][width=10mm,style=bold]
\setuplist[subsection][width=20mm]
\setuplist[subsubsection][width=20mm,style=slanted]
\starttext

\startcolor[blue]
\completecontent
\stopcolor

\section{First section}
\subsection{First subsection}
\subsubsection{First subsubsection}
\subsubsubsection{First subsubsubsection}
\section{Second section}
\subsection{Second subsection}
\subsubsection{Second subsubsection}
\subsubsubsection{Second subsubsubsection}
\stoptext

Creating other "Table of ..."

Generally all "Table (List) of ..." are defined with \definelist and \setuplist. You can "collect" several section levels in one list using \definecombinedlist, that's even explained in "ConTeXt, an excursion" (see Official_ConTeXt_Documentation).

To have some parts of your title texts not appear in the table of contents, use \nolist and have a look at http://www.pragma-ade.com/general/magazines/mag-0001.pdf.

Page Numbering in Table of Contents

If you have a special page numbering style it won't automatically be reflected in the table of contents. You need to set the parameters of the table of contents separately. For example,

\starttext
\startfrontmatter
\placecombinedlist[MyContentsList]
\stopfrontmatter
\startbodymatter
\setuppagenumbering[way=bychapter, left=A, chapternumber=yes, numberseparator=/]
...
\stopbodymatter

will give you pagenumbering such as A1/1, A1/2 etc. on the pages in the bodymatter. In the table of contents, however, these will show up as 1-1, 1-2 etc. The ToC needs to be formatted separately.

To get a prefix to the page numbering (like "A"), use

\def\ChapterPrefix#1{A#1}
\setuplist[chapter][pagecommand=\ChapterPrefix]

To get the numberseparator working, you need to know that the ToC will use the separator that is active at the time the ToC is output. So you need to set it immediately before you call the ToC command, e.g.

\setuppagenumbering[numberseparator=/]
\placecombinedlist[MyContentsList]

Last Number Dot in Table of Contents (e.g. 2.1.3.)

This topic is described on page dedicated to Dotted_number_in_caption.