Debian Codegraph @

texmf-dist/source/latex/koma-script/doc/tocbasic-en.tex

raw
1 % ======================================================================
2 % tocbasic-en.tex
3 % Copyright (c) Markus Kohm, 2002-2025
4 %
5 % This file is part of the LaTeX2e KOMA-Script bundle.
6 %
7 % This work may be distributed and/or modified under the conditions of
8 % the LaTeX Project Public License, version 1.3c of the license.
9 % The latest version of this license is in
10 % http://www.latex-project.org/lppl.txt
11 % and version 1.3c or later is part of all distributions of LaTeX
12 % version 2005/12/01 or later and of this work.
13 %
14 % This work has the LPPL maintenance status "author-maintained".
15 %
16 % The Current Maintainer and author of this work is Markus Kohm.
17 %
18 % This work consists of all files listed in MANIFEST.md.
19 % ======================================================================
20 %
21 % Package tocbasic for Package and Class Authors
22 % Maintained by Markus Kohm
23 %
24 % ======================================================================
25
26 \KOMAProvidesFile{tocbasic-en.tex}
27 [$Date: 2025-10-07 12:36:27 +0200 (Di, 07. Okt 2025) $
28 KOMA-Script guide (package tocbasic)]
29
30 \translator{Markus Kohm\and Arndt Schubert\and Karl Hagen}
31
32 \chapter{Managing Content Lists with \Package{tocbasic}}
33 \labelbase{tocbasic}
34 \BeginIndexGroup%
35 \BeginIndex{Package}{tocbasic}%
36 \BeginIndex{}{table of contents}%
37 \BeginIndex{}{content list}%
38 \BeginIndex{}{file>extension}%
39 The main purpose of the \Package{tocbasic} package is to give authors of
40 packages and classes the ability to create their own tables or lists of
41 content, content lists for short, similar to the list of figures and the list
42 of tables, allowing classes and other packages some control over these lists.
43 The \Package{tocbasic} package also delegates control of the
44 language-dependent parts of these content lists to the
45 \Package{babel}\IndexPackage{babel} package (see \cite{package:babel}). Using
46 \Package{tocbasic} relieves package and class authors from the burden of
47 implementing such features themselves.
48
49 As a minor side effect, the package can also be used to define new floating
50 environments, or floating environments like non-floating environments for
51 reference objects. For more details, after you read about the basic commands
52 in the next four sections, see the example in \autoref{sec:\LabelBase.example},
53 which is compactly summarized in \autoref{sec:\LabelBase.declarenewtoc}.
54
55 \KOMAScript{} itself uses \Package{tocbasic} not only for the table of
56 contents but also for the already mentioned lists of figures and tables.
57
58 \section{Basic Commands}
59 \seclabel{basics}
60
61 The basic commands are primarily used to handle a list of all known file
62 extensions\textnote{file extension, content lists} that represent a table or
63 list of contents. We call these auxiliary files\Index{auxiliary
64 file}\footnote{The term \emph{auxiliary file} here refers not to the main
65 \File{aux} file but to the other internal files used indirectly via the
66 \File{aux} file, e.\,g. the \File{toc} file, the \File{lof} file, or the
67 \File{lot} file.} TOC files\textnote{TOC file}\Index[indexmain]{TOC file}
68 regardless of the file extension that is actually used. Entries to such files
69 are typically written using
70 \Macro{addtocontents}\important{\Macro{addtocontents},
71 \DescRef{\LabelBase.cmd.addxcontentsline}}, or
72 \DescRef{\LabelBase.cmd.addxcontentsline}. There are also commands to perform
73 actions on all of these file extensions. Additionally, there are commands to
74 set or unset features for the file associated with a given extension.
75 Typically an file extension also has an owner\textnote{file owner}. This owner
76 may be a class or package, or an identifier of a category that the author of
77 the class or package using \Package{tocbasic} has chosen independently. For
78 example, \KOMAScript{} uses the category \texttt{float} as owner for the
79 \File{lof} and \File{lot} file extensions that are associated with the list of
80 figures and list of tables, respectively. For the table of contents,
81 \KOMAScript{} uses the file name of the class.
82
83 \begin{Declaration}
84 \Macro{Ifattoclist}\Parameter{extension}\Parameter{then code}%
85 \Parameter{else code}
86 \end{Declaration}
87 This\ChangedAt{v3.28}{\Package{tocbasic}} command tests whether or not the
88 \PName{extension} already exists in the list of known file extensions. If the
89 \PName{extension} is already known, the \PName{then code} will be
90 executed. Otherwise, the \PName{else code} will be executed.
91 \begin{Example}
92 Suppose you want to know if the file name extension ``\File{foo}'' is
93 already in use in order to report an error because it cannot be used:
94 \begin{lstcode}
95 \Ifattoclist{foo}{%
96 \PackageError{bar}{%
97 extension `foo' already in use%
98 }{%
99 Each extension may be used only
100 once.\MessageBreak
101 The class or another package already
102 uses extension `foo'.\MessageBreak
103 This error is fatal!\MessageBreak
104 You should not continue!}%
105 }{%
106 \PackageInfo{bar}{using extension `foo'}%
107 }
108 \end{lstcode}
109 \end{Example}
110 \EndIndexGroup
111
112
113 \begin{Declaration}
114 \Macro{addtotoclist}\OParameter{owner}\Parameter{extension}
115 \end{Declaration}
116 This command adds the \PName{extension} to the list of known extensions. But
117 if the \PName{extension} is known already, an error is reported to prevent
118 duplicate use of the same \PName{extension}.
119
120 If you specify the optional \OParameter{owner} argument, the given
121 \PName{owner} for this file extension is also saved. If you omit the optional
122 argument, \Package{tocbasic} tries to determine the file name of the class or
123 package currently being processed and saves it as the owner.
124 This\textnote{Attention!} procedure only works if you call
125 \Macro{addtotoclist} while loading a class or package. It will fail if a user
126 calls \Macro{addtotoclist} afterwards. In this case, the owner is empty.
127
128 Note\textnote{Attention!} that passing an empty \PName{owner} argument is not
129 always the same as completely omitting the optional argument, including the
130 square brackets. An empty argument would always result in an empty owner.
131 \begin{Example}
132 Suppose you want to add the extension ``\File{foo}'' to the list of known
133 file extensions while loading your package with the file name
134 ``\File{bar.sty}'':
135 \begin{lstcode}
136 \addtotoclist{foo}
137 \end{lstcode}%
138 This will add the extension ``\PValue{foo}'' with the owner
139 ``\PValue{bar.sty}'' to the list of known extensions if this extension was
140 not already in the list. If the class or another package has already added
141 the extension, you will get the error:
142 \begin{lstoutput}
143 Package tocbasic Error: file extension `foo' cannot be used twice
144
145 See the tocbasic package documentation for explanation.
146 Type H <return> for immediate help.
147 \end{lstoutput}
148 If you press the ``\texttt{h}'' key followed by return, you will get the
149 following help:
150 \begin{lstoutput}
151 File extension `foo' is already used by a toc-file, while bar.sty
152 tried to use it again for a toc-file.
153 This may be either an incompatibility of packages, an error at a package,
154 or a mistake by the user.
155 \end{lstoutput}
156
157 Perhaps your package also provides a command that dynamically generates a
158 content list. In this case, you should use the optional argument of
159 \Macro{addtotoclist} to specify the owner.
160 \begin{lstcode}
161 \newcommand*{\createnewlistofsomething}[1]{%
162 \addtotoclist[bar.sty]{#1}%
163 % Do something more to make this content list available
164 }
165 \end{lstcode}
166 Now if the user calls this command, for example with
167 \begin{lstcode}
168 \createnewlistofsomething{foo}
169 \end{lstcode}
170 this will add the extension ``\PValue{foo}'' with the owner
171 ``\PValue{bar.sty}'' to the list of known extension or report an error, if
172 the extension is already in use.
173 \end{Example}
174 You can specify any \PName{owner} you want, but it must be unique. For
175 example, if you were the author of the \Package{float} package, you could
176 specify the category ``\PValue{float}'' instead of ``\PValue{float.sty}'' as
177 the \PName{owner}. In this case, the \KOMAScript{}
178 options\important{\DescRef{maincls.option.listof}}%
179 \IndexOption{listof~=\PName{setting}} for the list of figures and the list of
180 tables would also affect your content lists because \KOMAScript{} associates
181 the file extensions ``\PValue{lof}'' for the list of figures and
182 ``\PValue{lot}'' for the list of tables with the owner ``\PValue{float}'' and
183 sets the options for this owner.
184
185 By the way, the \href{https://www.ctan.org/pkg/scrhack}{\Package{scrhack}}%
186 \IndexPackage{scrhack}%
187 \important{\href{https://www.ctan.org/pkg/scrhack}{\Package{scrhack}}} package
188 contains patches for several packages, such as
189 \Package{float}\IndexPackage{float} or
190 \Package{floatrow}\IndexPackage{floatrow}, which provide their own content
191 lists. If you use \href{https://www.ctan.org/pkg/scrhack}{\Package{scrhack}},
192 among other things, the respective file extensions will be added to the list
193 of known file extensions. Their \PName{owner} is also ``\PValue{float}''. This
194 is the basic building block, so to speak, allowing you to use the features of
195 \Package{tocbasic} and the \KOMAScript{} classes with these content lists as
196 well. See \cite{pkg:scrhack:manual} for more information.%
197 \EndIndexGroup
198
199
200 \begin{Declaration}
201 \Macro{AtAddToTocList}\OParameter{owner}\Parameter{commands}
202 \end{Declaration}
203 This command adds the \PName{commands} to an internal list of commands that
204 will be processed whenever a file extension with the specified \PName{owner}
205 is added to the list of known extensions with
206 \DescRef{\LabelBase.cmd.addtotoclist}. The optional argument is handled in the
207 same way as in the \DescRef{\LabelBase.cmd.addtotoclist} command. If you leave
208 the optional argument blank, the commands will always be executed, regardless
209 of the owner, every time a new file extension is added to the list of known
210 file extensions. Furthermore, while processing the \PValue{commands},
211 \Macro{@currext}\IndexCmd{@currext}\important{\Macro{@currext}} is set to the
212 extension of the extension currently being added.
213 \begin{Example}
214 \Package{tocbasic} itself uses
215 \begin{lstcode}
216 \AtAddToTocList[]{%
217 \expandafter\tocbasic@extend@babel
218 \expandafter{\@currext}%
219 }
220 \end{lstcode}
221 to add every file extension to the existing \Package{tocbasic} integration
222 with the \Package{babel} package.
223 \end{Example}
224
225 The two \Macro{expandafter} commands in the example are needed because the
226 argument of \DescRef{\LabelBase.cmd.tocbasic@extend@babel} has to be expanded.
227 See the description of \DescRef{\LabelBase.cmd.tocbasic@extend@babel} in
228 \autoref{sec:\LabelBase.internals},
229 \DescPageRef{\LabelBase.cmd.tocbasic@extend@babel} for more information.%
230 \EndIndexGroup
231
232
233 \begin{Declaration}
234 \Macro{removefromtoclist}\OParameter{owner}\Parameter{extension}
235 \end{Declaration}
236 This command removes the \PName{extension} from the list of known extensions.
237 If the optional argument, \OParameter{owner}, is given, the \PName{extension}
238 will only be removed if it was added by this \PName{owner}.
239 % TODO: Fix new translation
240 This also applies to the empty \PName{owner}. If, on the other hand, no
241 \OParameter{owner} is specified at all and the square brackets are also
242 omitted, the owner is not tested and the \PName{extension} is removed
243 regardless of the owner.%
244 % :ODOT
245 \EndIndexGroup
246
247
248 \begin{Declaration}
249 \Macro{doforeachtocfile}\OParameter{owner}\Parameter{commands}
250 \end{Declaration}
251 To this point, we've introduced commands provide additional security for class
252 and package authors, but also more overhead. With \Macro{doforeachtocfile},
253 you can reap the first benefit for this. This command lets you execute the
254 specified \PName{commands} for each file extension associated with an
255 \PName{owner}. While processing the \PName{commands}, \Macro{@currext} is the
256 extension of the current file. If you omit the optional \OParameter{owner}
257 argument, all file extensions are processed regardless of the owner. If the
258 optional argument is empty, on the other hand, only extensions with an empty
259 owner will be processed.
260 \begin{Example}
261 If you want to output a list of all known file extensions to the terminal
262 and to the \File{log} file, you can easily accomplish this:
263 \begin{lstcode}
264 \doforeachtocfile{\typeout{\@currext}}
265 \end{lstcode}
266 If, on the other hand, you only want to output the extensions owned by
267 ``\PValue{foo}'', this too is easy:
268 \begin{lstcode}
269 \doforeachtocfile[foo]{\typeout{\@currext}}
270 \end{lstcode}
271 \end{Example}
272 The \KOMAScript{} classes \Class{scrbook} and \Class{scrreprt} use this
273 command to optionally put a vertical skip or the chapter heading in content
274 lists using the \PValue{chapteratlist} feature. You can learn how to set this
275 feature in \autoref{sec:\LabelBase.toc} on
276 \DescPageRef{\LabelBase.cmd.setuptoc}.%
277 \EndIndexGroup
278
279
280 \begin{Declaration}
281 \Macro{tocbasicautomode}
282 \end{Declaration}
283 This command redefines \LaTeX{} kernel macro \Macro{@starttoc} for class and
284 package authors so that every time \Macro{@starttoc} is called, the specified
285 file extension is added to the list of known extensions, if it has not already
286 been added. It also uses \DescRef{\LabelBase.cmd.tocbasic@starttoc} instead of
287 \Macro{@starttoc}. See \autoref{sec:\LabelBase.internals},
288 \DescPageRef{\LabelBase.cmd.tocbasic@starttoc} for more information about
289 \DescRef{\LabelBase.cmd.tocbasic@starttoc} and \Macro{@starttoc}.
290
291 After you use \Macro{tocbasicautomode}, every content list created with
292 \Macro{@starttoc} is automatically put under the control of
293 \Package{tocbasic}. Whether or not this leads to the desired result, however,
294 depends very much on the individual content list. The \Package{babel} package
295 extensions, at least, will work for all those content lists. Nevertheless, it
296 is preferable for the class or package authors to use \Package{tocbasic}
297 explicitly. That way they can also take advantage of the other features of
298 \Package{tocbasic}, which are described in the following sections.%
299 \EndIndexGroup
300
301
302 \section{Creating a Content List}
303 \seclabel{toc}
304
305 In the previous section, you learned how to maintain a list of known file
306 extensions and how to automatically execute commands when adding new
307 extensions to this list. You also saw a command that can be used to execute
308 instructions for all known extensions or all extensions belonging to one
309 owner. In this section, you will learn commands that apply to the files
310 associated with these file extensions.
311
312 \begin{Declaration}
313 \Macro{addtoeachtocfile}\OParameter{owner}\Parameter{content}
314 \end{Declaration}
315 The \Macro{addtoeachtocfile} command uses the \LaTeX{} kernel command
316 \Macro{addtocontents} to write the \PName{content} to every TOC file\Index{TOC
317 file} in the list of known file extensions that has the specified
318 \PName{owner}. If you omit the optional argument, the \PName{content} is
319 written to each file in the list of known file extensions. Incidentally, the
320 actual file name is constructed from \Macro{jobname} and the file extension.
321 While writing the \PName{content},
322 \Macro{@currext}\IndexCmd{@currext}\important{\Macro{@currext}} is the
323 extension of the file currently being processed.
324 \begin{Example}
325 You want to add a vertical space of one line to all TOC files.
326 \begin{lstcode}
327 \addtoeachtocfile{%
328 \protect\addvspace{\protect\baselineskip}%
329 }
330 \end{lstcode}
331 If, on the other hand, you want to do this only for the files that have the
332 owner ``\PValue{foo}'', use:
333 \begin{lstcode}
334 \addtoeachtocfile[foo]{%
335 \protect\addvspace{\protect\baselineskip}%
336 }
337 \end{lstcode}
338 \end{Example}
339 You should protect commands that should not be expanded when they are written
340 by prefixing them with \Macro{protect}, in the same way as you would in
341 \Macro{addtocontents}.
342 \EndIndexGroup
343
344
345 \begin{Declaration}
346 \Macro{addxcontentsline}%
347 \Parameter{extension}\Parameter{level}\OParameter{section number}%
348 \Parameter{text}
349 \end{Declaration}
350 This command is very similar to
351 \Macro{addcontentsline}\IndexCmd{addcontentsline} from the \LaTeX{} kernel.
352 However, it has an additional optional argument for the \PName{section number}
353 of the entry, whereas for \Macro{addcontentsline}, it is specified in the
354 \PName{text} argument. It is used to include numbered or unnumbered entries in
355 the content list specified by the file \PName{extension}, where \PName{level}
356 is the sectioning level and \PName{text} is the content of the corresponding
357 entry. The page number is determined automatically.
358
359 In contrast to \Macro{addcontentsline}, \Macro{addxcontentsline} first tests
360 whether the \Macro{add\PName{level}\PName{extension}entry} command is defined.
361 If so, it will be used for the entry, passing the \PName{section number} as an
362 optional argument and \PName{text} as a mandatory argument. You can find an
363 example of such a command provided by the \KOMAScript{} classes in
364 \DescRef{maincls-experts.cmd.addparttocentry} (see
365 \autoref{sec:maincls-experts.toc},
366 \DescPageRef{maincls-experts.cmd.addparttocentry}). If the corresponding
367 command is undefined, the internal command
368 \DescRef{\LabelBase.cmd.tocbasic@addxcontentsline} is used instead. This takes
369 all four arguments as mandatory arguments and then uses
370 \Macro{addcontentsline} to create the desired entry. You can find more about
371 \DescRef{\LabelBase.cmd.tocbasic@addxcontentsline} in
372 \autoref{sec:\LabelBase.internals},
373 \DescPageRef{\LabelBase.cmd.tocbasic@addxcontentsline}.
374
375 One advantage of using \Macro{addxcontentsline} rather than
376 \Macro{addcontentsline} is that the \PValue{numberline} feature is respected
377 (see \DescPageRef{\LabelBase.cmd.setuptoc}). Furthermore, you can configure
378 the form of the entries by defining the appropriate commands specific to the
379 \PName{level} and file \PName{extension}.%
380 %
381 \EndIndexGroup
382
383
384 \begin{Declaration}
385 \Macro{addxcontentslinetoeachtocfile}\OParameter{owner}
386 \Parameter{level}
387 \OParameter{section number}%
388 \Parameter{text}
389 \Macro{addcontentslinetoeachtocfile}\OParameter{owner}
390 \Parameter{level}\Parameter{text}%
391 \end{Declaration}
392 These two commands are directly related to
393 \DescRef{\LabelBase.cmd.addxcontentsline}\ChangedAt{v3.12}{\Package{tocbasic}}
394 explained above, or to \Macro{addcontentsline} from the \LaTeX kernel. The
395 difference is that these statements write \PName{text} not just to a single
396 file but to all the files of a given \PName{owner} and, if the first optional
397 argument is omitted, to all files in the list of known file extensions.
398 \begin{Example}
399 Suppose you are a class author and you want to write the chapter entry not
400 just in the table of contents but in all content-list files. Suppose further
401 that \PValue{\#1} currently contains the text to be written.
402 \begin{lstcode}
403 \addxcontentslinetoeachtocfile{chapter}%
404 [\thechapter]{#1}
405 \end{lstcode}
406 In this case, of course, the current chapter number should be expanded
407 directly when writing to the TOC file, which is why it was not protected
408 from expansion with \Macro{protect}.
409 \end{Example}
410 While writing the \PName{content},
411 \Macro{@currext}\IndexCmd{@currext}\important{\Macro{@currext}} here is also
412 the extension of the file being written to, as it is with
413 \DescRef{\LabelBase.cmd.addtoeachtocfile}.%
414
415 Whenever\ChangedAt{v3.12}{\Package{tocbasic}} possible, the
416 \Macro{addxcontentslinetoeachtocfile} command is preferable to
417 \Macro{addcontentslinetoeachtocfile} because only the former offers the
418 enhancements of \DescRef{\LabelBase.cmd.addxcontentsline}. You can find more
419 about these enhancements and benefits in the explanation of
420 \DescRef{\LabelBase.cmd.addxcontentsline} above.%
421 %
422 \EndIndexGroup
423
424
425 \begin{Declaration}
426 \Macro{listoftoc}\OParameter{list-of title}\Parameter{extension}%
427 \Macro{listoftoc*}\Parameter{extension}%
428 \Macro{listofeachtoc}\OParameter{owner}%
429 \Macro{listof\PName{extension}name}
430 \end{Declaration}
431 You can use these commands to print the content lists.
432 The\important{\Macro{listoftoc*}} stared version \Macro{listoftoc*} needs only
433 one argument, the \PName{extension} of the file. The command first initializes
434 the vertical and horizontal spacing of paragraphs, calls the hook to execute
435 commands before reading the file, then reads the file, and finally executes
436 the hook to execute commands after reading the file. Thus you can think of
437 \Macro{listoftoc*} as a direct replacement for the \LaTeX{} kernel macro
438 \Macro{@starttoc}\IndexCmd{@starttoc}\important{\Macro{@starttoc}}.
439
440 The\important{\Macro{listoftoc}} version of \Macro{listoftoc} without the star
441 prints the complete content list and also creates an optional entry in the
442 table of contents and the running heads. If you provide the optional
443 \OParameter{list-of title} argument, it is used both as the title for the list
444 and as an optional entry in the table of contents and the running head.
445 If\textnote{Attention!} the \OParameter{list-of title} argument is empty, the
446 title will be empty too. If, on the other hand, you completely omit the
447 optional argument, including the square brackets, the
448 \Macro{listof\PName{extension}name} command will be used if it is defined. If
449 it is undefined, a default replacement name is used and a warning is issued.
450
451 The\important{\Macro{listofeachtoc}} \Macro{listofeachtoc} command outputs all
452 content lists associated with the given \PName{owner}, or of all known file
453 extensions if the optional argument is omitted. To\textnote{Attention!} output
454 the correct titles, \Macro{listof\PName{extension}name} should be defined.
455
456 You\textnote{Hint!} should define \Macro{listof\PName{extension}name}
457 appropriately for all file extensions because users may use \Macro{listoftoc}
458 without the optional argument, or \Macro{listofeachtoc}, themselves.
459 \begin{Example}
460 Suppose you have a new ``list of algorithms'' with the file extension
461 \PValue{loa} and want to output it. The command
462 \begin{lstcode}
463 \listoftoc[List of Algorithms]{loa}
464 \end{lstcode}
465 will do it for you. If, however, you want to output this list without a
466 title, you could use
467 \begin{lstcode}
468 \listof*{loa}
469 \end{lstcode}
470 In the second case, of course, there will be no entry in the table of
471 contents. For more information about creating entries in the table of
472 contents, see the \DescRef{\LabelBase.cmd.setuptoc} command on
473 \DescPageRef{\LabelBase.cmd.setuptoc}.
474
475 If you have defined
476 \begin{lstcode}
477 \newcommand*{\listofloaname}{%
478 List of Algorithms%
479 }
480 \end{lstcode}
481 already, then
482 \begin{lstcode}
483 \listoftoc{loa}
484 \end{lstcode}
485 will suffice to print the content list with the desired heading. It may be
486 easier for users to remember if you also define a simple list-of command:
487 \begin{lstcode}
488 \newcommand*{\listofalgorithms}{\listoftoc{loa}}
489 \end{lstcode}
490 \end{Example}
491
492 Because\textnote{Attention!} \LaTeX{} normally opens a new file for each of
493 these content lists, calling each of these commands may
494 result in an error like:
495 \begin{lstoutput}
496 ! No room for a new \write .
497 \ch@ck ...\else \errmessage {No room for a new #3}
498 \fi
499 \end{lstoutput}
500 if there are no more write handles left. Loading the
501 \Package{scrwfile}\important{\Package{scrwfile}}\IndexPackage{scrwfile}
502 package \cite{package:scrwfile} can solve this problem.
503
504 Also, the \href{https://www.ctan.org/pkg/scrhack}{\Package{scrhack}}%
505 \IndexPackage{scrhack}%
506 \important{\href{https://www.ctan.org/pkg/scrhack}{\Package{scrhack}}} package
507 contains patches for several packages, such as
508 \Package{float}\IndexPackage{float} or
509 \Package{floatrow}\IndexPackage{floatrow}, so that their content-list commands
510 can use \Macro{listoftoc}. As a result, many features of \Package{tocbasic}
511 and the \KOMAScript{} classes are also available for their content lists. See
512 \cite{pkg:scrhack:manual} for more information.%
513 \EndIndexGroup
514
515
516 \begin{Declaration}
517 \Macro{BeforeStartingTOC}\OParameter{extension}\Parameter{commands}%
518 \Macro{AfterStartingTOC}\OParameter{extension}\Parameter{commands}
519 \end{Declaration}
520 Sometimes it's useful to be able to execute \PName{commands} immediately
521 before reading the auxiliary TOC file. With \Macro{BeforeStartingTOC} you can
522 do so either for a single file \PName{extension} or for all files that are
523 read using \DescRef{\LabelBase.cmd.listoftoc*},
524 \DescRef{\LabelBase.cmd.listoftoc}, or \DescRef{\LabelBase.cmd.listofeachtoc}.
525 You can also execute \PName{commands} after reading the file if you define
526 them with \Macro{AfterStartingTOC}. If you omit the optional argument (or set
527 an empty one) a general hook will be set and the commands will be applied to
528 all content lists. The general before-hook is called before the individual
529 one, and the general after-hook is called after the individual one. While
530 executing the commands in these hooks,
531 \Macro{@currext}\IndexCmd{@currext}\important{\Macro{@currext}} is the
532 extension of the TOC file which is about to be or has just been read.%
533 \EndIndexGroup
534
535
536 \begin{Declaration}
537 \Macro{BeforeTOCHead}\OParameter{extension}\Parameter{commands}%
538 \Macro{AfterTOCHead}\OParameter{extension}\Parameter{commands}
539 \end{Declaration}
540 You can also define \PName{commands} that will be executed immediately before
541 or after setting the title of a content list using
542 \DescRef{\LabelBase.cmd.listoftoc*} or \DescRef{\LabelBase.cmd.listoftoc}. The
543 treatment of the optional parameter and the meaning of
544 \Macro{@currext}\IndexCmd{@currext}\important{\Macro{@currext}} is the same as
545 described for \DescRef{\LabelBase.cmd.BeforeStartingTOC} and
546 \DescRef{\LabelBase.cmd.AfterStartingTOC}.%
547 \EndIndexGroup
548
549
550 \begin{Declaration}
551 \Macro{MakeMarkcase}\Parameter{text}
552 \end{Declaration}
553 Whenever \Package{tocbasic} sets a mark for a running head, The text of the
554 mark will be an argument of \Macro{MakeMarkcase}. You can use this command to
555 change the case of the running head if necessary. The \KOMAScript{} classes
556 use \Macro{@firstofone}\IndexCmd{@firstofone}\important{\Macro{@firstofone}}
557 by default. This means the text of the running head will be set without
558 changing the capitalisation. If you use a different class,
559 \Macro{MakeMarkcase} will be set to
560 \Macro{MakeUppercase}\IndexCmd{MakeUppercase}%
561 \important{\Macro{MakeUppercase}}. However, \Package{tocbasic} only defines
562 this command if it is not already defined. It can therefore be predefined by
563 another class or package and \Package{tocbasic} will use that definition
564 rather than overwriting it.
565 \begin{Example}
566 For some strange reason, you want to set the running heads entirely in
567 lower-case letters. To apply this change automatically for all running heads
568 set by \Package{tocbasic}, you define:
569 \begin{lstcode}
570 \let\MakeMarkcase\MakeLowercase
571 \end{lstcode}
572 \end{Example}
573 Let\textnote{Hint!} me give you some advice about
574 \Macro{MakeUppercase}\IndexCmd{MakeUppercase}. First of all, this command is
575 not fully expandable. This means that it can cause problems interacting with
576 other commands. Beyond that, typographers agree that whenever you set whole
577 words or phrases in capital letters, additional spacing is absolutely
578 necessary. However, adding a fixed spacing between all letters is not an
579 adequate solution. Different pairs of letters require different spaces between
580 them. Additionally, some letters already create gaps in the text that must be
581 taken into account. Packages like \Package{ulem} or \Package{soul} can
582 scarcely achieve this, nor can \Macro{MakeUppercase}. The automatic letter
583 spacing using the \Package{microtype} package is in this respect only an
584 approximate solution, because it does not take into account the concrete,
585 font-dependent glyphs. Because\textnote{Attention!} typesetting all-capital
586 text is expert work and almost always requires manual adjustment, ordinary
587 users are recommended avoid using it, or to use it only sparingly and not in
588 such an exposed place as the running head.%
589 \EndIndexGroup
590
591
592 \begin{Declaration}
593 \Macro{deftocheading}\Parameter{extension}\Parameter{definition}
594 \end{Declaration}
595 The \Package{tocbasic} package contains a default definition for typesetting
596 the titles of content lists. You can configure this default definition through
597 various features discussed in the \DescRef{\LabelBase.cmd.setuptoc} comand
598 below. If those features are not enough, you can use \Macro{deftocheading}
599 to define your own title for the content list with the given file
600 \PName{extension}. The \PName{definition} of the title can use a single
601 parameter, \PValue{\#1}. When the command is called inside
602 \DescRef{\LabelBase.cmd.listoftoc} or \DescRef{\LabelBase.cmd.listofeachtoc},
603 that \PValue{\#1} will be replaced by the title of this content list.
604
605 Obviously, the \PName{definition} is also responsible for the interpretation
606 of additional features related to the title. This is especially true
607 for the features \PValue{leveldown}, \PValue{numbered} and \PValue{totoc},
608 that are be explained next.%
609 \EndIndexGroup
610
611
612 \begin{Declaration}
613 \Macro{setuptoc}\Parameter{extension}\Parameter{feature list}%
614 \Macro{unsettoc}\Parameter{extension}\Parameter{feature list}
615 \end{Declaration}
616 You can use these two commands to set and clear features for a TOC file
617 \PName{extension} or the content list associated with it. The \PName{feature
618 list} is a comma-separated list of features. The \Package{tocbasic} package
619 recognizes following features:
620 \begin{description}
621 \item[\PValue{leveldown}] means that the content list's heading is created not
622 with the highest sectioning level below
623 \DescRef{maincls.cmd.part}\,---\,\DescRef{maincls.cmd.chapter} if available,
624 \DescRef{maincls.cmd.section} otherwise\,---\,but with a heading of the next
625 level below that. This feature is evaluated by the internal heading command.
626 On the other hand, if a user-defined heading command has been created with
627 \DescRef{\LabelBase.cmd.deftocheading}, the person defining that command is
628 responsible for evaluating the feature. The \KOMAScript{} classes set this
629 feature using the \OptionValueRef{maincls}{listof}{leveldown}%
630 important{\OptionValueRef{maincls}{listof}{leveldown}}%
631 \IndexOption{listof~=\textKValue{leveldown}} option for all file extensions
632 with the owner \PValue{float}.
633 \item[\PValue{nobabel}] prevents using the language-switching features of
634 \Package{babel}\IndexPackage{babel} for the TOC file associated with the
635 this file \PName{extension}. This feature should be used only for content
636 lists that are created in a fixed language, which means that changes of the
637 language inside of the document will no longer affect the content list. The
638 \Package{scrwfile}\important{\Package{scrwfile}}\IndexPackage{scrwfile}
639 \cite{package:scrwfile} package also uses this feature for cloned
640 destinations, as because those files already inherit any language changes
641 from the cloning source.
642
643 Note\textnote{Attention!} that you must set this feature before you add a
644 file extension to the list of known extensions. Changing the feature
645 afterwards will have no effect.
646 \item[\PValue{noindent}]\ChangedAt{v3.27}{\Package{tocbasic}}%
647 causes all content-list entry styles provided by \KOMAScript{} to ignore
648 the \PValue{indent} attribute (see
649 \autoref{tab:\LabelBase.tocstyle.attributes},
650 \autopageref{tab:\LabelBase.tocstyle.attributes.indent}) and instead to
651 deactivate the indentation.%
652 \item[\PValue{noparskipfake}] prevents\ChangedAt{v3.17}{\Package{tocbasic}}
653 the insertion of a final \Length{parskip} before switched off paragraph
654 spacing for content lists. In general, this will cause documents that use
655 spacing between paragraphs to have less vertical space between the list
656 heading and first entry than between normal headings and normal text.
657 Normally, therefore, you will obtain a more uniform formatting without this
658 feature.
659 \item[\PValue{noprotrusion}] prevents\ChangedAt{v3.10}{\Package{tocbasic}}
660 character protrusion, which allows optical margin alignment, from being
661 disabled in the content lists. By default, character protrusion is disabled
662 when the \Package{microtype}\IndexPackage{microtype} package, or another
663 package that supports \Macro{microtypesetup}\IndexCmd{microtypesetup}, is
664 loaded. So if you want optical margin alignment in the content lists, you
665 must set this feature. Note\textnote{Attention!}, however, that character
666 protrusion in content lists often results in incorrect results. This is a
667 known issue with character protrusion.
668 \item[\PValue{numbered}] means that the heading for the content list should
669 be numbered and included in the table of contents. This feature is evaluated
670 by the internal heading command. However, if a user-defined heading command
671 has been created with \DescRef{\LabelBase.cmd.deftocheading}, the person
672 creating that definition is responsible evaluating the feature. The
673 \KOMAScript{} classes set this feature using the
674 \OptionValueRef{maincls}{listof}{numbered}%
675 \important{\OptionValueRef{maincls}{listof}{numbered}}%
676 \IndexOption{listof~=\textKValue{numbered}} option for all file extensions
677 with the owner \PValue{float}.
678 \item[\PValue{numberline}] \leavevmode\ChangedAt{v3.12}{\Package{tocbasic}}%
679 means that any entries made using \DescRef{\LabelBase.cmd.addxcontentsline}
680 or \DescRef{\LabelBase.cmd.addxcontentslinetoeachtocfile}, where the
681 optional argument for the number is missing or empty, will be provided with
682 an empty \DescRef{\LabelBase.cmd.numberline} command. This usually results
683 in these entries being left-aligned not with the number but with the text of
684 the numbered entries of the same level.
685 Using\ChangedAt{v3.20}{\Package{tocbasic}} the \PValue{tocline} entry style
686 can have additional side effects. See the style attribute
687 \Option{breakafternumber} and \Option{entrynumberformat} in
688 \autoref{tab:\LabelBase.tocstyle.attributes} starting on
689 \autopageref{tab:\LabelBase.tocstyle.attributes}.
690
691 \KOMAScript{} classes set this feature for the file extensions with the
692 owner \PValue{float} if you use the
693 \OptionValueRef{maincls}{listof}{numberline}%
694 \important{\OptionValueRef{maincls}{listof}{numberline}}%
695 \IndexOption{listof~=\textKValue{numberline}} option and for the file
696 extension \PValue{toc} if you use the
697 \OptionValueRef{maincls}{toc}{numberline}%
698 \important{\OptionValueRef{maincls}{toc}{numberline}}%
699 \IndexOption{toc~=\textKValue{numberline}} option. Similarly, this feature
700 is reset if you use \OptionValueRef{maincls}{listof}{nonumberline}%
701 \important{\OptionValueRef{maincls}{listof}{nonumberline}}%
702 \IndexOption{listof~=\textKValue{nonumberline}} or
703 \OptionValueRef{maincls}{toc}{nonumberline}%
704 \important{\OptionValueRef{maincls}{toc}{nonumberline}}%
705 \IndexOption{toc~=\textKValue{nonumberline}}.
706 \item[\PValue{onecolumn}] \leavevmode\ChangedAt{v3.01}{\Package{tocbasic}}%
707 means that this content list will automatically use \LaTeX's internal
708 one-column mode with \Macro{onecolumn}\IndexCmd{onecolumn}.
709 However\textnote{Attention!}, this applies only if this content list does
710 not use the \PValue{leveldown}\important{\PValue{leveldown}} feature. The
711 \KOMAScript{} classes \Class{scrbook} and \Class{scrreprt} activate this
712 feature with \DescRef{\LabelBase.cmd.AtAddToTocList} (see
713 \autoref{sec:\LabelBase.basics}, \DescPageRef{\LabelBase.cmd.AtAddToTocList})
714 for all content lists with the owner \PValue{float} or with themselves as
715 owner. Thus, for example, the table of contents, the list of figures, and
716 the list of tables are automatically printed in a single column for both
717 these classes. The multicolumn mode of the
718 \Package{multicol}\IndexPackage{multicol} package is expressly unaffected by
719 this option.
720 \item[\PValue{totoc}] means that the title of content list should be included
721 in the table of contents. This feature will be evaluated by the internal
722 heading command. However, if an user-defined heading command has been
723 created with \DescRef{\LabelBase.cmd.deftocheading}, the person defining
724 that command is responsible for evaluating this feature. The \KOMAScript{}
725 classes set this feature using the \OptionValueRef{maincls}{listof}{totoc}%
726 \important{\OptionValueRef{maincls}{listof}{totoc}}%
727 \IndexOption{listof~=\textKValue{totoc}} option for all file extensions with
728 the owner \PValue{float}.
729 \end{description}
730 The \KOMAScript{} classes recognize an additional feature:
731 \begin{description}
732 \item[\PValue{chapteratlist}] ensures that an optional subdivision is added
733 to the content list for each new chapter. By default, this subdivision is a
734 vertical space. See \DescRef{maincls.option.listof}%
735 \IndexOption{listof}\important{\DescRef{maincls.option.listof}} in
736 \autoref{sec:maincls.floats}, \DescPageRef{maincls.option.listof} for more
737 information about this option.
738 \end{description}
739 \begin{Example}
740 Because \KOMAScript{} classes use \Package{tocbasic} for the list of figures
741 and list of tables, there is another way to prevent chapter subdivisions in
742 these lists:
743 \begin{lstcode}
744 \unsettoc{lof}{chapteratlist}
745 \unsettoc{lot}{chapteratlist}
746 \end{lstcode}
747
748 If you want the chapter subdivisions for your own list that you have defined
749 with the file \PName{extension} ``\PValue{loa}'' to use the same subdivision
750 format used by the \KOMAScript{} classes, you can use
751 \begin{lstcode}
752 \setuptoc{loa}{chapteratlist}
753 \end{lstcode}
754 And if you also want classes that use \DescRef{maincls.cmd.chapter} as the
755 top-level structure to use the one-column mode automatically, you can
756 use
757 \begin{lstcode}
758 \Ifundefinedorrelax{chapter}{}{%
759 \setuptoc{loa}{onecolumn}%
760 }
761 \end{lstcode}
762 Using \DescRef{scrbase.cmd.Ifundefinedorrelax} requires the
763 \Package{scrbase} package (see \autoref{sec:scrbase.if},
764 \DescPageRef{scrbase.cmd.Ifundefinedorrelax}).
765
766 Even\textnote{Hint!} if your package will be used with another class, it
767 does not hurt to set these features. To the contrary, if another class also
768 evaluates these features, then your package would automatically use the
769 features of that class.
770 \end{Example}
771 As you can see, packages that use \Package{tocbasic} already support a wide
772 range of options for content lists that would otherwise require a great deal
773 of effort to implement and which are therefore missing in many packages.%
774 \EndIndexGroup
775
776
777 \begin{Declaration}
778 \Macro{Iftocfeature}\Parameter{extension}\Parameter{feature}%
779 \Parameter{then code}\Parameter{else code}
780 \end{Declaration}
781 You\ChangedAt{v3.28}{\Package{tocbasic}} can use this command to test if a
782 \PName{feature} was set for the given file \PName{extension}. If so the
783 \PName{then code} will be executed, otherwise the \PName{else code} will
784 be. This can be useful, for example, if you define your own heading command
785 using \DescRef{\LabelBase.cmd.deftocheading} but want to support the features
786 \PValue{totoc}, \PValue{numbered} or \PValue{leveldown}.%
787 \EndIndexGroup
788
789
790 \section{Configuring Content-List Entries}
791 \seclabel{tocstyle}%
792 \BeginIndexGroup
793 \BeginIndex{}{table of contents>entry}%
794 \Index{list of contents|\see{table of contents}}
795
796 Since\ChangedAt{v3.20}{\Package{tocbasic}} version~3.20, the
797 \Package{tocbasic} package has been able not only to configure the tables or
798 lists of contents and their auxiliary files but also to influence their
799 entries. To do so, you can define new styles or you can use and configure one
800 of the predefined styles. In the medium term, \Package{tocbasic} will replace
801 the experimental \Package{tocstyle} package that never became an official part
802 of the \KOMAScript{} bundle. The \KOMAScript{} classes themselves have relied
803 completely on the \Package{tocbasic} entry styles since version~3.20.
804
805 \begin{Declaration}
806 \Counter{tocdepth}
807 \end{Declaration}
808 Entries to content lists are usually hierarchical. For this purpose, each
809 entry level has a numerical value. The higher this value, the lower in the
810 hierarchy is this level. In the standard classes, for example, parts have the
811 level -1 and chapters have the value 0. The \LaTeX{} counter
812 \Counter{tocdepth} determines the deepest level that should be shown in the
813 table of contents and other content lists.
814
815 For example, the \Class{book} class sets \Counter{tocdepth} to 2, so entries
816 of the levels \PValue{part}, \PValue{chapter}, \PValue{section}, and
817 \PValue{subsection} are printed. Deeper levels like \PValue{subsubsection},
818 which has the numerical value 3, are not printed. Nevertheless the entries are
819 part of the auxiliary file for the table of contents.
820
821 Note that most \Package{tocbasic} entry styles, with the exception of
822 \PValue{gobble} (see \DescRef{\LabelBase.cmd.DeclareTOCStyleEntry}\iffree{}{,
823 later in this section}) observe \Counter{tocdepth}.%
824 \EndIndexGroup
825
826
827 \begin{Declaration}
828 \Macro{numberline}\Parameter{entry number}%
829 \Macro{usetocbasicnumberline}\OParameter{code}
830 \end{Declaration}
831 Although\ChangedAt{v3.20}{\Package{tocbasic}} the \LaTeX{} kernel
832 already defines a \Macro{numberline} command, the definition is not sufficient
833 for \Package{tocbasic}. Therefore \Package{tocbasic} defines its own commands
834 and sets \Macro{numberline} as needed using \Macro{usetocbasicnumberline} for
835 each content-list entry. Redefining \Macro{numberline}, therefore, is often
836 ineffective and may result in warnings if you use \Package{tocbasic}.
837
838 You can use the definition of \Package{tocbasic} by putting
839 \Macro{usetocbasicnumberline} into your document's preamble. The command first
840 checks if the current definition of \Macro{numberline}
841 uses certain important, internal commands of \Package{tocbasic}. If this is not
842 the case, \Macro{usetocbasicnumberline} redefines \Macro{numberline} and
843 executes \PName{code}. If you omit the optional argument, it issues
844 a message about the redefinition with \Macro{PackageInfo}. If
845 you just do not want such a message, use an empty optional argument.
846
847 Note\textnote{Attention!} that \Macro{usetocbasicnumberline} can change the
848 internal switch \Macro{@tempswa} globally!%
849 \EndIndexGroup
850
851
852 \begin{Declaration}
853 \Macro{DeclareTOCStyleEntry}\OParameter{option list}\Parameter{style}%
854 \Parameter{entry level}
855 \Macro{DeclareTOCStyleEntries}\OParameter{option list}\Parameter{style}%
856 \Parameter{entry level list}
857 \end{Declaration}
858 These\ChangedAt{v3.20}{\Package{tocbasic}} commands define or configure the
859 content-list entries of a given \PName{entry level}. The \PName{entry level}
860 argument is a symbolic name, e.\,g. \PValue{section}, for the entry to the
861 table of contents of the section level with the same name or \PValue{figure}
862 for an entry of a figure to the list of figures. A \PName{style} is assigned
863 to each \PName{entry level}. The \PName{style} has to be defined before using
864 it as an argument of \Macro{DeclareTOCStyleEntry} or
865 \Macro{DeclareTOCStyleEntries}. You can use the \PName{option list} to
866 configure the various, usually \PName{style}-dependent, attributes of the
867 entries.
868
869 Currently, \Package{tocbasic} defines the following entry styles:
870 \begin{description}
871 \item[\PValue{default}] defaults to a clone of the \PValue{dottedtocline}
872 style. Class authors who use \Package{tocbasic} are encouraged to change
873 this style to the default content-list style of the class using
874 \Macro{CloneTOCStyle}. For example the \KOMAScript{} classes change
875 \PValue{default} into a clone of \PValue{tocline}.
876 \item[\PValue{dottedtocline}] is similar to the style used by the standard
877 classes \Class{book} and \Class{report} for the \PValue{section} down to
878 \PValue{subparagraph} entry levels of the table of contents and for the
879 entries at the list of figures or list of tables. It supports the attributes
880 \PValue{level}, \PValue{indent}, and \PValue{numwidth}. The entries are
881 indented by the value of \PValue{indent} from the left. The width of the
882 entry number is given by the value of \PValue{numwidth}. For multi-line
883 entries, the indent will be increased by the value of \PValue{numwidth} for
884 the second and following lines. The page number is printed using
885 \Macro{normalfont}\IndexCmd{normalfont}. The entry text and the page number
886 are connected by a dotted line. \hyperref[fig:\LabelBase.dottedtocline]%
887 {Figure~\ref*{fig:\LabelBase.dottedtocline}} illustrates the attributes of
888 this style.
889 \begin{figure}
890 \centering
891 \resizebox{.8\linewidth}{!}{%
892 \begin{tikzpicture}
893 \draw[color=lightgray] (0,2\baselineskip) -- (0,-2.5\baselineskip);
894 \draw[color=lightgray] (\linewidth,2\baselineskip) --
895 (\linewidth,-2.5\baselineskip);
896 \node (dottedtocline) at (0,0) [anchor=west,inner sep=0,outer sep=0]
897 {%
898 \hspace*{7em}%
899 \parbox[t]{\dimexpr\linewidth-9.55em}{%
900 \setlength{\parindent}{-3.2em}%
901 \addtolength{\parfillskip}{-2.55em}%
902 \makebox[3.2em][l]{1.1.10}%
903 Text of an entry in the table of contents with the
904 \PValue{dottedtocline} style and more than one line%
905 \leaders\hbox{$\csname m@th\endcsname
906 \mkern 4.5mu\hbox{.}\mkern 4.5mu$}\hfill\nobreak
907 \makebox[1.55em][r]{12}%
908 }%
909 };
910 \draw[|-|,color=gray,overlay] (0,0) --
911 node [anchor=north,font=\small] {
912 \PValue{indent}
913 }
914 (3.8em,0);
915 \draw[|-|,color=gray,overlay] (3.8em,\baselineskip) --
916 node [anchor=south,font=\small] {
917 \PValue{numwidth}
918 }
919 (7em,\baselineskip);
920 \draw[|-|,color=gray,overlay] (\linewidth,\ht\strutbox) --
921 node [anchor=south,font=\small] {
922 \Macro{@tocrmarg}
923 }
924 (\linewidth-2.55em,\ht\strutbox);
925 \draw[|-|,color=gray,overlay] (\linewidth,-\baselineskip) --
926 node [anchor=north,font=\small] {
927 \Macro{@pnumwidth}
928 }
929 (\linewidth-1.55em,-\baselineskip);
930 \end{tikzpicture}%
931 }
932 \caption{Illustrations of some attributes of a TOC entry with the
933 \PValue{dottedtocline} style}
934 \labelofbase[fig]{dottedtocline}
935 \end{figure}
936 \item[\PValue{gobble}] is the simplest possible style. Entries in this style,
937 regardless of the setting of \DescRef{\LabelBase.counter.tocdepth}%
938 \IndexCounter{tocdepth}\important{\DescRef{\LabelBase.counter.tocdepth}},
939 will never be printed. The style simply gobbles the
940 entries, so to speak. It has the default \PValue{level} attribute, but
941 it is never evaluated.
942 \item[\PValue{largetocline}] is similar to the style used by the standard
943 classes for the \PValue{part} level. It supports the \PValue{level} and
944 \PValue{indent} attributes only. The latter deviates from the standard
945 classes, which do not support an indent of the \PValue{part} entries.
946
947 A penalty is set to permit page breaks before an entry of an appropriate
948 level. The entries will be indented by the value of \PValue{indent} from the
949 left and printed with the font style \Macro{large}\Macro{bfseries}. If
950 \DescRef{\LabelBase.cmd.numberline} is used, the number width is 3\Unit{em}.
951 \DescRef{\LabelBase.cmd.numberline} is not redefined. The standard classes
952 do not use \DescRef{\LabelBase.cmd.numberline} for \PName{part} entries. The
953 value of \PName{indent} also has no effect on the indentation from the
954 second line and after in a multi-line entry.
955
956 \hyperref[fig:\LabelBase.largetocline]%
957 {Figure~\ref*{fig:\LabelBase.largetocline}} illustrates the characteristics of
958 this style. You will also notice that the style has adopted some
959 inconsistencies present in the standard classes, e.\,g. the missing indent
960 of the second and following lines of an entry or the different values of
961 \Macro{@pnumwidth} that results from the font-size dependency. This can
962 result, in extreme cases, in the entry text coming too close. Note that the
963 width of the entry number shown in the figure is only valid if
964 \DescRef{\LabelBase.cmd.numberline} has been used. The standard classes,
965 however, use a distance of 1\Unit{em} after the number.
966 \begin{figure}
967 \centering
968 \resizebox{.8\linewidth}{!}{%
969 \begin{tikzpicture}
970 \draw[color=lightgray] (0,2\baselineskip) -- (0,-2.5\baselineskip);
971 \draw[color=lightgray] (\linewidth,2\baselineskip) --
972 (\linewidth,-2.5\baselineskip);
973 \node (largetocline) at (0,0) [anchor=west,inner sep=0,outer sep=0] {%
974 \parbox[t]{\dimexpr \linewidth-1.55em\relax}{%
975 \makebox[3em][l]{\large\bfseries I}%
976 \large\bfseries
977 Text of an entry to the table of contents with the
978 \PValue{largetocline} style and more than one line%
979 \hfill
980 \makebox[0pt][l]{\normalsize\normalfont
981 \makebox[1.55em][r]{\large\bfseries 1}}%
982 }%
983 };
984 \draw[|-|,color=gray] (0,\baselineskip) --
985 node [anchor=south] { 3\,em }
986 (3em,\baselineskip);
987 \draw[|-|,color=gray,overlay] (\linewidth,\ht\strutbox) --
988 node [anchor=south] { \Macro{@pnumwidth} }
989 (\linewidth-1.55em,\ht\strutbox);
990 \large\bfseries
991 \draw[|-|,color=gray,overlay] (\linewidth,-\baselineskip) --
992 node [anchor=north,font=\normalfont\normalsize] {
993 \Macro{large}\Macro{@pnumwidth}
994 }
995 (\linewidth-1.55em,-\baselineskip);
996 \end{tikzpicture}%
997 }
998 \caption{Illustrations of some attributes of a TOC entry with style
999 \PValue{largetocline}}
1000 \labelofbase[fig]{largetocline}
1001 \end{figure}
1002 \item[\PValue{tocline}] is a flexible style. The \KOMAScript{} classes use
1003 this style by default for all kinds of entries. Likewise, these classes
1004 define the clones \PValue{part}, \PValue{chapter}, and \PValue{section}, or
1005 \PValue{section} and \PValue{subsection} using this style, but add extra
1006 \PName{initial code} to the clones to change their defaults.
1007
1008 The style supports 20\important{\PValue{level}, \PValue{beforeskip},
1009 \PValue{breakafternumber}, \PValue{dynindent}, \PValue{dynnumwidth},
1010 \PValue{entryformat}, \PValue{entrynumberformat}, \PValue{indent},
1011 \PValue{indentfollows}, \PValue{linefill}, \PValue{numsep},
1012 \PValue{numwidth}, \PValue{onstarthigherlevel},
1013 \PValue{onstartlowerlevel}, \PValue{onstartsamelevel},
1014 \PValue{pagenumberbox}, \PValue{pagenumberformat},
1015 \PValue{pagenumberwidth}, \PValue{raggedentrytext},
1016 \PValue{raggedpagenumber}, \PValue{rightindent}} additional attributes in
1017 addition to the default \PValue{level} attribute. The defaults of all these
1018 attributes depend on the name of the \PName{entry level} and correspond to
1019 the results of the standard classes. So after loading \Package{tocbasic},
1020 you can change the style of the entries in the table of contents of the
1021 standard classes into \PValue{tocline} using
1022 \DescRef{\LabelBase.cmd.DeclareTOCEntryStyle} without this leading directly
1023 to major changes in their appearance. Thus you can precisely change only
1024 those attributes that are necessary for the desired changes. The same
1025 applies to the list of figures and the list of tables for the standard
1026 classes.
1027
1028 Because its great flexibility, this style can in principle replace the
1029 \PValue{dottedtocline}, \PValue{undottedtocline}, and \PValue{largetocline}
1030 styles, but this requires more effort to configure.
1031
1032 \hyperref[fig:\LabelBase.tocline]%
1033 {Figure~\ref*{fig:\LabelBase.tocline}} illustrates some of the length
1034 attributes of this style. The others are explained in
1035 \autoref{tab:\LabelBase.tocstyle.attributes} starting on
1036 \autopageref{tab:\LabelBase.tocstyle.attributes}.
1037 \begin{figure}
1038 \centering
1039 \resizebox{.8\linewidth}{!}{%
1040 \begin{tikzpicture}
1041 \coordinate (subsection) at (0,0);
1042 \coordinate (section) at ($(subsection)+(0,2\baselineskip)$);
1043 \coordinate (chapter) at ($(section)+(0,2\baselineskip)$);
1044 \coordinate (part) at ($(chapter)+(0,2.4\baselineskip+1em)$);
1045
1046 \draw[color=lightgray]
1047 ($(part)+(0,2\baselineskip)$) --
1048 (0,-2.5\baselineskip);
1049 \draw[color=lightgray]
1050 ($(part)+(\linewidth,2\baselineskip)$) --
1051 (\linewidth,-2.5\baselineskip);
1052
1053 \coordinate (subsection) at (0,0);
1054
1055 \node at (part) [anchor=west,inner sep=0,outer sep=0]
1056 {%
1057 \hspace*{3em}%
1058 \parbox[t]{\dimexpr\linewidth-5.55em}{%
1059 \setlength{\parindent}{-3em}%
1060 \addtolength{\parfillskip}{-2.55em}%
1061 \makebox[3em][l]{\large\bfseries I.}%
1062 \textbf{\large Text of a part entry with the
1063 \PValue{tocline} style and at least two lines of text}%
1064 \hfill
1065 \makebox[1.55em][r]{\bfseries 12}\large
1066 }%
1067 };
1068 \draw[|-|,color=gray,overlay]
1069 (part) --
1070 ($(part)+(3em,0)$)
1071 node [anchor=north east,font=\small] {
1072 \PValue{numwidth}
1073 };
1074 \draw[|-|,color=gray,overlay]
1075 ($(part)+(\linewidth,\ht\strutbox)$)
1076 node [anchor=north,font=\small] {
1077 \Macro{@tocrmarg}
1078 } --
1079 ($(part)+(\linewidth-2.55em,\ht\strutbox)$);
1080 \draw[|-|,color=gray,overlay]
1081 ($(part)+(\linewidth,-\baselineskip)$) --
1082 node [anchor=north,font=\small] {
1083 \Macro{@pnumwidth}
1084 }
1085 ($(part)+(\linewidth-1.55em,-\baselineskip)$);
1086 \node at (chapter) [anchor=west,inner sep=0,outer sep=0]
1087 {%
1088 \hspace*{1.5em}%
1089 \parbox[t]{\dimexpr\linewidth-4.05em}{%
1090 \setlength{\parindent}{-1.5em}%
1091 \addtolength{\parfillskip}{-2.55em}%
1092 \makebox[1.5em][l]{\bfseries 1.}%
1093 \textbf{Text of a chapter entry with the
1094 \PValue{tocline} style and more than one line of text
1095 for demonstration purposes}%
1096 \hfill
1097 \makebox[1.55em][r]{\bfseries 12}%
1098 }%
1099 };
1100 \draw[|-|,color=gray,overlay]
1101 ($(chapter)+(3em,\baselineskip)$) --
1102 node [anchor=west,font=\small] {
1103 \PValue{beforeskip}
1104 }
1105 ($(part)+(3em,-\baselineskip)$);
1106 \draw[|-|,color=gray,overlay]
1107 (chapter) --
1108 ($(chapter)+(1.5em,0)$)
1109 node [anchor=north east,font=\small] {
1110 \PValue{numwidth}
1111 };
1112 \draw[|-|,color=gray,overlay]
1113 ($(chapter)+(\linewidth,\ht\strutbox)$)
1114 node [anchor=north,font=\small] {
1115 \Macro{@tocrmarg}
1116 } --
1117 ($(chapter)+(\linewidth-2.55em,\ht\strutbox)$);
1118 \draw[|-|,color=gray,overlay]
1119 ($(chapter)+(\linewidth,-\baselineskip)$)
1120 node [anchor=north,font=\small] {
1121 \Macro{@pnumwidth}
1122 } --
1123 ($(chapter)+(\linewidth-1.55em,-\baselineskip)$);
1124 \node at (section) [anchor=west,inner sep=0,outer sep=0]
1125 {
1126 \hspace*{3.8em}%
1127 \parbox[t]{\dimexpr\linewidth-6.35em}{%
1128 \setlength{\parindent}{-2.3em}%
1129 \addtolength{\parfillskip}{-2.55em}%
1130 \makebox[2.3em][l]{1.1.}%
1131 Text of a section entry with the \PValue{tocline}
1132 style and more than one line of text for
1133 demonstration purposes%
1134 \leaders\hbox{$\csname m@th\endcsname
1135 \mkern 4.5mu\hbox{.}\mkern 4.5mu$}\hfill\nobreak
1136 \makebox[1.55em][r]{3}%
1137 }%
1138 };
1139 \node at (subsection) [anchor=west,inner sep=0,outer sep=0]
1140 {%
1141 \hspace*{7em}%
1142 \parbox[t]{\dimexpr\linewidth-9.55em}{%
1143 \setlength{\parindent}{-3.2em}%
1144 \addtolength{\parfillskip}{-2.55em}%
1145 \makebox[3.2em][l]{1.1.10.}%
1146 Text of a subsection entry with the \PValue{tocline}
1147 and more than one line of text for demonstration
1148 purposes%
1149 \leaders\hbox{$\csname m@th\endcsname
1150 \mkern 4.5mu\hbox{.}\mkern 4.5mu$}\hfill\nobreak
1151 \makebox[1.55em][r]{12}%
1152 }%
1153 };
1154 \draw[|-|,color=gray,overlay]
1155 ($(subsection)+(0,\ht\strutbox)$) --
1156 node [anchor=north,font=\small] {
1157 \PValue{indent}
1158 }
1159 ($(subsection)+(3.8em,\ht\strutbox)$);
1160 \draw[|-|,color=gray,overlay]
1161 ($(subsection)+(3.8em,0)$) --
1162 ($(subsection)+(7em,0)$)
1163 node [anchor=north east,font=\small] {
1164 \PValue{numwidth}
1165 };
1166 \draw[|-|,color=gray,overlay]
1167 ($(subsection)+(\linewidth,\ht\strutbox)$)
1168 node [anchor=north,font=\small] {
1169 \Macro{@tocrmarg}
1170 } --
1171 ($(subsection)+(\linewidth-2.55em,\ht\strutbox)$);
1172 \draw[|-|,color=gray,overlay]
1173 ($(subsection)+(\linewidth,-\baselineskip)$) --
1174 node [anchor=north,font=\small] {
1175 \Macro{@pnumwidth}
1176 }
1177 ($(subsection)+(\linewidth-1.55em,-\baselineskip)$);
1178 \end{tikzpicture}%
1179 }
1180 \caption{Illustrations of some attributes of a TOC entry with the
1181 \PValue{tocline} style}
1182 \labelofbase[fig]{tocline}
1183 \end{figure}
1184 \item[\PValue{toctext}]\ChangedAt{v3.27}{\Package{tocbasic}}%
1185 is a special feature. While all other styles produce one paragraph per
1186 entry, this one produces one paragraph for all successive entries of this
1187 style. With
1188 16\ChangedAt{v3.49}{\Package{tocbasic}}\important{\PValue{afterpar},
1189 \PValue{beforeskip}, \PValue{dynindent}, \PValue{entryformat},
1190 \PValue{entrynumberformat}, \PValue{indent}, \PValue{indentfollows},
1191 \PValue{numsep}, \PValue{onendentry}, \PValue{onendlastentry},
1192 \PValue{onstartentry}, \PValue{onstartfirstentry},
1193 \PValue{pagenumberformat}, \PValue{prepagenumber}, \PValue{raggedright},
1194 \PValue{rightindent}} attributes in addition to the default \PValue{level}
1195 attribute, there are almost as many options as for
1196 \PValue{tocline}. However, this style depends on the fact that an unfinished
1197 paragraph will be concluded at the beginning of the entry for all other
1198 styles, as well as at the end of the current content list. So it should
1199 never be combined with entries or content lists that are generated outside
1200 of \Package{tocbasic}.
1201 \item[\PValue{undottedtocline}] is similar to the style used by the standard
1202 \Class{book} and \Class{report} classes for the \PValue{chapter} entry
1203 level, or by \Class{article} for the \PValue{section} entry level in the
1204 table of contents. It supports\important{\PValue{level}, \PValue{indent},
1205 \PValue{numwidth}} only three attributes. A penalty is inserted permitting
1206 an appropriate page break before the entry, as is a vertical skip. The
1207 entries are printed with an indentation of \PValue{indent} from the left and
1208 in \Macro{bfseries}. This is a departure from the standard classes, which do
1209 not support the indentation of these entry levels.
1210 \DescRef{\LabelBase.cmd.numberline} is used unchanged. The width of the
1211 entry number is determined by \PValue{numwidth}. For multi-line entries the
1212 indent will be increased by the value of \PValue{numwidth} for the second
1213 and following lines. \hyperref[fig:\LabelBase.undottedtocline]%
1214 {Figure~\ref*{fig:\LabelBase.undottedtocline}} illustrates the attributes of
1215 this style.
1216 \begin{figure}
1217 \centering
1218 \resizebox{.8\linewidth}{!}{%
1219 \begin{tikzpicture}
1220 \draw[color=lightgray] (0,2\baselineskip) -- (0,-2.5\baselineskip);
1221 \draw[color=lightgray] (\linewidth,2\baselineskip) --
1222 (\linewidth,-2.5\baselineskip);
1223 \node (undottedtocline) at (0,0) [anchor=west,inner sep=0,outer sep=0]
1224 {%
1225 \makebox[1.5em][l]{\bfseries 1}%
1226 \parbox[t]{\dimexpr \linewidth-4.05em\relax}{%
1227 \bfseries
1228 Text of an entry to the table of contents with the
1229 \PValue{undottedtocline} style and more than one line%
1230 }%
1231 \raisebox{-\baselineskip}{\makebox[2.55em][r]{\bfseries 3}}%
1232 };
1233 \draw[|-|,color=gray,overlay] (0,\baselineskip) --
1234 node [anchor=south,font=\small] {
1235 \PValue{numwidth}
1236 }
1237 (1.5em,\baselineskip);
1238 \draw[|-|,color=gray,overlay] (\linewidth,\ht\strutbox) --
1239 node [anchor=south,font=\small] {
1240 \Macro{@tocrmarg}
1241 }
1242 (\linewidth-2.55em,\ht\strutbox);
1243 \draw[|-|,color=gray,overlay] (\linewidth,-\baselineskip) --
1244 node [anchor=north,font=\small] {
1245 \Macro{@pnumwidth}
1246 }
1247 (\linewidth-1.55em,-\baselineskip);
1248 \end{tikzpicture}%
1249 }
1250 \caption{Illustration of some attributes of the \PValue{undottedtocline}
1251 style with the example of a chapter title}%
1252 \labelofbase[fig]{undottedtocline}
1253 \end{figure}
1254 \end{description}
1255 You can find an explanation of the attributes of all styles that
1256 \Package{tocbasic} defines in \autoref{tab:\LabelBase.tocstyle.attributes}.
1257 In\ChangedAt{v3.27}{\Package{tocbasic}} addition to the usual assignment with
1258 \Option{\PName{key}=\PName{value}}, both commands understand an assignment in
1259 the form \Option{\PName{key}:=\PName{entry level}} for all options of the
1260 \KOMAScript{} styles. In this case, the current setting of \PName{key} for the
1261 \PName{entry level} will be copied. For example, you can copy the current
1262 indent of the \PValue{figure} level using \OptionValue{indent:}{figure}. For
1263 options that expect a length or integer value, you can also use
1264 \Option{\PName{key}+=\PName{value}} to add \PName{value} to the current setting
1265 of the \PName{key}. To subtract simply, you can use a negative \PName{value}.
1266 For example, with \OptionValue{indent+}{1cm} you can increase the indent by
1267 1\Unit{cm}. For options that expect a list value, you can use
1268 \Option{\PName{key}+=\PName{value}} to append \PName{value} to the current
1269 setting of the \PName{key}.
1270
1271 If\ChangedAt{v3.21}{\Package{tocbasic}} you use these attributes as
1272 options to \DescRef{\LabelBase.cmd.DeclareNewTOC} (see
1273 \DescPageRef{\LabelBase.cmd.DeclareNewTOC}), you must prefix the names of the
1274 attributes with \PValue{tocentry}, e\,g., \PValue{level} becomes
1275 \Option{tocentrylevel}. The copy operation with \Option{:=} described above is
1276 also available here. However, addition with \Option{+=} is not currently
1277 supported.
1278
1279 If\ChangedAt{v3.20}{\Package{tocbasic}} you use
1280 these attributes as options for
1281 \DescRef{maincls-experts.cmd.DeclareSectionCommand}%
1282 \IndexCmd{DeclareSectionCommand}\IndexCmd{DeclareNewSectionCommand}%
1283 \IndexCmd{RedeclareSectionCommand}\IndexCmd{ProvideSectionCommand} (see
1284 \DescPageRef{maincls-experts.cmd.DeclareSectionCommand}) and similar commands,
1285 you must prefix the names of the attributes with \PValue{toc}, e\,g.
1286 \PValue{level} becomes \Option{toclevel}.
1287 At this time, neither the copy operation with \Option{:=} nor the
1288 addition operation with \Option{+=} is supported.
1289
1290 Finally, using \Macro{DeclareTOCStyleEntry} will define the internal command
1291 \Macro{l@\PName{entry level}}.
1292
1293 \begin{desclist}
1294 \desccaption{%
1295 Attributes of the predefined TOC-entry styles of \Package{tocbasic}%
1296 \labelofbase[tab]{tocstyle.attributes}%
1297 }{%
1298 Attributes of the TOC-entry styles (\emph{continued})%
1299 }%
1300 \entry{\OptionVName{afterpar}{code}}{%
1301 \ChangedAt{v3.27}{\Package{tocbasic}}%
1302 The specified \PName{code} will be executed after the end of the paragraph
1303 in which an entry with the \PValue{toctext} style is printed. If several
1304 entries have such settings, their code will be executed in the order of
1305 the entries.%
1306 }%
1307 \entry{\OptionVName{beforeskip}{length}}{%
1308 The vertical distance inserted before an entry of this level in the
1309 \PValue{tocline} style (see \autoref{fig:\LabelBase.tocline}). The distance
1310 is made using either \Macro{vskip} or \Macro{addvspace} depending on the
1311 \PName{entry level}, to maintain compatibility as far as possible with the
1312 standard classes and earlier versions of \KOMAScript.
1313
1314 For the \PValue{part} \PName{entry level}, the attribute will be
1315 initialised with \texttt{2.25em plus 1pt}; for \PValue{chapter}, with
1316 \texttt{1em plus 1pt}. If the \PName{chapter} \PName{entry level} is
1317 undefined, \PValue{section} is initialised with \texttt{1em plus 1pt}
1318 instead. The initial value for all other levels is \texttt{0pt plus
1319 .2pt}.%
1320
1321 In\ChangedAt{v3.31}{\Package{tocbasic}} the style \PValue{toctext} the
1322 vertical space is inserted before the paragraph if it is the first entry
1323 in the paragraph. It is ignored for all other entries in the paragraph. If
1324 the initialization takes place via this style, \texttt{0pt} is used as
1325 default.%
1326 }%
1327 \entry{\OptionVName{breakafternumber}{switch}}{%
1328 \PName{switch} is one of the values for simple switches from
1329 \autoref{tab:truefalseswitch}, \autopageref{tab:truefalseswitch}. If the
1330 switch is active in the \PValue{tocline} style, there will be a line break
1331 after the number set with
1332 \DescRef{\LabelBase.cmd.numberline}\IndexCmd{numberline}. The line after
1333 the entry number again starts flush left with the number. The default is
1334 false for the \PValue{tocline} style.
1335
1336 If\textnote{Attention!} the \Option{numberline} feature has been activated
1337 for a content list (see \DescRef{\LabelBase.cmd.setuptoc},
1338 \autoref{sec:\LabelBase.toc}, \DescPageRef{\LabelBase.cmd.setuptoc}), as
1339 is the case with the \KOMAScript{} classes when the
1340 \OptionValueRef{maincls}{toc}{numberline}%
1341 \IndexOption{toc~=\textKValue{numberline}} option is used, then the
1342 unnumbered entries will nevertheless have a (by default empty) number line
1343 using the formatting of \Option{entrynumberformat}.%
1344 }%
1345 \entry{\OptionVName{dynindent}{switch}}{%
1346 \ChangedAt{v3.31}{\Package{tocbasic}}%
1347 \PName{switch} is one of the values for simple switches from
1348 \autoref{tab:truefalseswitch}, \autopageref{tab:truefalseswitch}. If the
1349 switch is active with the \PValue{tocline} or
1350 \PValue{toctext}\ChangedAt{v3.49}{\Package{tocbasic}} styles, the
1351 \PValue{indent} attribute only specifies a minimum value. The maximum
1352 value is determined by the number width and the indentation of the levels
1353 specified via \PValue{indentfollows}.%
1354 }%
1355 \entry{\OptionVName{dynnumwidth}{switch}}{%
1356 \PName{switch} is one of the values for simple switches from
1357 \autoref{tab:truefalseswitch}, \autopageref{tab:truefalseswitch}. If the
1358 switch is active with the \PValue{tocline} style, the \PValue{numwidth}
1359 attribute specifies a minimum value. If a previous \LaTeX{} run has
1360 determined that the maximum width of the entry numbers of the same level
1361 plus the value of \PValue{numsep} is greater than this minimum, the
1362 calculated value will be used instead.%
1363 }%
1364 \entry{\OptionVName{entryformat}{command}}{%
1365 You can use this attributes to change the format of the entry. The value
1366 should be a \PName{command} with exactly one argument. This argument is
1367 not necessarily fully expandable. You should not use commands like
1368 \Macro{MakeUppercase}, which expects a fully expandable argument. Font
1369 changes are relative to \Macro{normalfont}\Macro{normalsize}. Note that
1370 the output of \Option{linefill} and the page number are independent of
1371 \Option{entryformat}. See also the \Option{pagenumberformat} attribute .
1372
1373 The initial value of the attribute for the \PValue{part} \PName{entry
1374 level} is \Macro{large}\Macro{bfseries}, and for \PValue{chapter}, it is
1375 \Macro{bfseries}. If the \PValue{chapter} level is not defined,
1376 \PValue{section} uses \Macro{bfseries}. All other levels print the
1377 argument unchanged.%
1378 }%
1379 \entry{\OptionVName{entrynumberformat}{command}}{%
1380 You can use this attribute to format the entry number within
1381 \DescRef{\LabelBase.cmd.numberline}. The value should be a \PName{command}
1382 with exactly one argument. Font changes are relative to the one of
1383 attribute \Option{entryformat}.
1384
1385 The initial \PName{command} prints the argument unchanged. This means the
1386 entry number will be printed as it is.
1387
1388 If\textnote{Attention!} the \Option{numberline} feature for a content list
1389 has been activated (see \DescRef{\LabelBase.cmd.setuptoc},
1390 \autoref{sec:\LabelBase.toc}, \DescPageRef{\LabelBase.cmd.setuptoc}), as is
1391 the case with the \KOMAScript{} classes using the
1392 \OptionValueRef{maincls}{toc}{numberline}%
1393 \IndexOption{toc~=\textKValue{numberline}} option, the unnumbered entries
1394 will execute the \PName{command} as well.%
1395 }%
1396 \entry{%
1397 \OptionVName{indent}{length}%
1398 {\phantomsection\labelofbase[tab]{tocstyle.attributes.indent}}%
1399 }{%
1400 For\ChangedAt{v3.27}{\Package{tocbasic}} the \PValue{toctext} style, the
1401 \PName{length} is the horizontal distance of the paragraph from the left
1402 margin. If different entries within the paragraph have different settings,
1403 the last one is used. For the remaining styles, the \PName{length} is the
1404 horizontal distance of the entry from the left margin (see
1405 \autoref{fig:\LabelBase.dottedtocline} and \autoref{fig:\LabelBase.tocline}).
1406
1407 For the styles \PValue{tocline} and \PValue{toctext}, all entry levels
1408 whose names start with ``\texttt{sub}'' are initialised with the
1409 \PValue{indent}+\PValue{numwidth} of the entry level of the same name
1410 without this prefix. For the \PValue{dottedtocline},
1411 \PValue{undottedtocline}, and \PValue{tocline} styles, the initial values
1412 of levels \PValue{part} down to \PValue{subparagraph} and the levels
1413 \PValue{figure}, \PValue{table} and
1414 \ChangedAt{v3.39}{\Package{tocbasic}}\PValue{lstlisting} are compatible
1415 with the standard classes resp. package
1416 \Package{listings}\IndexPackage{listings}. All other levels do not have an
1417 initial value. Therefore you have to set an explicit value for such levels
1418 when they are defined first time.
1419
1420 If the \PValue{noindent} attribute is set for a content list via
1421 \DescRef{\LabelBase.cmd.setuptoc}, the entries of all styles provided by
1422 \KOMAScript{} enforce the value 0\Unit{pt} to deactivate the indent.%
1423 }%
1424 \entry{\OptionVName{level}{integer}}{%
1425 The numerical value of the \PName{entry level}. Only those entries whose
1426 numerical value is less than or equal to the
1427 \DescRef{\LabelBase.counter.tocdepth}%
1428 \important{\DescRef{\LabelBase.counter.tocdepth}}\IndexCounter{tocdepth}
1429 counter are printed.
1430
1431 This attribute is mandatory for all styles and will be defined
1432 automatically when the style is declared.
1433
1434 For the \PValue{tocline} and \PValue{toctext} styles, all entry levels
1435 whose name starts with ``\texttt{sub}'' are initialised with the value of
1436 the entry level of the same name without this prefix plus one. For the
1437 \PValue{dottedtocline}, \PValue{largetocline}, \PValue{tocline},
1438 \PValue{toctext}, and \PValue{undottedtocline} styles, the entry levels
1439 from \PValue{part} to \PValue{subparagraph}, as well as \PValue{figure},
1440 \PValue{table} and
1441 \ChangedAt{v3.39}{\Package{tocbasic}}\PValue{lstlisting}, are initialised
1442 to be compatible with the standard classes resp. package
1443 \Package{listings}\IndexPackage{listings}. For all other levels, the
1444 initialisation is done with the value of \Macro{\PName{entry
1445 level}numdepth}, if this is defined.%
1446 }%
1447 \entry{\OptionVName{indentfollows}{list of levels}}{%
1448 \ChangedAt{v3.31}{\Package{tocbasic}}%
1449 If \Option{dynindent} is set with styles \PValue{tocline} or
1450 \PValue{toctext}\ChangedAt{v3.49}{\Package{tocbasic}}, the comma-separated
1451 list of level names specified here is used to determine the actual
1452 indentation. Levels whose names begin with ``\texttt{sub}'' will be
1453 initialized with the name without this prefix. The \KOMAScript{} classes
1454 also automatically set appropriate values for the levels \PValue{section}
1455 and \PValue{paragraph}.%
1456 }%
1457 \entry{\OptionVName{linefill}{code}}{%
1458 With the \PValue{tocline} style, you can change what is used to fill the
1459 space between the end of the entry text and the page number. The
1460 \PName{linefill} attribute contains the \PName{code} that prints this
1461 filler. For the \PValue{part} and \PValue{chapter} \PName{entry level}s,
1462 the attribute is initialised with \Macro{hfill}. If no \PValue{chapter}
1463 \PName{entry level} has been defined, \PValue{section} also uses
1464 \Macro{hfill}. All other entry levels are initialised with
1465 \DescRef{\LabelBase.cmd.TOCLineLeaderFill} (see
1466 \DescPageRef{\LabelBase.cmd.TOCLineLeaderFill}).
1467
1468 Incidentally, if the \PName{code} specified does not automatically fill
1469 the gap, you should also activate the \PValue{raggedpagenumber} attribute
1470 to avoid ``\texttt{underfull \Macro{hbox}}'' messages.%
1471 }%
1472 \entry{\OptionVName{numsep}{length}}{%
1473 The \PValue{tocline} style tries to ensure a minimum distance of
1474 \PName{length} between the entry number and the entry text. If
1475 \PValue{dynnumwidth} is active, it will correct the number width to
1476 achieve this. Otherwise it simply throws a warning if the condition is not
1477 met.
1478
1479 The\ChangedAt{v3.27}{\Package{tocbasic}} \PValue{toctext} style, on the
1480 other hand, always adds a horizontal space of width \PName{length} after
1481 the number of the entry.
1482
1483 The initial \PName{length} is 0.4\Unit{em}.%
1484 }%
1485 \entry{\OptionVName{numwidth}{length}}{%
1486 The width reserved for the entry number (see
1487 \autoref{fig:\LabelBase.dottedtocline} to
1488 \autoref{fig:\LabelBase.undottedtocline}). With the \PValue{dottedtocline},
1489 \PValue{tocline}, and \PValue{undottedtocline} styles, this \PName{length}
1490 is added to the \PName{length} of attribute \PValue{indent} for the second
1491 and following lines of the entry text.
1492
1493 With the \PValue{tocline} style, the initial \PName{length} of all entries
1494 whose name starts with ``\texttt{sub}'' is the value of the level without
1495 this prefix plus 0.9\Unit{em}, if such a level with corresponding
1496 attributes exists. With the \PValue{dottedtocline},
1497 \PValue{undottedtocline}, and \PValue{tocline} styles, the initial
1498 \PName{length}s of levels from \PValue{part} to \PValue{subparagraph}, as
1499 well as \PName{figure}, \PName{table} and
1500 \ChangedAt{v3.39}{\Package{tocbasic}}\PName{lstlisting}, are compatible
1501 with those of the standard classes resp. package
1502 \Package{listings}\IndexPackage{listings}. All other levels do not have an
1503 initial value. Therefore you must set \PValue{numwidth} explicitly when
1504 the entry level is first used.%
1505 }%
1506 \entry{\OptionVName{onendentry}{code}}{%
1507 \ChangedAt{v3.27}{\Package{tocbasic}}%
1508 The \PName{code} is executed immediately after an entry with the
1509 \PValue{toctext} style, if this entry is not the last one of the
1510 paragraph. The user must ensure that the \PName{code} does not result in
1511 the paragraph ending.
1512
1513 Note: In reality the \PName{code} is not executed at the end of the entry
1514 but before the next entry with style \PValue{toctext}.%
1515 }%
1516 \entry{\OptionVName{onendlastentry}{code}}{%
1517 \ChangedAt{v3.27}{\Package{tocbasic}}%
1518 The \PName{code} is executed immediately before the end of the paragraph
1519 with an entry in the \PValue{toctext} style, as long as this entry is the
1520 last one in the paragraph. The user must ensure that the \PName{code} does
1521 not result in the paragraph ending.%
1522 }%
1523 \entry{\OptionVName{onstartentry}{code}}{%
1524 \ChangedAt{v3.27}{\Package{tocbasic}}%
1525 The \PName{code} is executed immediately before an entry with the
1526 \PValue{toctext} style, unless it is the first one in the paragraph. The
1527 user must ensure that the \PName{code} does not result in the paragraph
1528 ending.%
1529 }%
1530 \entry{\OptionVName{onstartfirstentry}{code}}{%
1531 \ChangedAt{v3.27}{\Package{tocbasic}}%
1532 The \PName{code} is executed immediately before an entry with the
1533 \PValue{toctext} style if this entry is the first one of the paragraph. The
1534 user must ensure that the \PName{code} does not result in the paragraph
1535 ending.%
1536 }%
1537 \entry{\OptionVName{onstarthigherlevel}{code}}{%
1538 The \PValue{tocline} style can execute \PName{code} at the start of an
1539 entry, depending on whether the previous entry had numerical level greater
1540 than, the same as, or less than the current entry. The \PName{code}
1541 specified by this attribute will be executed if the current entry has a
1542 greater numerical value, i.\,e. it is lower in the entry hierarchy, than
1543 the previous one.
1544
1545 Note that detecting the level of the previous entry only works so long as
1546 \Macro{lastpenalty} has not changed since the previous entry.
1547
1548 The initial \PName{code} is \DescRef{\LabelBase.cmd.LastTOCLevelWasLower}
1549 (see \DescPageRef{\LabelBase.cmd.LastTOCLevelWasLower}).%
1550 }%
1551 \entry{\OptionVName{onstartlowerlevel}{code}}{%
1552 The \PValue{tocline} style can execute \PName{code} at the start of an
1553 entry, depending on whether the previous entry had numerical level greater
1554 than, the same as, or less than the current entry. The \PName{code}
1555 specified by this attribute will be executed if the current entry has a
1556 lower numerical value, i.\,e. it is higher in the entry hierarchy, than
1557 the previous one.
1558
1559 Note that detecting the level of the previous entry only works so long as
1560 \Macro{lastpenalty} has not changed since the previous entry.
1561
1562 The initial \PName{code} is \DescRef{\LabelBase.cmd.LastTOCLevelWasHigher}
1563 (see \DescPageRef{\LabelBase.cmd.LastTOCLevelWasHigher}), which usually
1564 favours a page break before the entry.%
1565 }%
1566 \entry{\OptionVName{onstartsamelevel}{code}}{%
1567 The \PValue{tocline} style can execute \PName{code} at the start of an
1568 entry, depending on whether the previous entry had numerical level greater
1569 than, the same as, or less than the current entry. The \PName{code}
1570 specified by this attribute will be executed if the current entry has the
1571 same numerical value, i.\,e. it is on the same level in the entry
1572 hierarchy, as the previous one.
1573
1574 Note that detecting the level of the previous entry only works so long as
1575 \Macro{lastpenalty} has not changed since the previous entry.
1576
1577 The initial \PName{code} is \DescRef{\LabelBase.cmd.LastTOCLevelWasSame}
1578 (see \DescPageRef{\LabelBase.cmd.LastTOCLevelWasSame}), which usually
1579 favours a page break before the entry.%
1580 }%
1581 \entry{\OptionVName{pagenumberbox}{command}}{%
1582 By default the page number of an entry is printed flush right in a box
1583 of width \Macro{@pnumwidth}. In the \PValue{tocline} style, you can
1584 change the \PName{command} to print the number using this attribute. The
1585 \PName{command} should expect exactly one argument, the page number.
1586
1587 This attribute is initialised with the box already mentioned.%
1588 }%
1589 \entry{\OptionVName{pagenumberformat}{command}}{%
1590 You can use this attribute to change the format of the page number of an
1591 entry. The \PName{command} should expect exactly one argument, the page
1592 number. Font changes are relative to the font of \Option{entryformat}
1593 followed by \Macro{normalfont}\Macro{normalsize}.
1594
1595 The initial \PName{command} of entry level \PValue{part} prints the
1596 argument in \Macro{large}\Macro{bfseries} and of entry level
1597 \PValue{chapter} in \Macro{bfseries}. For classes without
1598 \Macro{l@chapter} \PValue{section} also uses \Macro{bfseries}. The initial
1599 \PName{command} of all other levels prints the argument in
1600 \Macro{normalfont}\Macro{normalcolor}.%
1601 }%
1602 \entry{\OptionVName{pagenumberwidth}{length}}{%
1603 \ChangedAt{v3.27}{\Package{tocbasic}}%
1604 You can use this attribute to locally change the width of the default box
1605 for the page number of an entry with the style \PValue{tocline} from
1606 \Macro{@pnumwidth} to the specified \PName{length}. Note that if you
1607 change the default page number box with the \Option{pagenumberbox}
1608 attribute, the specified \PName{length} will no longer be used
1609 automatically.%
1610 }%
1611 \entry{\OptionVName{prepagenumber}{code}}{%
1612 \ChangedAt{v3.27}{\Package{tocbasic}}%
1613 The \PValue{toctext} style executes the \PName{code} between the text and
1614 the page number of the entry. Usually this is used to add a horizontal
1615 space or separator between text and page number.%
1616
1617 The default is a non-breaking space using \Macro{nonbreakspace}.%
1618 }%
1619 \entry{\OptionVName{raggedentrytext}{switch}}{%
1620 The\ChangedAt{v3.21}{\Package{tocbasic}} \PName{switch} is one of the
1621 values for simple switches from \autoref{tab:truefalseswitch},
1622 \autopageref{tab:truefalseswitch}. If the switch is active, the
1623 \PValue{tocline} style prints the text of an entry ragged right instead of
1624 fully justified, and only words that are longer than a text line are
1625 automatically hyphenated.
1626
1627 This \PName{switch} is false by default.%
1628 }%
1629 \entry{\OptionVName{raggedpagenumber}{switch}}{%
1630 The \PName{switch} is one of the values for simple switches from
1631 \autoref{tab:truefalseswitch}, \autopageref{tab:truefalseswitch}. If the
1632 switch is active, the \PValue{tocline} style does not force the page
1633 number to be right justified.
1634
1635 Depending on the value of \PValue{linefill}, setting this attribute could
1636 affect only whether a warning message appears, or the formatting of the
1637 page number as well. So it is important to set both attributes so that
1638 they correspond.
1639
1640 By default the \PName{switch} is not activated and therefore corresponds
1641 with an initial value of \Macro{hfill} or
1642 \DescRef{\LabelBase.cmd.TOCLineLeaderFill} for the \PValue{linefill}
1643 attribute.%
1644 }%
1645 \entry{\OptionVName{raggedright}{switch}}{%
1646 \ChangedAt{v3.27}{\Package{tocbasic}}%
1647 The \PName{switch} is one of the values for simple switches from
1648 \autoref{tab:truefalseswitch}, \autopageref{tab:truefalseswitch}. If the
1649 switch is active for any entry with the \PValue{toctext} style inside the
1650 same paragraph, the whole paragraph is printed ragged right.
1651 }%
1652 \entry{\OptionVName{rightindent}{length}}{%
1653 \ChangedAt{v3.27}{\Package{tocbasic}}%
1654 You can use this attribute to locally change the right indent for the text
1655 of an entry with the \PValue{tocline} style from \Macro{@tocrmarg} to the
1656 specified \PName{length}.%
1657 }%
1658 \end{desclist}
1659
1660 While \Macro{DeclareTOCStyleEntry} defines only one \PName{entry level},
1661 \Macro{DeclareTOCStyleEntries}\ChangedAt{v3.26}{\Package{tocbasic}} can define
1662 an entire list of \PName{entry level}s in one command. Each entry level in the
1663 comma-separated \PName{entry-level list} is defined with the same \PName{style}
1664 and settings of the given \PName{option list}.%
1665 \EndIndexGroup
1666
1667
1668 \begin{Declaration}
1669 \Macro{DeclareTOCEntryStyle}\Parameter{style}%
1670 \OParameter{initial code}%
1671 \Parameter{command code}%
1672 \Macro{DefineTOCEntryOption}\Parameter{option}\OParameter{default value}%
1673 \Parameter{code}%
1674 \Macro{DefineTOCEntryBooleanOption}\Parameter{option}%
1675 \OParameter{default value}%
1676 \Parameter{prefix}%
1677 \Parameter{postfix}%
1678 \Parameter{description}%%
1679 %\OParameter{initial code}%
1680 \Macro{DefineTOCEntryCommandOption}\Parameter{option}%
1681 \OParameter{default value}%
1682 \Parameter{prefix}%
1683 \Parameter{postfix}%
1684 \Parameter{description}%%
1685 %\OParameter{initial code}%
1686 \Macro{DefineTOCEntryIfOption}\Parameter{option}%
1687 \OParameter{default value}%
1688 \Parameter{prefix}%
1689 \Parameter{postfix}%
1690 \Parameter{description}%%
1691 %\OParameter{initial code}%
1692 \Macro{DefineTOCEntryLengthOption}\Parameter{option}%
1693 \OParameter{default value}%
1694 \Parameter{prefix}%
1695 \Parameter{postfix}%
1696 \Parameter{description}%%
1697 %\OParameter{initial code}%
1698 \Macro{DefineTOCEntryNumberOption}\Parameter{option}%
1699 \OParameter{default value}%
1700 \Parameter{prefix}%
1701 \Parameter{postfix}%
1702 \Parameter{description}%
1703 %\OParameter{initial code}%
1704 \end{Declaration}
1705 \Macro{DeclareTOCEntryStyle}\ChangedAt{v3.20}{\Package{tocbasic}} is
1706 one of the most complex commands in \KOMAScript. It is therefore explicitly
1707 intended for \LaTeX{} developers and not for ordinary \LaTeX{} users. It lets
1708 you define new a \PName{style} for content-list entries. Usually, entries to
1709 content lists are made using
1710 \Macro{addcontentsline}\IndexCmd{addcontentsline}, or preferably, if you use
1711 \Package{tocbasic}, with
1712 \DescRef{\LabelBase.cmd.addxcontentsline}\IndexCmd{addxcontentsline} (see
1713 \autoref{sec:\LabelBase.basics}, \DescPageRef{\LabelBase.cmd.addxcontentsline}).
1714 In both cases \LaTeX{} writes a corresponding
1715 \Macro{contentsline}\IndexCmd{contentsline} to the appropriate auxiliary file.
1716 When reading this auxiliary file, \LaTeX{} then executes a
1717 \Macro{l@\PName{entry level}} command for each \Macro{contentsline}.
1718
1719 If you later assign a \PName{style} to an entry level using
1720 \DescRef{\LabelBase.cmd.DeclareTOCStyleEntry}, the \PName{initial code} is
1721 executed first, if provided, and then the \PName{command code} for the
1722 definition of \Macro{l@\PName{entry level}}. The \PName{command code} is the
1723 code that will be expanded and executed by \Macro{l@\PName{entry level}}.
1724 Inside \PName{command code} \texttt{\#1} is the name of the TOC entry level
1725 and \texttt{\#\#1} and \texttt{\#\#2} are the arguments of
1726 \Macro{l@\PName{entry level}}.
1727
1728 The \PName{initial code} serves first to initialise all attributes of the
1729 \PName{style}. Developers should make sure that all attributes are provided
1730 with values here. Only then does \DescRef{\LabelBase.cmd.DeclareTOCStyleEntry}
1731 work without errors if an \PName{option list} is not specified. The second
1732 task of the \PName{initial code} is to define all the options that this
1733 \PName{style} recognises. The \Option{level} option is always defined
1734 automatically. The value of the \Option{level} can be queried within the
1735 \PName{command code} with \Macro{@nameuse}\PParameter{\#1tocdepth}%
1736 \important{\Macro{\PName{entry level}tocdepth}}, for example, to compare it
1737 with the \DescRef{\LabelBase.counter.tocdepth}\IndexCounter{tocdepth} counter.
1738
1739 To define options for the attributes of the \PName{style} inside the
1740 \PName{initial code}, you can use the commands
1741 \Macro{DefineTOCEntryBooleanOption}, \Macro{DefineTOCEntryCommandOption},
1742 \Macro{DefineTOCEntryIfOption}, \Macro{DefineTOCEntryLengthOption}, and
1743 \Macro{DefineTOCEntryNumberOption}. These commands each define an
1744 \PName{option} that, when called, defines a macro named
1745 \Macro{\PName{prefix}\PName{entry level}\PName{postfix}} set to the given
1746 value or to the \PName{default value} of the option. The
1747 \Macro{DefineTOCEntryIfOption} command is a somewhat special case. It defines
1748 \Macro{\PName{prefix}\PName{entry level}\PName{postfix}} as a command with two
1749 arguments. If the value passed to the option is one of the activation (true)
1750 values from \autoref{tab:truefalseswitch}, \autopageref{tab:truefalseswitch},
1751 the command expands to the first argument. If the value to the option is a
1752 deactivation (false) value, the command expands to the second argument.
1753
1754 In\ChangedAt{v3.27}{\Package{tocbasic}} addition to the usual options of the
1755 form \Option{\PName{key}=\PName{value}}, the five
1756 \Macro{DefineTOCEntry\dots Option} commands automatically define options of
1757 the form \Option{\PName{key}:=\PName{entry level}}. These copy the value of
1758 another \PName{entry level} if the value is stored in a macro with the same
1759 \PName{prefix} and \PName{postfix}. For the styles predefined by
1760 \Package{tocbasic}, this is the case for all options of the same name
1761 independent of the name of the style. The commands
1762 \Macro{DefineTOCEntryLengthOption} and \Macro{DefineTOCEntryNumberOption} also
1763 define options of the form \Option{\PName{key}:=\PName{value}}, which are used
1764 to add the new \PName{value} to the value already stored in
1765 \Macro{\PName{prefix}\PName{entry level}\PName{postfix}}.
1766
1767 The \PName{description} should be a brief message that describes the sense
1768 of the option with some keywords. The \Package{tocbasic} package uses this text
1769 in error messages, warnings, and information output on the terminal and to the
1770 \File{log} file.
1771
1772 The simplest style of \Package{tocbasic}, \PValue{gobble}, is defined
1773 using:
1774 \begin{lstcode}
1775 \DeclareTOCEntryStyle{gobble}{}%
1776 \end{lstcode}
1777 If you now define an entry level \PValue{dummy} in this style using:
1778 \begin{lstcode}
1779 \DeclareTOCStyleEntry[level=1]{gobble}{dummy}
1780 \end{lstcode}
1781 this would correspond, among other things, to:
1782 \begin{lstcode}
1783 \def\dummytocdepth{1}
1784 \def\l@dummy#1#2{}
1785 \end{lstcode}
1786
1787 For example, within the \PValue{tocline} style,
1788 \begin{lstcode}
1789 \DefineTOCEntryCommandOption{linefill}[\TOCLineLeaderFill]%
1790 {scr@tso@}{@linefill}{filling between text and page number}%
1791 \end{lstcode}
1792 is used to define the \Option{linefill} option. By specifying
1793 \DescRef{\LabelBase.cmd.TOCLineLeaderFill} as the \PName{default value},
1794 a call such as
1795 \begin{lstcode}
1796 \DeclareTOCStyleEntry[linefill]{tocline}{part}
1797 \end{lstcode}
1798 would, among other things, create the definition
1799 \begin{lstcode}
1800 \def\scr@tso@part@linefill{\TOCLineLeaderFill}
1801 \end{lstcode}
1802
1803 If you want to define your own styles, you should first study the definition
1804 of the \PValue{dottedtocline} style. After you understand this definition, you
1805 can find many hints as to how to use the commands effectively in the much more
1806 complex definition of the \PValue{tocline} style.
1807
1808 However, in many cases it will be sufficient to clone an existing style using
1809 \DescRef{\LabelBase.cmd.CloneTOCEntryStyle} and to change the initial code of
1810 the new style using \DescRef{\LabelBase.cmd.TOCEntryStyleInitCode} or
1811 \DescRef{\LabelBase.cmd.TOCEntryStyleStartInitCode}.
1812
1813 \Macro{DefineTOCEntryOption} is merely used to define the other commands and
1814 you should not use it directly. Normally, there is no need for it. It is
1815 mentioned here only for the sake of completeness.%
1816 \EndIndexGroup
1817
1818
1819 \begin{Declaration}
1820 \Macro{CloneTOCEntryStyle}\Parameter{style}\Parameter{new style}%
1821 \end{Declaration}
1822 With\ChangedAt{v3.20}{\Package{tocbasic}} this command you can clone
1823 an existing \PName{style}. It defines a \PName{new style} with the same
1824 attributes and settings as the existing \PName{style}. The package itself uses
1825 \Macro{CloneTOCEntryStyle} to declare the \PValue{default} style as a clone of
1826 \PValue{dottedtocline}. The \KOMAScript{} classes use the command to declare
1827 the styles \PValue{part}, \PValue{section}, and \PValue{chapter} or
1828 \PValue{subsection} as clones of \PValue{tocline} and then modify them with
1829 \DescRef{\LabelBase.cmd.TOCEntryStyleInitCode} and
1830 \DescRef{\LabelBase.cmd.TOCEntryStyleStartInitCode}. The \Class{scrbook} and
1831 \Class{scrreprt} classes newly declare the \PValue{default} style as a clone
1832 of \PValue{section}, and \Class{scrartcl} declares it as a clone of
1833 \PValue{subsection}.%
1834 \EndIndexGroup
1835
1836
1837 \begin{Declaration}
1838 \Macro{TOCEntryStyleInitCode}\Parameter{style}%
1839 \Parameter{initial code}%
1840 \Macro{TOCEntryStyleStartInitCode}\Parameter{style}%
1841 \Parameter{initial code}
1842 \end{Declaration}
1843 Every\ChangedAt{v3.20}{\Package{tocbasic}} TOC-entry style has an
1844 initialisation code. This is used whenever a \PName{style} is assigned to an
1845 TOC entry using \DescRef{\LabelBase.cmd.DeclareTOCEntryStyle}. This
1846 \PName{initial code} should not have global side effects, because it is also
1847 used for local initialisation inside other commands like
1848 \DescRef{\LabelBase.cmd.DeclareNewTOC}\IndexCmd{DeclareNewTOC}. The
1849 \PName{initial code} not only defines all attributes of a \PName{style}, but
1850 it also sets the defaults for those attributes.
1851
1852 You can use \Macro{TOCEntryStyleStartInitCode} and
1853 \Macro{TOCEntryStyleInitCode} to extend previously existing initialisation
1854 code with further \PName{initial code}. \Macro{TOCEntryStyleStartInitCode}
1855 adds \PName{initial code} in front of the existing code.
1856 \Macro{TOCEntryStyleInitCode} adds the \PName{initial code} at the end of the
1857 existing initialisation code. The \KOMAScript{} classes, for example, use
1858 \Macro{TOCEntryStyleStartInitCode} to properly initialise the fill, fonts, and
1859 vertical spacing of the \PValue{part} style cloned from \PValue{tocline}. For
1860 example, the \Class{scrbook} and \Class{scrreprt} classes use
1861 \begin{lstcode}
1862 \CloneTOCEntryStyle{tocline}{section}
1863 \TOCEntryStyleStartInitCode{section}{%
1864 \expandafter\providecommand%
1865 \csname scr@tso@#1@linefill\endcsname
1866 {\TOCLineLeaderFill\relax}%
1867 }
1868 \end{lstcode}
1869 to define \PValue{section} as a modified clone of \PValue{tocline}.%
1870 \EndIndexGroup
1871
1872
1873 \begin{Declaration}
1874 \Macro{LastTOCLevelWasHigher}%
1875 \Macro{LastTOCLevelWasSame}%
1876 \Macro{LastTOCLevelWasLower}
1877 \end{Declaration}
1878 At\ChangedAt{v3.20}{\Package{tocbasic}} the beginning of entries
1879 using the \PValue{tocline} style, \Package{tocbasic} executes one of these
1880 three commands depending on \Macro{lastpenalty}. \Macro{LastTOCLevelWasHigher}
1881 and \Macro{LastTOCLevelWasSame} used in vertical mode add
1882 \Macro{addpenalty}\PParameter{\Macro{@lowpenalty}} and therefore permit a page
1883 break before an entry with the same or higher hierarchical position.
1884 \Macro{LastTOCLevelWasLower} is empty, so a page break between an entry and
1885 its first sub-entry is not permitted.
1886
1887 Users should not redefine these commands. Instead, you should change the
1888 behaviour of single entry levels using the \PValue{onstartlowerlevel},
1889 \PValue{onstartsamelevel}, and \PValue{onstarthigherlevel} attributes.%
1890 \EndIndexGroup
1891
1892
1893 \begin{Declaration}
1894 \Macro{TOCLineLeaderFill}\OParameter{leader}
1895 \end{Declaration}
1896 This\ChangedAt{v3.20}{\Package{tocbasic}} command is intended to be
1897 used as a value for the \Option{linefill} option of the \PName{tocline}
1898 TOC-entry style. It creates a connection between the end of the entry text and
1899 the entry's page number. You can specify the \PName{leader}, which is repeated
1900 at regular intervals, as an optional argument. The default is a dot.
1901
1902 As the name suggests, the command uses \Macro{leaders} to output the
1903 \PName{leader}. The spacing used is defined analogously to the \LaTeX{} kernel
1904 command \Macro{@dottedtocline} by
1905 \Macro{mkern}\Macro{@dotsep}\Unit{\texttt{mu}}.%
1906 \EndIndexGroup
1907 \EndIndexGroup
1908
1909
1910 \section{Internal Commands for Class and Package Authors}
1911 \seclabel{internals}
1912
1913 The \Package{tocbasic} package provides some internal commands for the use of
1914 class and package authors. These commands all begin with the prefix
1915 \Macro{tocbasic@}. But\textnote{Attention!} even class or package authors
1916 should not redefine them! Their inner functioning may be changed or extended
1917 at any time, so redefining these commands could significantly damage the
1918 \Package{tocbasic}'s operation.
1919
1920 \begin{Declaration}
1921 \Macro{tocbasic@extend@babel}\Parameter{extension}
1922 \end{Declaration}
1923 At every change of the current language, either at the beginning of the
1924 document or inside the document, the \Package{babel}\IndexPackage{babel}
1925 package (see \cite{package:babel}), or rather a \LaTeX{} kernel enhanced by
1926 \Package{babel}'s language management, writes language-switching commands to
1927 the files with the \File{toc}, \File{lof}, and \File{lot} extensions. The
1928 \Package{tocbasic} package extends this mechanism with
1929 \Macro{tocbasic@extend@babel} so that it also works for other file extensions.
1930 The \PName{extension} argument must be completely expanded! Otherwise the
1931 there is a risk that, for example, the meaning of the argument has already
1932 change at the time it is actually evaluated.
1933
1934 This command is typically invoked by default for every file \PName{extension}
1935 added to the list of known extensions with
1936 \DescRef{\LabelBase.cmd.addtotoclist}. You can suppress this with the
1937 \PValue{nobabel}\important{\PValue{nobabel}} feature (see
1938 \DescRef{\LabelBase.cmd.setuptoc}, \autoref{sec:\LabelBase.toc},
1939 \DescPageRef{\LabelBase.cmd.setuptoc}). \Package{tocbasic} does this
1940 automatically for the extensions \File{toc}, \File{lof}, and \File{lot} to
1941 avoid switching languages twice in the corresponding files.
1942
1943 There is usually no reason to call this command yourself. However, there could
1944 conceivably be content lists that are not under the control of
1945 \Package{tocbasic} and so are not in \Package{tocbasic}'s list of known file
1946 extensions, but which nevertheless should use \Package{babel}'s language
1947 switching mechanism. You can call the command explicitly for those files.
1948 But\textnote{Attention!} please note that this should be done only once per
1949 file extension!%
1950 \EndIndexGroup
1951
1952
1953 \begin{Declaration}
1954 \Macro{tocbasic@starttoc}\Parameter{extension}
1955 \end{Declaration}
1956 This command is the actual replacement for the
1957 \Macro{@starttoc}\IndexCmd{@starttoc}\important{\Macro{@starttoc}} command
1958 from the \LaTeX{} kernel. It is the command behind
1959 \DescRef{\LabelBase.cmd.listoftoc*} (see \autoref{sec:\LabelBase.toc},
1960 \DescPageRef{\LabelBase.cmd.listoftoc*}). Class or package authors who want to
1961 take advantage of \Package{tocbasic} should at least use this command, or even
1962 better, \DescRef{\LabelBase.cmd.listoftoc}. The command uses
1963 \Macro{\@starttoc} internally, but sets
1964 \Length{parskip}\IndexLength{parskip}\important{\Length{parskip}\\
1965 \Length{parindent}\\ \Length{parfillskip}},
1966 \Length{parindent}\IndexLength{parindent} to 0, and \Length{parfillskip} to 0
1967 to infinity. Moreover,
1968 \Macro{@currext}\important{\Macro{@currext}}\IndexCmd{@currext} is set to the
1969 file extension of the current TOC file, so it can be evaluated during the
1970 subsequent execution of the hooks. You can find an explanation of these hooks
1971 below.
1972
1973 Because\textnote{Attention!} \LaTeX{} opens a new content-list file for
1974 writing after reading that file, calling this command may result in an error
1975 message of the type
1976 \begin{lstoutput}
1977 ! No room for a new \write .
1978 \ch@ck ...\else \errmessage {No room for a new #3}
1979 \fi
1980 \end{lstoutput}
1981 if no more write handles are available. You can solve this problem by loading
1982 the \Package{scrwfile}\important{\Package{scrwfile}}\IndexPackage{scrwfile}
1983 package \cite{package:scrwfile} or by using \LuaLaTeX{}.%
1984 \EndIndexGroup
1985
1986
1987 \begin{Declaration}
1988 \Macro{tocbasic@@before@hook}%
1989 \Macro{tocbasic@@after@hook}
1990 \end{Declaration}
1991 The \Macro{tocbasic@@before@hook} hook is executed immediately before reading
1992 an auxiliary file for a content list, before executing the commands defined
1993 with \DescRef{\LabelBase.cmd.BeforeStartingTOC} command. You can extend this
1994 hook using \Macro{g@addto@macro}\IndexCmd{g@addto@macro}.
1995
1996 Similarly, \Macro{tocbasic@@after@hook} is executed immediately after reading
1997 such an auxiliary file and before executing the commands defined with
1998 \DescRef{\LabelBase.cmd.AfterStartingTOC}. You can extend this hook using
1999 \Macro{g@addto@macro}\IndexCmd{g@addto@macro}.
2000
2001 \KOMAScript{} uses these hooks to dynamically adjust content lists to the
2002 width of the heading numbers. Only classes and packages should use these
2003 hooks. Users\textnote{Attention!} should really use
2004 \DescRef{\LabelBase.cmd.BeforeStartingTOC} and
2005 \DescRef{\LabelBase.cmd.AfterStartingTOC} instead. Authors of packages should
2006 also prefer these commands. These hooks should not be used to generate any
2007 output!
2008
2009 If neither\textnote{Attention!} \DescRef{\LabelBase.cmd.listofeachtoc} nor
2010 \DescRef{\LabelBase.cmd.listoftoc} nor \DescRef{\LabelBase.cmd.listoftoc*} are
2011 used to output the content list, the hooks should be executed explicitly.%
2012 \EndIndexGroup
2013
2014
2015 \begin{Declaration}
2016 \Macro{tocbasic@\PName{extension}@before@hook}%
2017 \Macro{tocbasic@\PName{extension}@after@hook}
2018 \end{Declaration}
2019 These hooks are executed directly after
2020 \DescRef{\LabelBase.cmd.tocbasic@@before@hook} or before
2021 \DescRef{\LabelBase.cmd.tocbasic@@after@hook} for the TOC file with the
2022 corresponding file \PName{extension}. Class\textnote{Attention!} and package
2023 authors should never change them under any circumstances! If
2024 neither\textnote{Attention!} \DescRef{\LabelBase.cmd.listofeachtoc} nor
2025 \DescRef{\LabelBase.cmd.listoftoc} nor \DescRef{\LabelBase.cmd.listoftoc*} are
2026 used to output a content list, the hooks should nevertheless be called, if
2027 they are defined. These commands can be undefined.%
2028 \iffalse % With current LaTeX you can simply use \@ifundefined
2029 For an appropriate test, see \DescRef{scrbase.cmd.Ifundefinedorrelax}%
2030 \IndexCmd{Ifundefinedorrelax} in \autoref{sec:scrbase.if},
2031 \DescPageRef{scrbase.cmd.Ifundefinedorrelax}.%
2032 \fi%
2033 \EndIndexGroup
2034
2035
2036 \begin{Declaration}
2037 \Macro{tocbasic@listhead}\Parameter{title}
2038 \end{Declaration}
2039 This command is used by \DescRef{\LabelBase.cmd.listoftoc} and
2040 \DescRef{\LabelBase.cmd.listofeachtoc} to set the heading of the content list.
2041 This can be either the default heading of the \Package{tocbasic} package or a
2042 custom definition. If you define your own command for the heading, you can
2043 also use \Macro{tocbasic@listhead}. In this case, you should define
2044 \Macro{@currext}\important{\Macro{@currext}}\IndexCmd{@currext} to be the file
2045 extension of the corresponding TOC file before using
2046 \Macro{tocbasic@listhead}.%
2047 \EndIndexGroup
2048
2049
2050 \begin{Declaration}
2051 \Macro{tocbasic@listhead@\PName{extension}}\Parameter{title}
2052 \end{Declaration}
2053 This command is used in \DescRef{\LabelBase.cmd.tocbasic@listhead} to set the
2054 individual headings, optional table of contents entry, and running head, if it
2055 is defined. Otherwise, \DescRef{\LabelBase.cmd.tocbasic@listhead} defines them
2056 before their use.%
2057 \EndIndexGroup
2058
2059
2060 \begin{Declaration}
2061 \Macro{tocbasic@addxcontentsline}%
2062 \Parameter{extension}\Parameter{level}\Parameter{number}\Parameter{text}%
2063 \Macro{nonumberline}
2064 \end{Declaration}
2065 The\ChangedAt{v3.12}{\Package{tocbasic}} \Macro{tocbasic@addxcontentsline}
2066 command creates entry of the specified level in the TOC file with the given
2067 \PName{extension}. Whether the entry is numbered or not depends on whether or
2068 not the \PName{number} argument is empty. In this case the \PName{text} will
2069 be prefixed by \Macro{nonumberline} without any argument. Otherwise,
2070 \DescRef{\LabelBase.cmd.numberline} with the \PName{number} argument will used
2071 as usual.
2072
2073 The \Macro{nonumberline} command is redefined inside
2074 \DescRef{\LabelBase.cmd.listoftoc} (see \autoref{sec:\LabelBase.toc},
2075 \DescPageRef{\LabelBase.cmd.listoftoc}) depending on the \PValue{numberline}
2076 feature (see \autoref{sec:\LabelBase.toc},
2077 \DescPageRef{\LabelBase.cmd.setuptoc}). As a result, changing this feature
2078 results in changes of the corresponding TOC immediately at the next \LaTeX{}
2079 run.%
2080 \EndIndexGroup
2081
2082
2083 \begin{Declaration}
2084 \Macro{tocbasic@DependOnPenaltyAndTOCLevel}\Parameter{entry level}%
2085 \Macro{tocbasic@SetPenaltyByTOCLevel}\Parameter{entry level}
2086 \end{Declaration}
2087 The\ChangedAt{v3.20}{\Package{tocbasic}} \PValue{tocline}
2088 content-list style (see \autoref{sec:\LabelBase.tocstyle}) sets a
2089 \Macro{penalty} at the end of each entry via
2090 \Macro{tocbasic@SetPenaltyByTOCLevel} so that no page break can occur after an
2091 entry. The exact value chosen depends on the \PName{entry level}.
2092
2093 At the beginning of an entry, \Macro{tocbasic@DependOnPenaltyAndTOCLevel} is
2094 used to execute the value of the \Option{onstartlowerlevel}, the
2095 \Option{onstartsamelevel}, or the \Option{onstarthigherlevel} style option,
2096 depending on \Macro{lastpenalty} and the current \PName{entry level}. By
2097 default, the first two permit a page break when executed in vertical mode.
2098
2099 Developers of \PValue{tocline}-compatible styles should copy this behaviour.
2100 To do so, they can fall back on these internal macros.%
2101 \EndIndexGroup
2102
2103
2104 \section{A Complete Example}
2105 \seclabel{example}
2106
2107 This section provides a complete example of how to define your own floating
2108 environment including an associated content list and \KOMAScript{} integration
2109 using \Package{tocbasic}. This example uses internal commands, that is, they
2110 have a ``\texttt{@}'' in their name. This means\textnote{Attention}, that you
2111 must either put the code into a package or class or placed it between
2112 \Macro{makeatletter}\important[i]{\Macro{makeatletter}\\\Macro{makeatother}}%
2113 \IndexCmd{makeatletter} and \Macro{makeatother}\IndexCmd{makeatother}.
2114
2115 First\textnote{environment}, we need a new floating environment.
2116 That's easy with the following:
2117 \begin{lstcode}
2118 \newenvironment{remarkbox}{%
2119 \@float{remarkbox}%
2120 }{%
2121 \end@float
2122 }
2123 \end{lstcode}
2124 The new environment is named \Environment{remarkbox}.
2125
2126 Each\textnote{placement} floating environment has a default placement. It
2127 consists of one or more of the well-known placement options: \PValue{b},
2128 \PValue{h}, \PValue{p} and \PValue{t}.
2129 \begin{lstcode}
2130 \newcommand*{\fps@remarkbox}{tbp}
2131 \end{lstcode}
2132 The new floating environment should be placed by default only either at
2133 the top of a page, at the bottom of a page, or on a separate page.
2134
2135 Floating\textnote{type} environments also have a numerical floating
2136 type between 1 and 31. Environments with the same active bit at the floating type cannot change
2137 their order. Figures and tables normally use type~1 and 2. So a figure that
2138 comes later in the source code than a table may be output earlier than the
2139 table and vice versa.
2140 \begin{lstcode}
2141 \newcommand*{\ftype@remarkbox}{4}
2142 \end{lstcode}
2143 The new environment has floating type~4, so it may pass figures and floats and
2144 may be passed by those.
2145
2146 The\textnote{number} captions of floating environment also have numbers.
2147 \begin{lstcode}
2148 \newcounter{remarkbox}
2149 \newcommand*{\remarkboxformat}{%
2150 Remark~\theremarkbox\csname autodot\endcsname}
2151 \newcommand*{\fnum@remarkbox}{\remarkboxformat}
2152 \end{lstcode}
2153 Here, a new counter is defined first, which is independent of the chapters
2154 or the counters of other structural levels. \LaTeX{} itself also defines
2155 \Macro{theremarkbox} with the default output as an Arabic number.
2156 This is then used to define the formatted output of the
2157 counter. The formatted output is again defined as a floating-point
2158 number for use in the \DescRef{\LabelBase.cmd.caption} command.
2159
2160 Floating\textnote{file name extension} environments have their own content lists
2161 and those need an auxiliary file named \Macro{jobname} and a file
2162 extension:
2163 \begin{lstcode}
2164 \newcommand*{\ext@remarkbox}{lor}
2165 \end{lstcode}
2166 As the file extension, we use ``\File{lor}''.
2167
2168 With this, the floating environment works. But the content list of
2169 is still missing. So that we do not have to implement it ourselves, we
2170 use the \Package{tocbasic} package. This is loaded with
2171 \begin{lstcode}
2172 \usepackage{tocbasic}
2173 \end{lstcode}
2174 inside of document preambles. Class or package authors would use
2175 \begin{lstcode}
2176 \RequirePackage{tocbasic}
2177 \end{lstcode}
2178 instead.
2179
2180 Now\textnote{extension} we register the file name extension with the
2181 \Package{tocbasic} package:
2182 \begin{lstcode}
2183 \addtotoclist[float]{lor}
2184 \end{lstcode}
2185 We use \PValue{float} as the owner so that all options of \KOMAScript{}
2186 classes that relate to lists of floating environments also apply to the new
2187 content list.
2188
2189 Next\textnote{title} we define a title or heading for this content list:
2190 \begin{lstcode}
2191 \newcommand*{\listoflorname}{List of Remarks}
2192 \end{lstcode}
2193 When working with multiple languages, the normal practice is to define an
2194 English title first and then, for example with the help of the
2195 \Package{scrbase} package, to add titles for all the other languages you want
2196 to support. See \autoref{sec:scrbase.languageSupport}, starting on
2197 \autopageref{sec:scrbase.languageSupport}.
2198
2199 Now\textnote{entry} all we have to do is define what a single entry in the
2200 content list should look like:
2201 \begin{lstcode}
2202 \newcommand*{\l@remarkbox}{\l@figure}
2203 \end{lstcode}
2204 This specifies that entries in the list of remarks should look exactly like the
2205 entries in the list of figures. This would be the easiest solution. A more
2206 explicit definition would be something like:
2207 \begin{lstcode}
2208 \DeclareTOCStyleEntry[level=1,indent=1em,numwidth=1.5em]%
2209 {tocline}{remarkbox}
2210 \end{lstcode}
2211
2212 You\textnote{chapter entry} also want chapter entries to affect the content
2213 list.
2214 \begin{lstcode}
2215 \setuptoc{lor}{chapteratlist}
2216 \end{lstcode}
2217 Setting this property allows this when you use a \KOMAScript{} class, and other class
2218 that supports this property. Unfortunately, the standard classes do not.
2219
2220 This\textnote{list of remarks} should be enough. Users can now
2221 select different kinds of headings using the corresponding options of
2222 the \KOMAScript{} classes or \DescRef{\LabelBase.cmd.setuptoc}, (e.\,g. with
2223 or without an entry in the table of contents, with or without numbering). But
2224 with a simple
2225 \begin{lstcode}
2226 \newcommand*{\listofremarkboxes}{\listoftoc{lor}}
2227 \end{lstcode}
2228 you can simplify the usage even more.
2229
2230 As you've seen, just five one-line commands, of which only three or four are
2231 really necessary, refer to the content list. Nevertheless, the new list of
2232 remarks already provides the ability to place both numbered and unnumbered
2233 entries into the table of contents.You can use a lower sectioning level for
2234 the headings. Running heads are set for the \KOMAScript{} classes, the
2235 standard classes, and all classes that explicitly support \Package{tocbasic}.
2236 Supporting classes even pay attention to this new list of remarks at each new
2237 \DescRef{maincls.cmd.chapter}. Even changes to the current language made with
2238 \Package{babel} are included in the list of remarks.
2239
2240 Of course\textnote{additional features}, package authors can add more
2241 features. For example, they could explicitly offer options to hide
2242 \DescRef{\LabelBase.cmd.setuptoc} from users. Or they can refer to the
2243 \Package{tocbasic} manual when explaining the appropriate features. The
2244 advantage of this is that users automatically benefit from any future
2245 extensions to \Package{tocbasic}. However, if you do not want to burden the
2246 user with the fact that the file extension \File{lor} is used for the key
2247 terms, then
2248 \begin{lstcode}
2249 \newcommand*{\setupremarkboxes}{\setuptoc{lor}}
2250 \end{lstcode}
2251 is sufficient to set a list of features passed as an argument to
2252 \Macro{setupremarkboxes} as a list of features for the file extension
2253 \File{lor}.
2254
2255 \section{Everything with Only One Command}
2256 \seclabel{declarenewtoc}
2257
2258 The example in the previous section has shows that \Package{tocbasic} makes it
2259 easy to define your own floating environments with their own content lists.
2260 This section shows how it can be even easier.
2261
2262 \begin{Declaration}
2263 \Macro{DeclareNewTOC}\OParameter{options}\Parameter{extension}
2264 \end{Declaration}
2265 This command declares\ChangedAt{v3.06}{\Package{tocbasic}} a new content list,
2266 its heading, and the description of the entries controlled by
2267 \Package{tocbasic} all in a single step. Optionally, you can also define
2268 floating and non-floating environments at the same time. Inside of both such
2269 environments, \DescRef{\LabelBase.cmd.caption}%
2270 \important{\DescRef{\LabelBase.cmd.caption}}\IndexCmd{caption} creates entries
2271 for this new content list. You can also use the \KOMAScript{} extensions
2272 \DescRef{\LabelBase.cmd.captionabove}\important[i]{%
2273 \DescRef{\LabelBase.cmd.captionabove}\\
2274 \DescRef{\LabelBase.cmd.captionbelow}}, \DescRef{\LabelBase.cmd.captionbelow}, and
2275 \DescRef{maincls.env.captionbeside} (see \autoref{sec:maincls.floats}).
2276
2277 The \PName{extension} argument is the file extension of the TOC file that
2278 represents the content list, as explained in \autoref{sec:\LabelBase.basics}.
2279 This argument is mandatory and must not be empty!
2280
2281 The \PName{options} argument is a comma-separated list, of the same type as,
2282 for example, \DescRef{maincls.cmd.KOMAoptions} (see
2283 \autoref{sec:typearea.options}). However\textnote{Attention!}, those options
2284 cannot be set using \DescRef{maincls.cmd.KOMAoptions}\IndexCmd{KOMAoptions}!
2285 You can find an overview of all available options in
2286 \autoref{tab:\LabelBase.DeclareNewTOC-options}.
2287
2288 If\ChangedAt{v3.20}{\Package{tocbasic}} the \Option{tocentrystyle}
2289 option is not used, the \PValue{default} style will be used if required. For
2290 information about this style, see \autoref{sec:\LabelBase.tocstyle}. If you do
2291 not want to define a command for entries to the content list, you can use an
2292 empty argument, i.\,e. \OptionValue{tocentrystyle}{} or
2293 \OptionValue{tocentrystyle}{\PParameter{}}.
2294
2295 Depending\ChangedAt{v3.20}{\Package{tocbasic}}%
2296 \ChangedAt{v3.21}{\Package{tocbasic}} on the style of the entries to
2297 the content list, you can set all valid attributes of the selected style as
2298 part of the \PName{options}. To do so, you must add the prefix
2299 \PValue{tocentry} to the names of the attributes given in
2300 \autoref{tab:\LabelBase.tocstyle.attributes}, starting on
2301 \autopageref{tab:\LabelBase.tocstyle.attributes}. You can make later changes to
2302 the style of the entries at any time using
2303 \DescRef{\LabelBase.cmd.DeclareTOCStyleEntry}%
2304 \IndexCmd{DeclareTOCStyleEntry}%
2305 \important{\DescRef{\LabelBase.cmd.DeclareTOCStyleEntry}}. See
2306 \autoref{sec:\LabelBase.tocstyle},
2307 \DescPageRef{\LabelBase.cmd.DeclareTOCStyleEntry} for more information about
2308 the styles.%
2309 %
2310 \begin{desclist}
2311 \renewcommand*{\abovecaptionskipcorrection}{-\normalbaselineskip}%
2312 \desccaption[{Options for command \Macro{DeclareNewTOC}}]{%
2313 Options for the
2314 \Macro{DeclareNewTOC}\ChangedAt{v3.06}{\Package{tocbasic}} command%
2315 \labelofbase[tab]{DeclareNewTOC-options}%
2316 }{%
2317 Options for the \Macro{DeclareNewTOC} command (\emph{continued})%
2318 }%
2319 \entry{\OptionVName{atbegin}{commands}%
2320 \ChangedAt{v3.09}{\Package{tocbasic}}}{%
2321 The \PName{commands} will be executed at the begin of the floating or
2322 non-floating environment.%
2323 }%
2324 \entry{\OptionVName{atend}{commands}%
2325 \ChangedAt{v3.09}{\Package{tocbasic}}}{%
2326 The \PName{commands} will be executed at the end of the floating or
2327 non-floating environment.%
2328 }%
2329 \entry{\OptionVName{category}{string}}{%
2330 \ChangedAt{v3.27}{\Package{tocbasic}}%
2331 This option can be used as a synonym for \OptionVName{owner}{string}.%
2332 }%
2333 \entry{\OptionVName{counterwithin}{\LaTeX{} counter}}{%
2334 If you define a new floating or non-floating environment, a new counter
2335 \Counter{\PName{type}} will be created as well (see option
2336 \Option{type}). You can make this counter dependent on another
2337 \PName{\LaTeX{} counter} in the same way, for example, that the
2338 \Counter{figure} counter in the \Class{book} classes is dependent on the
2339 \Counter{chapter} counter. A\ChangedAt{v3.35}{\Package{tocbasic}} setting
2340 \OptionValue{counterwithin}{chapter} is used for classes with
2341 \DescRef{maincls.cmd.chapter}\IndexCmd{chapter} only in the main matter
2342 (see \DescRef{maincls.cmd.frontmatter}\IndexCmd{frontmatter},
2343 \DescRef{maincls.cmd.mainmatter} and
2344 \DescRef{maincls.cmd.backmatter}\IndexCmd{backmatter} in
2345 \autoref{sec:maincls.separation}, \DescPageRef{maincls.cmd.frontmatter})
2346 and only if the counter \Counter{chapter}\IndexCounter{chapter} is greater
2347 than zero at output. For classes without \DescRef{maincls.cmd.chapter}
2348 this applies accordingly to the \OptionValue{counterwithin}{section}
2349 setting and counter
2350 \Counter{section}\IndexCounter{section}\IndexCmd{section}.%
2351 }%
2352 \entry{\Option{float}}{%
2353 If set, defines a new content list and a floating environment, both named
2354 \PName{type}, and an environment for double-column floats named
2355 \PName{type*}.%
2356 }%
2357 \entry{\OptionVName{floatpos}{float positions}}{%
2358 Each floating environment has default \PName{float positions} that can be
2359 changed through the optional argument of the floating environment. The
2360 syntax and semantics are identical to those of the standard floating
2361 environments. If the option is not used, the default \PName{float
2362 positions} are ``\texttt{tbp}'', that is \emph{top}, \emph{bottom},
2363 \emph{page}.%
2364 }%
2365 \entry{\OptionVName{floattype}{number}}{%
2366 Each floating environment has a \PName{number}. Floating environments
2367 where only different bits are set can be moved past each other. The
2368 floating environments \Environment{figure} and \Environment{table} usually
2369 have the types 1 and 2, so they can move past each other. The numerical
2370 float type can be between 1 and 31. If common bits are set, the float
2371 types cannot be reordred. If no float type is given, the greatest possible
2372 one-bit type, 16, will be used.%
2373 }%
2374 \entry{\Option{forcenames}}{%
2375 If set, the names will be defined even if they were already defined
2376 before.%
2377 }%
2378 \entry{\OptionVName{hang}{length}}{%
2379 \ChangedAt{v3.20}{\Package{tocbasic}}%
2380 \ChangedAt{v3.21}{\Package{tocbasic}}%
2381 This option has been deprecated since \KOMAScript~3.20. Instead, the
2382 amount of the hanging indent of entries to the content list\index{content
2383 list>entry} depends on attributes of the TOC-entry style given by the
2384 \Option{tocentrystyle} option. The \KOMAScript{} styles provide the
2385 \PValue{numwidth} attribute. If the style used has such an attribute,
2386 \Macro{DeclareNewTOC} will initialise it with a default of 1.5\Unit{em}.
2387 You can easily change the \PName{value} using
2388 \OptionVName{tocentrynumwidth}{value}. The \KOMAScript{} classes, for
2389 example, use \OptionValue{tocentrynumwidth}{2.3em}.%
2390 }%
2391 \entry{\OptionVName{indent}{length}}{%
2392 \ChangedAt{v3.20}{\Package{tocbasic}}%
2393 \ChangedAt{v3.21}{\Package{tocbasic}}%
2394 This option has been deprecated since \KOMAScript~3.20. Instead, the
2395 amount that entries to the content list\index{content list>entry} are
2396 indented depends on attributes of the TOC-entry style given by the
2397 \Option{tocentrystyle} option. The \KOMAScript{} styles provide the
2398 \PValue{indent} attribute. If the style used has such an attribute,
2399 \Macro{DeclareNewTOC} will initialise it with a default of 1\Unit{em}. You
2400 can easily change the \PName{value} using
2401 \OptionVName{tocentryindent}{value}. The \KOMAScript{} classes for example
2402 use \OptionValue{tocentrynumwidth}{1.5em}.%
2403 }%
2404 \entry{\OptionVName{level}{number}}{%
2405 \ChangedAt{v3.20}{\Package{tocbasic}}%
2406 \ChangedAt{v3.21}{\Package{tocbasic}}%
2407 This option has been deprecated since \KOMAScript~3.20. Instead, the level
2408 of the entries to the content list\index{content list>entry} depends on
2409 attributes of the TOC-entry style given by the \Option{tocentrystyle}
2410 option. Nevertheless, all styles have the \PValue{level} attrobite, and
2411 \Macro{DeclareNewTOC} initialises it with a default value of 1. You can
2412 easily change the \PName{value} using \OptionVName{tocentrylevel}{value}.%
2413 }%
2414 \entry{\OptionVName{listname}{title}}{%
2415 Each content list has a heading, or title, that you can specify with this
2416 option. If the option is not specified, the title will be ``List of
2417 \PName{entry type}'' (see the \Option{types} option), with the first
2418 character of the \PName{entry type} changed to upper case. It also defines
2419 the \Macro{list\PName{entry type}name} macro with this value, which you
2420 can change at any time. This macro, however, is only defined if it is not
2421 already defined or if the \Option{forcenames} option is also set.%
2422 }%
2423 \entry{\OptionVName{name}{entry name}}{%
2424 Both the optional prefix for entries in the content list and the labels in
2425 floating or non-floating environments (see the \Option{float} and
2426 \Option{nonfloat} options) require an \PName{entry name} for an entry to
2427 the content list. If no \PName{entry name} is given, the value of the
2428 \PValue{type} (see the \Option{type} option) with the first character
2429 changed to upper case will be used. It also defines a \Macro{\PName{entry
2430 type}name} macro with this value, which you can change at any
2431 time. This macro, however, is only defined if it is not already defined or
2432 if the \Option{forcenames} option is also set.%
2433 }%
2434 \entry{\Option{nonfloat}}{%
2435 If set, defines not only a content list but also a non-floating
2436 environment, \Environment{\PName{entry type}-} (see the \Option{type}
2437 option), which can be used similarly to a floating environment, but which
2438 does not move from the place where it is used.%
2439 }%
2440 \entry{\OptionVName{owner}{string}}{%
2441 Every new content list has an owner in \Package{tocbasic} (see
2442 \autoref{sec:\LabelBase.basics}). You can specify this here. If no owner is
2443 specified, the owner ``\PValue{float}'' is used. The \KOMAScript{} classes
2444 use this owner for the list of figures and the list of tables.%
2445 }%
2446 \entry{\OptionVName{setup}{list of attributes}}{%
2447 \ChangedAt{v3.25}{\Package{tocbasic}}%
2448 The \PName{list of attributes} is set with
2449 \DescRef{\LabelBase.cmd.setuptoc}. Note that to specify multiple
2450 attributes in a comma-separated list, you must put this list between
2451 braces.%
2452 }%
2453 \entry{\OptionVName{tocentrystyle}{TOC-entry style}}{%
2454 \ChangedAt{v3.20}{\Package{tocbasic}}%
2455 \PName{TOC-entry style} specifies the style that should be used for all
2456 entries to the content list corresponding to the \PName{extension}. The
2457 name of the entry level is given by the \Option{type} option. In addition
2458 to the options in this table, all attributes of the \PName{TOC-entry
2459 style} can be used as options. To do so, you have to prefix the name of
2460 such an attribute with \PValue{tocentry}. For example, you can change the
2461 numerical level of the entries using the \Option{tocentrylevel} option.
2462 For more information about the styles and their attributes see
2463 \autoref{sec:\LabelBase.tocstyle}, starting on
2464 \autopageref{sec:\LabelBase.tocstyle}.%
2465 }%
2466 \entry{\OptionVName{tocentry\PName{style-option}}{value}}{%
2467 \ChangedAt{v3.20}{\Package{tocbasic}}%
2468 Additional options depending on the \PName{TOC-entry style} given by
2469 \Option{tocentrystyle}. See \autoref{sec:\LabelBase.tocstyle},
2470 \autopageref{sec:\LabelBase.tocstyle} for additional information about
2471 TOC-entry styles. See \autoref{tab:\LabelBase.tocstyle.attributes},
2472 \autopageref{tab:\LabelBase.tocstyle.attributes} for information about the
2473 attributes of the predefined TOC-entry styles of package
2474 \Package{tocbasic} that can be used as \PName{style-option}.%
2475 }%
2476 \entry{\OptionVName{type}{entry type}}{%
2477 Sets the type of the newly declared content list. The \PName{entry type}
2478 is also used as a base name for various macros and possibly environments
2479 and counters. It should therefore consist only of letters. If this option
2480 is not used, the file \PName{extension} from the mandatory argument will
2481 be used as the \PName{entry type}.%
2482 }%
2483 \entry{\OptionVName{types}{string}}{%
2484 In several places, the plural form of the \PName{entry type} is required.
2485 If no plural is given, the value of the \PValue{entry type} with an ``s''
2486 appended will be used.%
2487 }%
2488 \entry{\OptionVName{unset}{list of attributes}}{%
2489 \ChangedAt{v3.25}{\Package{tocbasic}}%
2490 The \PName{list of attributes} is unset with
2491 \DescRef{\LabelBase.cmd.unsettoc}. Note that to specify a comma-separated
2492 list of attributes, you must put this list between braces.%
2493 }%
2494 \end{desclist}
2495
2496 \begin{Example}
2497 Using \Macro{DeclareNewTOC} significantly shortens the example from
2498 \autoref{sec:\LabelBase.example}:
2499 \begin{lstcode}
2500 \DeclareNewTOC[%
2501 type=remarkbox,%
2502 types=remarkboxes,%
2503 float,% define a floating environment
2504 floattype=4,%
2505 name=Remark,%
2506 listname={List of Remarks}%
2507 ]{lor}
2508 \setuptoc{lor}{chapteratlist}
2509 \end{lstcode}
2510 In addition to the \Environment{remarkbox} and \Environment{remarkbox*}
2511 environments, this also defines the \Counter{remarkbox} counter; the
2512 commands \Macro{theremarkbox}, \Macro{remarkboxname}, and
2513 \Macro{remarkboxformat} that are used for captions; the commands
2514 \Macro{listremarkboxnames} and \Macro{listofremarkboxes} that are used in
2515 the list of remarks; and some internal commands that depend on the file name
2516 extension \File{lor}. If the package should use a default for the floating
2517 type, the \Option{floattype} option can be omitted. If the \Option{nonfloat}
2518 option is specified, a non-floating environment, \Environment{remarkbox-},
2519 will also be defined, inside which you can use
2520 \DescRef{\LabelBase.cmd.caption}\IndexCmd{caption}.
2521 \hyperref[tab:\LabelBase.comparison]{Figure~\ref*{tab:\LabelBase.comparison}}
2522 compares the commands, counters, and environments of the example
2523 \Environment{remarkbox} environment to the commands, counters, and
2524 environments of figures.%
2525 \begin{table}
2526 \centering
2527 \caption{Comparing the example \Environment{remarkbox} environment
2528 with the \Environment{figure} environment}
2529 \labelofbase[tab]{comparison}
2530 \begin{tabularx}{\textwidth}{ll>{\raggedright}p{6em}X}
2531 \toprule
2532 \Environment{remarkbox} & \Environment{figure}
2533 & options of \Macro{DeclareNewTOC} & short description \\[1ex]
2534 \midrule
2535 \Environment{remarkbox} & \Environment{figure}
2536 & \Option{type}, \Option{float}
2537 & floating environments of the respective types\\[1ex]
2538 \Environment{remarkbox*} & \Environment{figure*}
2539 & \Option{type}, \Option{float}
2540 & columns spanning floating environments of the respective types\\[1ex]
2541 \Counter{remarkbox} & \Counter{figure}
2542 & \Option{type}, \Option{float}
2543 & counter used by \DescRef{\LabelBase.cmd.caption}\\[1ex]
2544 \Macro{theremarkbox} & \Macro{thefigure}
2545 & \Option{type}, \Option{float}
2546 & output command to the respective counters\\[1ex]
2547 \Macro{remarkboxformat} & \DescRef{maincls.cmd.figureformat}
2548 & \Option{type}, \Option{float}
2549 & formatting command to the respective counters used by
2550 \DescRef{\LabelBase.cmd.caption}\\[1ex]
2551 \Macro{remarkboxname} & \Macro{figurename}
2552 & \Option{type}, \Option{float}, \Option{name}
2553 & names used in the label of \DescRef{\LabelBase.cmd.caption}\\[1ex]
2554 \Macro{listofremarkboxes} & \DescRef{maincls.cmd.listoffigures}
2555 & \Option{types}, \Option{float}
2556 & command to show the list of the respective environments\\[1ex]
2557 \Macro{listremarboxname} & \Macro{listfigurename}
2558 & \Option{type}, \Option{float}, \Option{listname}
2559 & heading text of the respective list \\[1ex]
2560 \Macro{fps@remarkbox} & \Macro{fps@figure}
2561 & \Option{type}, \Option{float}, \Option{floattype}
2562 & numeric float type for order perpetuation\\[1ex]
2563 \File{lor} & \File{lof}
2564 &
2565 & file name extension of the TOC file of the respective list \\
2566 \bottomrule
2567 \end{tabularx}
2568 \end{table}
2569
2570 And here is a possible use of the example environment:
2571 \begin{lstcode}
2572 \begin{remarkbox}
2573 \centering
2574 The same thing should always be typeset in the same way
2575 and with the same appearance.
2576 \caption{First Law of Typography}
2577 \label{rem:typo1}
2578 \end{remarkbox}
2579 \end{lstcode}
2580 A snippet of a sample page with this environment might look like this:
2581 \begin{center}\footnotesize
2582 \begin{tabular}
2583 {|!{\hspace{.1\linewidth}}p{.55\linewidth}!{\hspace{.1\linewidth}}|}
2584 \\
2585 \centering
2586 The same thing should always be typeset in the same way
2587 and with the same appearance.\\[\abovecaptionskip]
2588 {%
2589 \usekomafont{caption}\footnotesize{\usekomafont{captionlabel}%
2590 Remark 1: }First Law of Typography
2591 }\\
2592 \end{tabular}%
2593 \end{center}%
2594 \end{Example}
2595
2596 Users of old versions of package \Package{hyperref} should always use the
2597 \Option{listname} option. Otherwise they may get an error message because
2598 \Package{hyperref} usually has a problem with the
2599 \Macro{MakeUppercase}\IndexCmd{MakeUppercase} command that is needed to
2600 convert the first letter of \Option{types} to upper case. Better is of course
2601 to use an up-to-date \Package{hyperref} with an up-to-date \LaTeX.%
2602 \EndIndexGroup
2603
2604 \section{Captions of (Float) Environments}
2605 \seclabel{caption}
2606
2607 As\ChangedAt{v3.46}{\Package{tocbasic}} explained in the previous section, the
2608 \DescRef{\LabelBase.cmd.DeclareNewTOC} command can also be used to define new
2609 floating and non-floating environments, whose titles set with
2610 \DescRef{\LabelBase.cmd.caption} are automatically entered in the
2611 corresponding directories. tocbasic also offers some extensions for this.
2612
2613 Please note that all the features described in this section require a
2614 \LaTeX{}\textnote{\LaTeX{} 2022/06/01} version from 2022/06/01. These features
2615 are therefore not available with older LaTeX versions!
2616
2617 \textnote{\Package{caption}}\IndexPackage{caption}%
2618 At this point it should be noted that the features documented in this section
2619 currently also work when using the caption package. This was tested with
2620 version 2023/08/05 v3.6o of the caption package. In general, however, it is
2621 not recommended to rely on any of the features described in this section when
2622 using any package that provides or modifies \DescRef{\LabelBase.cmd.caption}
2623 or \DescRef{\LabelBase.cmd.captionof}, or when using classes that provide
2624 \DescRef{\LabelBase.cmd.caption} in a way that is incompatible with the
2625 standard classes or the KOMA script classes. When using the aforementioned
2626 caption package, for example, the features documented in its manual should be
2627 used instead. See \cite{package:caption.engl}.
2628
2629 \begin{Declaration}
2630 \OptionValue{captionposition}{top}
2631 \OptionValue{captionposition}{bottom}
2632 \OptionVName{captionabove}{Boolean value}
2633 \OptionVName{captionbelow}{Boolean value}
2634 \end{Declaration}
2635 By default, the distances above and below the captions are selected so that
2636 they fit for captions below the respective object, for example below an image
2637 or a table. This corresponds to the setting
2638 \OptionValue{captionposition}{bottom} or the synonymous settings
2639 \OptionValue{captionabove}{false} or \OptionValue{captionbelow}{true}. The
2640 settings \OptionValue{captionposition}{top}, \OptionValue{captionabove}{true}
2641 or \OptionValue{captionbelow}{false} can also be used to automatically swap
2642 the spacing so that it fits for titles above the object. The selection is made
2643 within the call to \DescRef{\LabelBase.cmd.caption} or
2644 \DescRef{\LabelBase.cmd.captionof} provided that the
2645 \DescRef{\LabelBase.cmd.caption} patch has been activated. See option
2646 enablepatch in \autoref{sec:\LabelBase.standardclasses} from
2647 \autopageref{sec:\LabelBase.standardclasses}.
2648
2649 Please note that these options are not \KOMAScript{} options. They can
2650 therefore not be set with \DescRef{maincls.cmd.KOMAoptions} or
2651 \DescRef{maincls.cmd.KOMAoption}. Instead, when loading \Package{tocbasic},
2652 they are available as an optional argument of \Macro{usepackage} - or
2653 \Macro{RequirePackage} for class and package authors. To compensate for this,
2654 it is possible to load the package multiple times with different options. They
2655 can also be set at any time within the document using
2656 \verb|\SetKeys[tocbasic]|\Parameter{options}.
2657
2658 Only \PValue{true}%
2659 \IndexOption[indexmain]{captionabove~=\KValue{true}}%
2660 \IndexOption[indexmain]{captionbelow~=\KValue{true}} or \PValue{false}%
2661 \IndexOption[indexmain]{captionabove~=\KValue{false}}%
2662 \IndexOption[indexmain]{captionbelow~=\KValue{false}} are permitted as
2663 \PName{Boolean value}s. The use of \Option{captionabove} or
2664 \Option{captionbelow} without a value corresponds to
2665 \OptionValue{captionabove}{true} or \OptionValue{captionbelow}{true}.
2666
2667 As a special feature, \Package{tocbasic} also defines corresponding options
2668 with the prefix of the name of the environment for all environments defined
2669 with the help of \DescRef{\LabelBase.cmd.DeclareNewTOC}, for example the
2670 options \OptionValue{figurecaptionposition}{value}%
2671 \IndexOption[indexmain]{figurecaptionposition~=\KValue{top}}%
2672 \LabelOptionValue{figurecaptionposition}{top}%
2673 \IndexOption[indexmain]{figurecaptionposition~=\KValue{bottom}}%
2674 \LabelOptionValue{figurecaptionposition}{bottom},
2675 \OptionVName{figurecaptionabove}{Boolean value}%
2676 \IndexOption[indexmain]{figurecaptionabove~=\PName{Boolean value}},
2677 \OptionVName{figurecaptionbelow}{Boolean value}%
2678 \IndexOption[indexmain]{figurecaptionbelow~=\PName{Boolean value}},
2679 \OptionValue{tablecaptionposition}{value}%
2680 \IndexOption[indexmain]{tablecaptionposition~=\KValue{top}}%
2681 \LabelOptionValue{tablecaptionposition}{top}%
2682 \IndexOption[indexmain]{tablecaptionposition~=\KValue{bottom}}%
2683 \LabelOptionValue{tablecaptionposition}{bottom},
2684 \OptionVName{tablecaptionabove}{value}%
2685 \LabelOption{tablecaptionabove}%
2686 \IndexOption[indexmain]{tablecaptionabove~=\PName{Boolean value}}, and
2687 \OptionVName{tablecaptionbelow}{value}%
2688 \IndexOption[indexmain]{tablecaptionbelow~=\PName{Boolean value}} for the
2689 environments \Environment{figure} and \Environment{table} defined in the
2690 \KOMAScript{} classes. In addition to the values specified above for
2691 \Option{captionposition}, \Option{captionabove} and \Option{captionbelow}, the
2692 \PName{value} \PValue{default} is also permitted. This deactivates the
2693 explicit settings for the respective environment so that the settings of the
2694 general option \Option{captionposition}, \Option{captionabove} or
2695 \Option{captionbelow} are used again.
2696 \EndIndexGroup
2697
2698 \begin{Declaration}
2699 \Macro{caption}\OParameter{entry}\Parameter{title}
2700 \Macro{captionbelow}\OParameter{entry}\Parameter{title}
2701 \Macro{captionabove}\OParameter{entry}\Parameter{title}
2702 \end{Declaration}%
2703 As explained in the \DescRef{\LabelBase.option.captionposition} options,
2704 floating environments and also the non-floating environments that can be
2705 defined with \DescRef{\LabelBase.cmd.DeclareNewTOC} are normally provided with
2706 a caption using \Macro{caption}. Using \Package{tocbasic} and the option
2707 mentioned, you can set whether the spacing for captions should be selected
2708 above or below the object. However, as this only works if \Macro{caption} is
2709 redefined appropriately by \Package{tocbasic}, there are also the commands
2710 \Macro{captionbelow} and \Macro{captionabove}. These usually also work if the
2711 corresponding patch has not been activated, i.e. \Macro{caption} does not
2712 react to the options \Option{captionposition}, \Option{captionabove} and
2713 \Option{captionbelow}.
2714 %
2715 \begin{Example}
2716 Instead of using captions below a table, you want to place your
2717 captions above it\Index{table>caption}, because you have tables
2718 which span more then one page. In the standard classes you could
2719 only write:
2720 \begin{lstcode}
2721 \begin{table}
2722 \caption{This is an example table}
2723 \begin{tabular}{llll}
2724 This & is & an & example.\\\hline
2725 This & is & an & example.\\
2726 This & is & an & example.
2727 \end{tabular}
2728 \end{table}
2729 \end{lstcode}
2730 Then you would get this unsatisfying result:
2731 \begin{ShowOutput}\centering
2732 {\usekomafont{caption}{\usekomafont{captionlabel}\tablename~30.2:}
2733 This is an example table.}\\
2734 \begin{tabular}{llll}
2735 This & is & an & example.\\\hline
2736 This & is & an & example.\\
2737 This & is & an & example.
2738 \end{tabular}
2739 \end{ShowOutput}
2740 Using {\KOMAScript} you write instead:
2741 \begin{lstcode}
2742 \begin{table}
2743 \captionabove{This is just an example table}
2744 \begin{tabular}{llll}
2745 This & is & an & example.\\\hline
2746 This & is & an & example.\\
2747 This & is & an & example.
2748 \end{tabular}
2749 \end{table}
2750 \end{lstcode}
2751 Then you get:
2752 \begin{ShowOutput}\centering
2753 {\usekomafont{caption}{\usekomafont{captionlabel}\tablename~30.2:}
2754 This is just an example table}\\\vskip\abovecaptionskip
2755 \begin{tabular}{llll}
2756 This & is & an & example.\\\hline
2757 This & is & an & example.\\
2758 This & is & an & example.
2759 \end{tabular}
2760 \end{ShowOutput}
2761 Since you want all your tables typeset with captions above, you could of
2762 course use:
2763 \begin{lstcode}
2764 \usepackage[enablepatch=caption,tablecaptionabove]{tocbasic}
2765 \end{lstcode}
2766 Then you can use \Macro{caption} inside the \Environment{table} environment
2767 to get the same result as with \Macro{captionabove}. The use of
2768 \OptionValueRef{\LabelBase}{enablepatch}{caption} is important for the
2769 correct functioning of the second option
2770 \DescRef{\LabelBase.option.tablecaptionabove}. The \KOMAScript{} classes
2771 therefore already load \Package{tocbasic} with this option by default.%
2772 \end{Example}
2773 \EndIndexGroup
2774 \ExampleEndFix
2775
2776 \begin{Declaration}
2777 \Macro{captionof}\Parameter{float type}\OParameter{entry}%
2778 \Parameter{title}%
2779 \Macro{captionbelowof}\Parameter{float type}\OParameter{entry}%
2780 \Parameter{title}%
2781 \Macro{captionaboveof}\Parameter{float type}\OParameter{entry}%
2782 \Parameter{title}
2783 \end{Declaration}%
2784 Like the \Package{caption}\IndexPackage{caption} and
2785 \Package{capt-of}\IndexPackage{capt-of} packages, the \Package{tocbasic}
2786 package offers the \Macro{captionof} command, with which you can put a caption
2787 for a floating environment, together with an entry in the corresponding
2788 environment list, outside of the floating environment or even in a different
2789 floating environment. Unlike \DescRef{\LabelBase.cmd.caption}, the type of
2790 floating environment must be specified as the first parameter.
2791
2792 In addition, \Package{tocbasic} also provides the commands
2793 \Macro{captionaboveof}. These are like \DescRef{\LabelBase.cmd.captionabove}
2794 and \DescRef{\LabelBase.cmd.captionbelow} but with the additional features and
2795 parameter of \Macro{captionof}.
2796
2797 Of course takes into account the \PValue{heading} and \PValue{signature}
2798 settings of options \DescRef{\LabelBase.option.captionposition},
2799 \DescRef{\LabelBase.option.captionabove} or
2800 \DescRef{\LabelBase.option.captionbelow} and also the corresponding individual
2801 options of the environments defined using
2802 \DescRef{\LabelBase.cmd.DeclareNewTOC} to setup the distance for captions
2803 above or below the object.
2804 \begin{Example}
2805 Suppose you want to create a floating object with a table and a figure next
2806 to each other. Since there are no mixed floating environments, you primarily
2807 use a \Environment{figure} environment:
2808 \begin{lstcode}
2809 \begin{figure}
2810 \begin{minipage}{.5\linewidth}
2811 \centering
2812 \rule{4cm}{5cm}
2813 \caption{A rectangle}\label{fig:rechteck}
2814 \end{minipage}%
2815 \begin{minipage}{.5\linewidth}
2816 \centering
2817 \captionaboveof{table}
2818 [Measure of the rectangle in
2819 figure~\ref{fig:rechteck}]%
2820 {Rectangle measure}
2821 \label{tab:rechteck}
2822 \begin{tabular}{ll}
2823 Width: & 4\,cm\\
2824 Height: & 5\,cm
2825 \end{tabular}
2826 \end{minipage}
2827 \end{figure}
2828 \end{lstcode}
2829 Two \Environment{minipage} environments were used to place the figure
2830 and the table side by side. The\textnote{Attention!} percent sign after the
2831 end of the first \Environment{minipage} is important. Without it, an
2832 additional space would appear between the \Environment{minipage}
2833 environments.
2834
2835 The figure caption was created with \DescRef{\LabelBase.cmd.caption}. The
2836 table caption was created with \Macro{captionaboveof} with \PValue{table} as
2837 the first argument. Because of this, \Package{tocbasic} knows that this is a
2838 table caption even though it is inside the \Environment{figure} environment.
2839
2840 The optional argument of \Macro{captionaboveof} creates an entry in the
2841 list of tables. Without the optional argument, the caption specified in the
2842 final mandatory argument would have been used for the list of tables too.
2843 Although this caption text is sufficient for the environment itself, it
2844 would not be very meaningful in the list of tables. Therefore, a different
2845 title is used for the list of tables using the optional argument.
2846 \autoref{fig:\LabelBase.captionaboveof} shows the result of the example code.%
2847 \begin{figure}
2848 % \centering
2849 % \caption
2850 \KOMAoptions{captions=bottombeside}%
2851 \setcapindent{0pt}%
2852 \begin{captionbeside}
2853 [{Example: Using \Macro{captionaboveof} inside another floating
2854 environment}]
2855 {Example: Using \Macro{captionaboveof} inside another floating
2856 environment\label{fig:\LabelBase.captionaboveof}}
2857 [l]
2858 \begin{minipage}[b]{.66\linewidth}%
2859 \raisebox{\depth}{\fbox{\KOMAoptions{captions=oneline}%
2860 \begin{minipage}{.5\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}
2861 \centering
2862 \rule{4cm}{5cm}
2863 \caption[Example: A rectangle]{A rectangle}\label{fig:\LabelBase.rechteck}
2864 \end{minipage}%
2865 \begin{minipage}{.5\dimexpr\linewidth-2\fboxsep-2\fboxrule\relax}
2866 \centering
2867 \captionaboveof{table}[Example: Measure of the rectangle in
2868 figure~\ref{fig:\LabelBase.rechteck}]{Rectangle measure}
2869 \label{tab:\LabelBase.rechteck}
2870 \begin{tabular}{ll}
2871 Width: & 4\,cm\\
2872 Height: & 5\,cm
2873 \end{tabular}
2874 \end{minipage}}}%
2875 \end{minipage}%
2876 \end{captionbeside}%
2877 \end{figure}%
2878 \end{Example}%
2879 You can produce a non-floating table with a caption in the same way as the
2880 table inside a figure environment in the example
2881 above. Thereby \Package{tocbasic} also tries to prevent a page break between
2882 the heading and the table. However, this cannot be ensured in all
2883 cases. Therefore, a \Environment{minipage} environment should also be used to
2884 avoid page breaks between the caption and the table. In addition, you should
2885 embed the \Environment{minipage} environment in a \Environment{flushleft}
2886 environment both to achieve a pleasing separation between the surrounding text
2887 and to avoid the paragraph indentation of the \Environment{minipage}
2888 environment. Of course, it is easier to use the environment
2889 \DescRef{maincls.env.table-}\IndexEnv{table-} directly.%
2890 \EndIndexGroup
2891
2892
2893 \section{Using \Package{tocbasic} with Third-Party Classes}
2894 \seclabel{standardclasses}
2895
2896 The \Package{tocbasic} package can be utilized with classes beyond the
2897 \KOMAScript{} ones. Starting from version
2898 3.42\ChangedAt{v3.42}{\Package{tocbasic}}, the package also provides
2899 additional functionality to ensure seamless integration with other
2900 classes. However, note that these new features have been thoroughly tested
2901 only with standard classes and require invasive adjustments to foreign
2902 classes. For this reason, none of the features are active in the default
2903 setting. Instead, they must be activated through options\,---\,in one
2904 instance, alternatively by command\,---\,to be enabled.
2905
2906 These new options \emph{cannot} be set with \DescRef{maincls.cmd.KOMAoptions}
2907 or \DescRef{maincls.cmd.KOMAoption}. Instead, when loading \Package{tocbasic}
2908 they are optional arguments of \Macro{usepackage} --
2909 resp. \Macro{RequirePackage} for class and package authors. To compensate, it
2910 is possible to load the package multiple times with different
2911 options. \textnote{Attention!}However, the options require a \LaTeX{} version
2912 2022/06/01\textnote{\LaTeX{} 2022/06/01} onwards, so with older \LaTeX{}
2913 versions the new features are \emph{not} available.
2914
2915 \begin{Declaration}
2916 \OptionVName{enablepatch}{list of patches}
2917 \OptionVName{disablepatch}{list of patches}
2918 \end{Declaration}
2919 Option\ChangedAt{v3.42}{\Package{tocbasic}} enables the patches listed, while
2920 \Option{disablepatch} disables them. In both cases, the \PName{list of
2921 patches} is a comma-separated list of individual patches enclosed in single
2922 curly braces. A list of available patches can be found in
2923 \autoref{tab:\LabelBase.patches}. Both options can be used several times. For
2924 example:
2925 \begin{lstcode}
2926 \usepackage[enablepatch=chapter,enablepatch=listoffigures]{tocbasic}
2927 \end{lstcode}
2928 is equivalent to
2929 \begin{lstcode}
2930 \usepackage[enablepatch={chapter,listoffigure}]{tocbasic}
2931 \end{lstcode}
2932 Note that in the second case, exactly one pair of curly braces must be set for
2933 the value. Forgetting these brackets will inevitably lead to an error message!
2934
2935 The patches themselves are executed at \verb|\begin{document}|. Therefore
2936 \begin{lstcode}
2937 \usepackage[enablepatch=chapter]{tocbasic}
2938 \usepackage[enablepatch=listoffigures]{tocbasic}
2939 \end{lstcode}
2940 is also possible and would lead to the same result.
2941
2942 \begin{table}
2943 \centering
2944 \caption{with \Package{tocbasic} available patches}
2945 \labelofbase[tab]{patches}
2946 \begin{desctabular}
2947 \pventry{all}{%
2948 \IndexOption{enablepatch~=all}\IndexOption{disablepatch~=all}%
2949 When activated, all other patches are executed regardless of the
2950 individual setting. If a \KOMAScript{} class is loaded, this does not
2951 apply to \PValue{chapter}.%
2952 }%
2953 \pventry{caption}{%
2954 \ChangedAt{v3.46}{\Package{tocbasic}}%
2955 \IndexOption{enablepatch~=caption}\IndexOption{disablepatch~=caption}%
2956 \IndexCmd{caption}\IndexCmd{captionof}%
2957 The commands \DescRef{\LabelBase.cmd.caption} and
2958 \DescRef{\LabelBase.cmd.captionof} are redefined so that they respect
2959 the options \DescRef{\LabelBase.option.captionposition},
2960 \DescRef{\LabelBase.option.captionabove},
2961 \DescRef{\LabelBase.option.captionbelow} or the corresponding options
2962 depending on the type or environment.%
2963 }%
2964 \pventry{chapter}{%
2965 \IndexOption{enablepatch~=chapter}\IndexOption{disablepatch~=chapter}%
2966 \IndexCmd{chapter}%
2967 Via a generic hook, the \Macro{@makechapterhead} command is extended to
2968 insert a vertical spacing in all lists of the category or owner
2969 \PValue{float} in case of a new chapter similar to the list of figures
2970 and the list of tables. Non-numbered chapters created with
2971 \Macro{chapter*} or \Macro{@makeschapterhead} are not impacted by this
2972 modification.%
2973 }%
2974 \pventry{listoffigures}{%
2975 \IndexOption{enablepatch~=listoffigures}%
2976 \IndexOption{disablepatch~=listoffigures}%
2977 The \Macro{listoffigures}\IndexCmd{listoffigures} command is now
2978 redefined to be implemented by \Package{tocbasic}, allowing for all the
2979 features provided by \Package{tocbasic} to be accessed through
2980 \DescRef{\LabelBase.cmd.setuptoc}. These features are documented in
2981 \autoref{sec:\LabelBase.toc} on \DescPageRef{\LabelBase.cmd.setuptoc}.%
2982 }%
2983 \pventry{listoftables}{%
2984 \IndexOption{enablepatch~=listoftables}%
2985 \IndexOption{disablepatch~=listoftables}%
2986 The \Macro{listoftables}\IndexCmd{listoftables} command is now redefined
2987 to be implemented by \Package{tocbasic}, allowing for all the features
2988 provided by \Package{tocbasic} to be accessed through
2989 \DescRef{\LabelBase.cmd.setuptoc}. These features are documented in
2990 \autoref{sec:\LabelBase.toc} on \DescPageRef{\LabelBase.cmd.setuptoc}.%
2991 }%
2992 \pventry{starttoc}{%
2993 \IndexOption{enablepatch~=starttoc}%
2994 \IndexOption{disablepatch~=starttoc}%
2995 \IndexCmd{@starttoc}%
2996 The \DescPageRef{\LabelBase.cmd.tocbasicautomode} command, which is
2997 explained in \autoref{sec:\LabelBase.basics},
2998 \DescPageRef{\LabelBase.cmd.tocbasicautomode}, is invoked.%
2999 }%
3000 \end{desctabular}
3001 \end{table}
3002
3003 A first noteworthy feature is
3004 \OptionValue{enablepatch}{all}\important{\OptionValue{enablepatch}{all}}%
3005 \IndexOption{enablepatch~=all}. While not a true patch, this setting
3006 guarantees that all patches are executed, irrespective of their individual
3007 settings. However, this can be overridden by
3008 \OptionValue{disablepatch}{all}\important{\OptionValue{disablepatch}{all}}%
3009 \IndexOption{disablepatch~=all}. \textnote{Attention!}With
3010 \OptionValue{disablepatch}{all} not all patches are deactivated, but rather
3011 the individual settings for each patch are respected.
3012
3013 A second noteworthy feature is \OptionValue{enablepatch}{caption}%
3014 \important{\OptionValue{enabelpatch=caption}}%
3015 \IndexOption{enablepatch~caption}. As this patch is absolutely necessary for
3016 the correct function of the options from \autoref{sec:\LabelBase.caption},
3017 \DescPageRef{\LabelBase.option.captionposition} and the \KOMAScript{} options
3018 \OptionValueRef{maincls}{captions}{heading},
3019 \OptionValueRef{maincls}{captions}{signature},
3020 \OptionValueRef{maincls}{captions}{figureheading},
3021 \OptionValueRef{maincls}{captions}{figuresignature},
3022 \OptionValueRef{maincls}{captions}{tableheading} and
3023 \OptionValueRef{maincls}{captions}{tablesignature} based on them, it is
3024 automatically activated by the \KOMAScript{} classes. Without activation, the
3025 options mentioned have no defined effect.
3026
3027 A third noteworthy feature is
3028 \OptionValue{enablepatch}{chapter}%
3029 \important{\OptionValue{enablepatch}{chapter}}%
3030 \IndexOption{enablepatch~=chapter}. Its usage may result in damage, hence a
3031 notification is displayed in the terminal output and add to the \File{log}
3032 file. Utilizing the patch with a \KOMAScript{} class can lead to actual
3033 damage, and therefore is triggering a warning.
3034
3035 Since the \PValue{chapter} patch has no useful function with the \KOMAScript{}
3036 classes, it will not be employed by
3037 \OptionValue{enablepatch}{all}\important{\OptionValue{disablepatch}{all}}%
3038 \IndexOption{disablepatch~=all} when using a \KOMAScript{} class to prevent
3039 potential harm. Hence, when using a \KOMAScript{} class,
3040 \OptionValue{enablepatch}{chapter} would be needed explicitly to enable this
3041 patch. But you usually should not enable it in this case.
3042
3043 \begin{Example}
3044 The contrast between employing \Package{tocbasic} with and without patching
3045 is readily apparent when examining the \Environment{remarkbox} example from
3046 \autoref{sec:\LabelBase.declarenewtoc} using the class
3047 \Class{book}. Initially, let us load \Package{tocbasic} sans options:
3048 \lstinputcode[xleftmargin=2em]{book-remarkbox-nopatch-en.tex}%
3049
3050 As you can see from the upper row of \autoref{fig:remarkbox}, the table of
3051 figures is not included in the table of contents. The statement
3052 \verb|\setuptoc{lof}{totoc}| has no effect. On the other hand, the list of
3053 remarks appears in the table of contents as a result of
3054 \verb|\setuptoc{lor}{totoc}|. Although a vertical space appears in the list
3055 of figures itself between the figures of chapter~1 and chapter~2, it does
3056 not appear in the list of remarks.
3057
3058 \begin{figure}
3059 \centering
3060 \frame{\includegraphics[width=.3\textwidth,page=1]{book-remarkbox-nopatch-en.pdf}}
3061 \frame{\includegraphics[width=.3\textwidth,page=3]{book-remarkbox-nopatch-en.pdf}}
3062 \frame{\includegraphics[width=.3\textwidth,page=5]{book-remarkbox-nopatch-en.pdf}}\\
3063 \frame{\includegraphics[width=.3\textwidth,page=1]{book-remarkbox-patch-en.pdf}}
3064 \frame{\includegraphics[width=.3\textwidth,page=3]{book-remarkbox-patch-en.pdf}}
3065 \frame{\includegraphics[width=.3\textwidth,page=5]{book-remarkbox-patch-en.pdf}}
3066 \caption[{Example for \Package{tocbasic} without and with patch when using
3067 class \Class{book}}]{Example for \Package{tocbasic} without (above) and
3068 with (below) patch when using class \Class{book}}
3069 \label{fig:remarkbox}
3070 \end{figure}
3071
3072 The second row of \autoref{fig:remarkbox} demonstrates the proper listing
3073 format: including entries for both the list of figures and the list of
3074 remarks in the table of contents, as well as vertical spacing when changing
3075 chapters in both lists. The code has been updated with the
3076 \PValue{listoffigures} patch, replacing the entry for the list of
3077 figures. This guarantees that \verb|\setuptoc{lof}{totoc}| will be correctly
3078 applied. At the same time, the \PValue{chapter} patch ensures that the
3079 offset is inserted into the list of remarks as intended.%
3080 \lstinputcode[xleftmargin=2em]{book-remarkbox-patch-en.tex}%
3081 Yes, indeed, the only difference of both examples is loading
3082 the package \Package{tocbasic} without or with option
3083 \OptionValue{enablepatch}{\{chapter,listoffigures\}}.%
3084 \end{Example}%
3085 \EndIndexGroup
3086 \ExampleEndFix
3087
3088 \section{Deprecated Commands}
3089 \seclabel{obsolete}
3090
3091 Earlier versions of \Package{tocbasic} had commands that were renamed in
3092 response to feedback from members of the \LaTeX{} Project Team. These deprecated
3093 commands should not be used anymore.
3094
3095 \LoadNonFree{tocbasic}{0}%
3096 %
3097 \EndIndexGroup
3098 %
3099 \endinput
3100
3101 %%% Local Variables:
3102 %%% mode: latex
3103 %%% TeX-master: "scrguide-en.tex"
3104 %%% coding: utf-8
3105 %%% ispell-local-dictionary: "en_GB"
3106 %%% eval: (flyspell-mode 1)
3107 %%% End:
3108
3109 % LocalWords: Multiline multiline