summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/koma-script/tocbasic.sty
blob: b186dabe9e4fcaa80652cbf4cdd9f942734fd749 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
%%
%% This is file `tocbasic.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tocbasic.dtx  (with options: `package')
%% scrlogo.dtx  (with options: `logo')
%% 
%% Copyright (c) 2007-2009
%% Markus Kohm and any individual authors listed elsewhere in this file.
%% 
%% This file was generated from file(s) of the KOMA-Script bundle.
%% ---------------------------------------------------------------
%% 
%% This work may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, version 1.3c of the license.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later and of this work.
%% 
%% This work has the LPPL maintenance status "author-maintained".
%% 
%% The Current Maintainer and author of this work is Markus Kohm.
%% 
%% This file may only be distributed together with the files
%% `scrlogo.dtx' and `tocbasic.dtx'. You may however distribute the files
%% `scrlogo.dtx' and `tocbasic.dtx' without this file.
%% See also `tocbasic.dtx' for additional information.
%% 
%% If this file is a beta version, you are not allowed to distribute it.
%% 
%% Currently there is only a short english manual at `tocbasic.dtx', that
%% should also be found as `tocbasic.pdf'.
%% 
%% The KOMA-Script bundle (but maybe not this file) was based upon the
%% LaTeX2.09 Script family created by Frank Neukam 1993 and the LaTeX2e
%% standard classes created by The LaTeX3 Project 1994-1996.
%% 
%%% From File: tocbasic.dtx
\def\tocbasicversion{2009/01/20 v3.02a}
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesPackage{tocbasic}
                [\tocbasicversion
                (package)%
                ]
\newcommand*{\tb@listoftocs}{}
\newcommand{\ifattoclist}[1]{%
  \begingroup
    \def\do##1##2{%
      \edef\reserved@a{##1}%
      \ifx\reserved@a\reserved@b\@tempswatrue\fi
    }%
    \edef\reserved@b{#1}\@tempswafalse\tb@listoftocs
    \if@tempswa\aftergroup\@firstoftwo\else\aftergroup\@secondoftwo\fi
  \endgroup
}
\newcommand*{\addtotoclist}{%
  \@ifnextchar [%]
    \scr@@addtotoclist\scr@addtotoclist
}
\newcommand*{\scr@addtotoclist}{%
  \ifx\@currname\@empty
    \def\reserved@a{\scr@@addtotoclist[]}%
  \else
    \edef\reserved@a{\noexpand\scr@@addtotoclist[\@currname.\@currext]}%
  \fi
  \reserved@a
}
\newcommand*{\scr@@addtotoclist}[2][]{%
  \ifattoclist{#2}{%
    \PackageError{tocbasic}{%
      file extension `#2' cannot be used twice
    }{%
      File extension `#2' is already used by a toc-file, while
      \ifx\relax#1\relax someone\else #2\fi\MessageBreak
      tried to use it again for a toc-file.\MessageBreak
      This may be either an incompatibility of packages, an error at a
      package,\MessageBreak
      or a mistake by the user.\MessageBreak
    }%
  }{%
    \g@addto@macro\tb@listoftocs{\do{#2}{#1}}%
    \ifx\relax #1\relax\else
      \@ifundefined{tb@#1@add@hook}{}{%
        \edef\reserved@a{%
          \noexpand\def\noexpand\@currext{#2}%
          \noexpand\@nameuse{tb@#1@add@hook}%
          \noexpand\def\noexpand\@currext{\@currext}%
        }\reserved@a
      }%
    \fi
    \edef\reserved@a{%
      \noexpand\def\noexpand\@currext{#2}%
      \noexpand\@nameuse{tb@@add@hook}%
      \noexpand\def\noexpand\@currext{\@currext}%
    }\reserved@a
  }%
}
\newcommand*{\AtAddToTocList}{%
  \@ifnextchar [%]
    \@@AtAddToTocList\@AtAddToTocList
}
\newcommand*{\@AtAddToTocList}{%
  \ifx\@currname\@empty
    \def\reserved@a{\@@AtAddToTocList[]}%
  \else
    \edef\reserved@a{\noexpand\@@AtAddToTocList[\@currname.\@currext]}%
  \fi
  \reserved@a
}
\newcommand*{\@@AtAddToTocList}[1][]{%
  \@ifundefined{tb@#1@add@hook}{\@namedef{tb@#1@add@hook}{}}{}%
  \expandafter\g@addto@macro\csname tb@#1@add@hook\endcsname
}
\newcommand*{\tocbasic@extend@babel}[1]{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \ifx\csname bbl@set@language\endcsname\relax
    \PackageInfo{tocbasic}{babel extension for `#1' omitted\MessageBreak
      because of missing \string\bbl@set@language}%
  \else
    \iftocfeature{#1}{nobabel}{%
      \PackageInfo{tocbasic}{omitting babel extension for `#1'\MessageBreak
        because of feature `nobabel' available\MessageBreak
        for `#1'}%
    }{%
      \PackageInfo{tocbasic}{setting babel extension for `#1'}%
      \expandafter\gdef\expandafter\bbl@set@language\expandafter##\expandafter1%
      \expandafter{%
        \bbl@set@language{##1}%
        \addtocontents{#1}{\xstring\select@language{\languagename}}%
      }%
    }%
  \fi
}
\AtAddToTocList[]{\expandafter\tocbasic@extend@babel\expandafter{\@currext}}
\newcommand*{\removefromtoclist}{%
  \@ifnextchar [%]
    \@removefromtoclist\@@removefromtoclist
}
\newcommand*{\@removefromtoclist}[2][]{%
  \begingroup
    \let\tb@oldlist\tb@listoftocs
    \def\do##1##2{%
      \edef\reserved@a{##1}%
      \ifx\reserved@a\reserved@b
        \begingroup
          \edef\reserved@a{##2}%
          \edef\reserved@b{#1}%
          \ifx\reserved@a\reserved@b\else
            \g@addto@macro\tb@listoftocs{\do{##1}{##2}}%
          \fi
        \endgroup
      \else
        \g@addto@macro\tb@listoftocs{\do{##1}{##2}}%
      \fi
    }%
    \edef\reserved@b{#2}\let\tb@listoftocs\@empty
    \tb@oldlist
  \endgroup
}
\newcommand*{\@@removefromtoclist}[1]{%
  \begingroup
    \let\tb@oldlist\tb@listoftocs
    \def\do##1##2{%
      \edef\reserved@a{##1}%
      \ifx\reserved@a\reserved@b\else
        \g@addto@macro\tb@listoftocs{\do{##1}{##2}}%
      \fi
    }%
    \edef\reserved@b{#1}\let\tb@listoftocs\@empty
    \tb@oldlist
  \endgroup
}
\newcommand{\doforeachtocfile}{%
  \@ifnextchar [%]
    \@doforeachtocfile\@@doforeachtocfile
}
\newcommand{\@doforeachtocfile}[2][]{%
  \def\do##1##2{%
    \edef\reserved@a{#1}\edef\reserved@b{##2}\ifx\reserved@a\reserved@b
      \edef\@currext{##1}#2%
    \fi
  }%
  \edef\reserved@a{%
    \noexpand\tb@listoftocs
    \noexpand\def\noexpand\@currext{\@currext}%
  }\reserved@a
  \let\do\relax
}
\newcommand{\@@doforeachtocfile}[1]{%
  \def\do##1##2{%
    \edef\@currext{##1}#1%
  }%
  \edef\reserved@a{%
    \noexpand\tb@listoftocs
    \noexpand\def\noexpand\@currext{\@currext}%
  }\reserved@a
  \let\do\relax
}
\newcommand{\addtoeachtocfile}{%
  \@ifnextchar [%]
    \@addtoeachtocfile\@@addtoeachtocfile
}
\newcommand{\@addtoeachtocfile}[2][]{%
  \doforeachtocfile[{#1}]{\addtocontents{\@currext}{#2}}%
}
\newcommand{\@@addtoeachtocfile}[1]{%
  \doforeachfocfile{\addtocontents{\@currext}{#1}}%
}
\newcommand{\addcontentslinetoeachtocfile}{%
  \@ifnextchar [%]
    \@addcontentslinetoeachtocfile\@@addcontentslinetoeachtocfile
}
\newcommand{\@addcontentslinetoeachtocfile}[3][]{%
  \doforeachtocfile[{#1}]{\addcontentsline{\@currext}{#2}{#3}}%
}
\newcommand{\@@addcontentslinetoeachtocfile}[2]{%
  \doforeachtocfile{\addcontentsline{\@currext}{#1}{#2}}%
}
\newcommand*{\tocbasic@starttoc}[1]{%
  \begingroup
    \setlength{\parskip}{\z@}%
    \setlength{\parindent}{\z@}%
    \setlength{\parfillskip}{\z@\@plus 1fil}%
    \def\@currext{#1}%
    \csname tocbasic@@before@hook\endcsname
    \csname tb@#1@before@hook\endcsname
    \@starttoc{#1}%
    \csname tb@#1@after@hook\endcsname
    \csname tocbasic@@after@hook\endcsname
  \endgroup
}
\newcommand*{\tocbasic@@before@hook}{}
\newcommand*{\tocbasic@@after@hook}{}
\newcommand{\BeforeStartingTOC}[2][]{%
  \expandafter\g@addto@macro\csname tb@#1@before@hook\endcsname{#2}%
}
\newcommand{\AfterStartingTOC}[2][]{%
  \expandafter\g@addto@macro\csname tb@#1@after@hook\endcsname{#2}%
}
\newcommand*{\listoftoc}{%
  \@ifstar \tocbasic@starttoc\@listoftoc
}
\newcommand*{\@listoftoc}[2][\list@fname]{%
  \begingroup
    \@ifundefined{listof#2name}{%
      \let\list@fname\relax
      \ifx\relax#1\relax
        \PackageWarning{tocbasic}{%
          You should either define \expandafter\string\csname
          listof#2name\endcsname\MessageBreak
          or use the optional argument of \string\listoftoc\space\MessageBreak
          to set the term to be used for the\MessageBreak
          heading of list of #2}%
        \def\list@fname{\listofname~#2}%
      \fi
    }{%
      \expandafter\let\expandafter\list@fname\csname listof#2name\endcsname
    }%
    \def\@currext{#2}%
    \iftocfeature{\@currext}{onecolumn}{%
      \iftocfeature{\@currext}{leveldown}{}{%
        \if@twocolumn
          \aftergroup\twocolumn\onecolumn
        \fi
      }%
    }{}%
    \tocbasic@listhead{#1}%
    \tocbasic@starttoc{#2}%
  \endgroup
}
\newcommand*{\listofname}{List of}
\newcommand*{\listofeachtoc}{%
  \@ifnextchar [%]
    \@listofeachtoc\@@listofeachtoc
}
\newcommand{\@listofeachtoc}[1][]{%
  \doforeachtocfile[{#1}]{\listoftoc{\@currext}}%
}
\newcommand{\@@listofeachtoc}[1]{%
  \doforeachfocfile{\listoftoc{\@currext}}%
}
\newcommand*{\tocbasic@listhead}[1]{%
  \@ifundefined{tocbasic@listhead@\@currext}{%
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname chapter\endcsname\relax
      \expandafter\def\csname tocbasic@listhead@\@currext\endcsname##1{%
        \iftocfeature{\@currext}{leveldown}{%
          \iftocfeature{\@currext}{numbered}{%
            \subsection[##1]{##1}%
          }{%
            \subsection*{##1}%
            \ifx\@mkboth\@gobbletwo\else\markright{\MakeMarkcase{##1}}\fi
            \iftocfeature{\@currext}{totoc}{%
              \addcontentsline{toc}{subsection}{##1}%
            }{}%
          }%
        }{%
          \iftocfeature{\@currext}{numbered}{%
            \section[##1]{##1\@mkboth{##1}{##1}}%
          }{%
            \section*{##1}%
            \@mkboth{\MakeMarkcase{##1}}{\MakeMarkcase{##1}}%
            \iftocfeature{\@currext}{totoc}{%
              \addcontentsline{toc}{section}{##1}%
            }{}%
          }%
        }%
      }%
    \else
      \expandafter\def\csname tocbasic@listhead@\@currext\endcsname##1{%
        \iftocfeature{\@currext}{leveldown}{%
          \iftocfeature{\@currext}{numbered}{%
            \section{##1}%
          }{%
            \section*{##1}%
            \iftocfeature{\@currext}{totoc}{%
              \addcontentsline{toc}{section}{##1}%
            }{}%
            \ifx\@mkboth\@gobbletwo\else\markright{\MakeMarkcase{##1}}\fi
          }%
        }{%
          \iftocfeature{\@currext}{numbered}{%
            \chapter[##1]{##1\@mkboth{##1}{##1}}%
          }{%
            \chapter*{##1}%
            \@mkboth{\MakeMarkcase{##1}}{\MakeMarkcase{##1}}%
            \iftocfeature{\@currext}{totoc}{%
              \addcontentsline{toc}{chapter}{##1}%
            }{}%
          }%
        }%
      }%
    \fi
  }{}%
  \csname tb@@beforehead@hook\endcsname
  \csname tb@\@currext @beforehead@hook\endcsname
  \csname tocbasic@listhead@\@currext\endcsname{#1}%
  \csname tb@\@currext @afterhead@hook\endcsname
  \csname tb@@afterhead@hook\endcsname
}
\newcommand{\BeforeTOCHead}[2][]{%
  \expandafter\g@addto@macro\csname tb@#1@beforehead@hook\endcsname{#2}%
}
\newcommand{\AfterTOCHead}[2][]{%
  \expandafter\g@addto@macro\csname tb@#1@afterhead@hook\endcsname{#2}%
}
\AtBeginDocument{%
  \@ifundefined{MakeMarkcase}{%
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname KOMAClassName\endcsname\relax
      \let\MakeMarkcase\MakeUppercase
    \else
      \let\MakeMarkcase\@firstofone
    \fi
  }{}%
}
\newcommand*{\deftocheading}[1]{%
  \@namedef{tocbasic@listhead@#1}##1}
\newcommand*{\setuptoc}[2]{%
  \@for\@tempa:=#2\do{%
    \expandafter\tb@@sp@def\expandafter\@tempa\expandafter{\@tempa}%
    \@namedef{tocbasic@#1@feature@\@tempa}{}%
  }%
}
\newcommand*{\unsettoc}[2]{%
  \@for\@tempa:=#2\do{%
    \expandafter\tb@@sp@def\expandafter\@tempa\expandafter{\@tempa}%
    \expandafter\let\csname tocbasic@#1@feature@\@tempa\endcsname\relax
  }%
}
\def\@tempa#1{%
  \def\tb@@sp@def##1##2{%
    \futurelet\tb@sp@tempa\tb@@sp@d##2\@nil\@nil#1\@nil\relax##1}%
  \def\tb@@sp@d{%
    \ifx\tb@sp@tempa\@sptoken
      \expandafter\tb@@sp@b
    \else
      \expandafter\tb@@sp@b\expandafter#1%
    \fi}%
  \def\tb@@sp@b#1##1 \@nil{\tb@@sp@c##1}%
}
\@tempa{ }
\def\tb@@sp@c#1\@nil#2\relax#3{\@temptokena{#1}\edef#3{\the\@temptokena}}
\setuptoc{toc}{nobabel}
\setuptoc{lof}{nobabel}
\setuptoc{lot}{nobabel}
\newcommand*{\iftocfeature}[2]{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname tocbasic@#1@feature@#2\endcsname\relax
    \expandafter\@secondoftwo
  \else
    \expandafter\@firstoftwo
  \fi
}
\newcommand*{\tocbasicautomode}{%
  \let\tb@saved@starttoc\@starttoc
  \BeforeStartingTOC{%
    \let\@starttoc\tb@saved@starttoc
    \expandafter\ifattoclist\expandafter{\@currext}{}{%
      \addtotoclist[tocbasicautomode]{\@currext}%
    }%
  }%
}
%%% From File: scrlogo.dtx
\@ifundefined{KOMAScript}{%
  \DeclareRobustCommand{\KOMAScript}{\textsf{K\kern.05em O\kern.05em%
      M\kern.05em A\kern.1em-\kern.1em Script}}}{}
\endinput
%%
%% End of file `tocbasic.sty'.