ma-cb-en-tablesofcontent.tex /size: 4268 b    last modification: 2020-07-01 14:35
1\startcomponent ma-cb-en-tablesofcontent
2
3\enablemode[**en-us]
4
5\project ma-cb
6
7\startchapter[title=Table of contents (lists)]
8
9\index{table of contents}
10\index{list}
11
12\Command{\tex{completecontent}}
13\Command{\tex{placecontent}}
14\Command{\tex{definelist}}
15\Command{\tex{setuplist}}
16\Command{\tex{writetolist}}
17\Command{\tex{writebetweenlist}}
18\Command{\tex{definecombinedlist}}
19\Command{\tex{setupcombinedlist}}
20
21A table of contents contains chapter numbers, chapter titles and page numbers and
22can be extended with sections, sub sections, etc. A table of contents is
23generated automatically by typing:
24
25\starttyping
26\placecontent
27\stoptyping
28
29Which table of contents is produced depends on the location of this command in
30your document. At the start of the document it will generate a list of chapters,
31sections etc. But at the top of a chapter:
32
33\startbuffer
34\chapter{Hasselt in Summer}
35
36\placecontent
37
38\section{Hasselt in July}
39
40\section{Hasselt in August}
41
42\stopbuffer
43
44\typebuffer
45
46it will only produce a list of (sub) section titles with the corresponding
47section numbers and page numbers.
48
49The predefined command \type{\placecontent} is available because it was defined
50with:
51
52\shortsetup{definecombinedlist}
53
54This command and \type{\definelist} allows you to define your own lists necessary
55for accessing your documents.
56
57The use of this command and its related commands is illustrated for the default available
58table of contents.
59
60\startbuffer
61\definelist[chapter]
62\setuplist
63   [chapter]
64   [before=\blank,
65    after=\blank,
66    style=bold]
67
68\definelist[section]
69\setuplist
70   [section]
71   [alternative=d]
72\stopbuffer
73
74\typebuffer
75
76Now there are two lists of chapters and sections and these will be combined in a
77table of contents with the command \type{\definecombinedlist}.
78
79\startbuffer
80\definecombinedlist
81   [content]
82   [chapter,section]
83   [level=subsection]
84\stopbuffer
85
86\typebuffer
87
88Now two commands are available: \type{\placecontent} and \type{\completecontent}.
89With the second command the title of the table of contents will be added to the
90table of contents.
91
92The layout of lists can be varied with the parameter \type{alternative}.
93
94\placetable
95  [here,force]
96  [tab:alternatives]
97  {Alternatives for displaying lists.}
98  {\starttable[|c|l|]
99  \HL
100  \NC \bf Alternative \NC \bf Display \NC\SR
101  \HL
102  \NC \type{a} \NC number -- title -- page number              \NC\FR
103  \NC \type{b} \NC number -- title -- spaces -- page number    \NC\MR
104  \NC \type{c} \NC number -- title -- dots -- page number      \NC\MR
105  \NC \type{d} \NC number -- title -- page number (continuing) \NC\MR
106  \NC \type{e} \NC reserved for interactive purposes           \NC\MR
107  \NC \type{f} \NC reserved for interactive purposes           \NC\MR
108  \NC \type{g} \NC reserved for interactive purposes           \NC\LR
109  \HL
110  \stoptable}
111
112Lists are set up with:
113
114\shortsetup{setuplist}
115\shortsetup{setupcombinedlist}
116
117If you want to change the layout of the generated table of contents you'll have
118to remember that it is a (combined) list and that we can set the partial lists
119separately.
120
121\startbuffer
122\setuplist
123  [section]
124  [textstyle=bold,
125   pagestyle=bold,
126   numberstyle=bold]
127\stopbuffer
128
129\typebuffer
130
131This will result in a bold page number, section title and section number.
132
133Lists are generated and placed with:
134
135\shortsetup{placelist}
136
137So if you want a list of sections at the beginning of a new chapter, you type:
138
139\starttyping
140\placelist[section]
141\stoptyping
142
143only the sections will be displayed.
144
145A long list or a long table of contents will use up more than one page. To be
146able to force page breaking you can type:
147
148\starttyping
149\placecontent[extras={8.2=page}]
150\stoptyping
151
152A page break will then occur after section 8.2.
153
154In some cases you want to be able to write your own text in an automatically
155generated list. This is done with:
156
157\shortsetup{writetolist}
158\shortsetup{writebetweenlist}
159
160For example if you want to make a remark in your table of contents after a
161section titled {\em Hotels in Hasselt} you can type:
162
163\startbuffer
164\section{Hotels in Hasselt}
165\writebetweenlist[section]{\blank}
166\writetolist[section][location=here]{}{Section under construction}
167\writebetweenlist[section]{\blank}
168\stopbuffer
169
170\typebuffer
171
172\stopchapter
173
174\stopcomponent
175