| 1 |
% \iffalse meta-comment |
| 2 |
% ====================================================================== |
| 3 |
% tocbasic.dtx |
| 4 |
% Copyright (c) Markus Kohm, 2008-2025 |
| 5 |
% |
| 6 |
% This file is part of the LaTeX2e KOMA-Script bundle. |
| 7 |
% |
| 8 |
% This work may be distributed and/or modified under the conditions of |
| 9 |
% the LaTeX Project Public License, version 1.3c of the license. |
| 10 |
% The latest version of this license is in |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 13 |
% version 2005/12/01 or later and of this work. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status "author-maintained". |
| 16 |
% |
| 17 |
% The Current Maintainer and author of this work is Markus Kohm. |
| 18 |
% |
| 19 |
% This work consists of all files listed in MANIFEST.md. |
| 20 |
% ====================================================================== |
| 21 |
%%% From File: $Id: tocbasic.dtx 4251 2025-12-31 10:31:49Z kohm $ |
| 22 |
%<identify>%%% (run: identify) |
| 23 |
%<prepare>%%% (run: prepare) |
| 24 |
%<option>%%% (run: option) |
| 25 |
%<execoption>%%% (run: execoption) |
| 26 |
%<preparebody>%%% (run: preparebody) |
| 27 |
%<body>%%% (run: body) |
| 28 |
%<exit>%%% (run: exit) |
| 29 |
%<*dtx> |
| 30 |
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi |
| 31 |
\begingroup |
| 32 |
\def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}} |
| 33 |
\filedate$Date: 2025-12-31 11:31:49 +0100 (Mi, 31 Dez 2025) $ |
| 34 |
\def\filerevision$#1: #2 ${\gdef\filerevision{r#2}} |
| 35 |
\filerevision$Revision: 4251 $ |
| 36 |
\endgroup |
| 37 |
\ProvidesFile{tocbasic.dtx}[\filedate\space\filerevision\space |
| 38 |
%</dtx> |
| 39 |
%<package&identify>\NeedsTeXFormat{LaTeX2e}[2022/06/01] |
| 40 |
%<package&identify>\ProvidesPackage{tocbasic}[% |
| 41 |
%<*dtx|(package&identify)> |
| 42 |
%!KOMAScriptVersion |
| 43 |
package |
| 44 |
%<*dtx> |
| 45 |
source |
| 46 |
%</dtx> |
| 47 |
%</dtx|(package&identify)> |
| 48 |
%<package&identify> (handling toc-files)% |
| 49 |
%<*dtx> |
| 50 |
(dtx)% |
| 51 |
%</dtx> |
| 52 |
%<*dtx|(package&identify)> |
| 53 |
] |
| 54 |
%</dtx|(package&identify)> |
| 55 |
%<*dtx> |
| 56 |
\ifx\documentclass\undefined |
| 57 |
\input scrdocstrip.tex |
| 58 |
\@@input scrkernel-version.dtx |
| 59 |
\@@input scrstrip.inc |
| 60 |
\KOMAdefVariable{COPYRIGHTFROM}{2008} |
| 61 |
\generate{\usepreamble\defaultpreamble |
| 62 |
\file{tocbasic.sty}{% |
| 63 |
\from{tocbasic.dtx}{package,identify}% |
| 64 |
\from{tocbasic.dtx}{package,prepare}% |
| 65 |
\from{tocbasic.dtx}{package,option}% |
| 66 |
\from{tocbasic.dtx}{package,execoption}% |
| 67 |
\from{tocbasic.dtx}{package,preparebody}% |
| 68 |
\from{tocbasic.dtx}{package,body,deprecated}% |
| 69 |
\from{scrkernel-tocstyle.dtx}{package,body}% |
| 70 |
\from{scrkernel-tocstyle.dtx}{package,style,gobble}% |
| 71 |
\from{scrkernel-tocstyle.dtx}{package,style,dottedtocline}% |
| 72 |
\from{scrkernel-tocstyle.dtx}{package,style,undottedtocline}% |
| 73 |
\from{scrkernel-tocstyle.dtx}{package,style,largetocline}% |
| 74 |
\from{scrkernel-tocstyle.dtx}{package,style,tocline}% |
| 75 |
\from{scrkernel-tocstyle.dtx}{package,style,toctext}% |
| 76 |
\from{scrkernel-tocstyle.dtx}{package,style,default}% |
| 77 |
\from{tocbasic.dtx}{package,exit}% |
| 78 |
\from{scrlogo.dtx}{logo}% |
| 79 |
}% |
| 80 |
}% |
| 81 |
\@@input scrstrop.inc |
| 82 |
\else |
| 83 |
\let\endbatchfile\relax |
| 84 |
\fi |
| 85 |
\endbatchfile |
| 86 |
\documentclass[USenglish]{koma-script-source-doc} |
| 87 |
\usepackage{babel} |
| 88 |
\setcounter{StandardModuleDepth}{2} |
| 89 |
\begin{document} |
| 90 |
\DocInput{tocbasic.dtx} |
| 91 |
\end{document} |
| 92 |
%</dtx> |
| 93 |
% \fi |
| 94 |
% |
| 95 |
% \changes{v3.36}{2022/02/10}{switch over from \cls*{scrdoc} to |
| 96 |
% \cls*{koma-script-source-doc}} |
| 97 |
% \changes{v3.36}{2022/02/10}{require package \pkg*{scrlogo} instead of |
| 98 |
% defining \cs{KOMAScript}} |
| 99 |
% \changes{v3.40}{2023/04/17}{guide names changed} |
| 100 |
% |
| 101 |
% \GetFileInfo{tocbasic.dtx} |
| 102 |
% \title{Handling of Tables and Lists of Contents with |
| 103 |
% \href{https://komascript.de}{\KOMAScript} Package \pkg*{tocbasic}} |
| 104 |
% \author{\href{mailto:[email protected]}{Markus Kohm}} |
| 105 |
% \date{Revision \fileversion{} of \filedate} |
| 106 |
% \maketitle |
| 107 |
% \begin{abstract} |
| 108 |
% The main purpose of package \pkg*{tocbasic} is to provide features for |
| 109 |
% authors of classes and packages to create own tables or lists of contents |
| 110 |
% like the list of figures and the list of tables and thereby allow other |
| 111 |
% classes or packages some types of control over these. For examples package |
| 112 |
% \pkg*{tocbasic} delegates language control of all these tables and lists |
| 113 |
% of contents to package \pkg{babel}. So automatic change of language |
| 114 |
% will be provided inside all these tables and lists of contents. Using |
| 115 |
% \pkg*{tocbasic} will exculpate authors of classes and packages from |
| 116 |
% implementation of such features. |
| 117 |
% |
| 118 |
% \KOMAScript{} classes use \pkg*{tocbasic} not only for the table of |
| 119 |
% contents but also for the already mentioned lists of figures and tables. |
| 120 |
% \end{abstract} |
| 121 |
% \tableofcontents |
| 122 |
% |
| 123 |
% \section{User Manual} |
| 124 |
% |
| 125 |
% You can find the user manuals of \pkg*{tocbasic} in the \KOMAScript{} |
| 126 |
% manual, either the German \file{scrguide-de.pdf} or the English |
| 127 |
% \file{scrguide-en.pdf}. |
| 128 |
% |
| 129 |
% |
| 130 |
% \MaybeStop{\PrintIndex} |
| 131 |
% |
| 132 |
% |
| 133 |
% \section{Implementation} |
| 134 |
% \label{sec:implementation} |
| 135 |
% |
| 136 |
% \begin{macrocode} |
| 137 |
%<@@=tocbasic> |
| 138 |
%<*package> |
| 139 |
% \end{macrocode} |
| 140 |
% |
| 141 |
% All macros with prefix \cs{tb@} or \cs{@} are internal macros and should not |
| 142 |
% be used by package and class authors. Macros with prefix \cs{tocbasic@} are |
| 143 |
% internal macros, that may be used by class and packages authors. Macros |
| 144 |
% without \texttt{@} are interface commands and may be used by class and |
| 145 |
% package authors and users. |
| 146 |
% |
| 147 |
% Note: Parts of the implementation of package \pkg*{tocbasic} are |
| 148 |
% out-sourced into file \file{scrkernel-tocbasic.dtx}. |
| 149 |
% |
| 150 |
% |
| 151 |
% \subsection{Requirements} |
| 152 |
% \label{sec:packages} |
| 153 |
% |
| 154 |
% \changes{v3.42}{2023/09/08}{We need at least \LaTeX{} 2022-06-01} |
| 155 |
% For full functionality at least \LaTeX{} 2022-06-01 is needed. |
| 156 |
% \begin{macrocode} |
| 157 |
%<*prepare> |
| 158 |
\newif\if@tocbasic@old@latex@found |
| 159 |
\ifnum 0=\ifcsname IfFormatAtLeastTF\endcsname |
| 160 |
\IfFormatAtLeastTF{2022-06-01}{1}{0} |
| 161 |
\else |
| 162 |
0 |
| 163 |
\fi\relax |
| 164 |
\PackageWarningNoLine{tocbasic}{% |
| 165 |
LaTeX kernel too old!\MessageBreak |
| 166 |
For full functionality the package needs at least\MessageBreak |
| 167 |
LaTeX 2022-06-01.\MessageBreak |
| 168 |
You are using an older LaTeX version.\MessageBreak |
| 169 |
So the functionality will be limited.\MessageBreak |
| 170 |
Note that this also can result in error messages,\MessageBreak |
| 171 |
that would not raise with an up-to-date LaTeX% |
| 172 |
} |
| 173 |
\@tocbasic@old@latex@foundtrue |
| 174 |
\fi |
| 175 |
% \end{macrocode} |
| 176 |
% \changes{v3.41}{2023/06/28}{required packages moved to \texttt{prepare} run} |
| 177 |
% \changes{v3.41}{2023/06/28}{\pkg{expl3} and \pkg{xparse} are required} |
| 178 |
% Package \pkg*{scrbase} is needed to process all macro options. |
| 179 |
% \begin{macrocode} |
| 180 |
\RequirePackage{scrbase} |
| 181 |
% \end{macrocode} |
| 182 |
% |
| 183 |
% Now we can load \pkg{xparse} if needed, which also would load \pkg{expl3}: |
| 184 |
% \begin{macrocode} |
| 185 |
\scr@ifundefinedorrelax{NewDocumentCommand}{% |
| 186 |
\RequirePackage{xparse}[2018-04-12]% |
| 187 |
}{} |
| 188 |
% \end{macrocode} |
| 189 |
% |
| 190 |
% \changes{v3.50}{2025/12/31}{stop loading with \cls{beamer}} |
| 191 |
% Now we can detect \cls{beamer} to stop loading the package. |
| 192 |
% \begin{macrocode} |
| 193 |
\IfClassLoadedTF{beamer}{% |
| 194 |
\PackageWarningNoLine{tocbasic}{% |
| 195 |
beamer class detected,\MessageBreak |
| 196 |
loading package tocbasic aborted% |
| 197 |
}% |
| 198 |
\DeclareOption*{} |
| 199 |
\ProcessOptions |
| 200 |
\endinput |
| 201 |
}{} |
| 202 |
%</prepare> |
| 203 |
% \end{macrocode} |
| 204 |
% |
| 205 |
% |
| 206 |
% \subsection{Options} |
| 207 |
% \label{sec:options} |
| 208 |
% |
| 209 |
% \changes{v3.42}{2023/09/08}{with old \LaTeX{} all options are unknown} |
| 210 |
% |
| 211 |
% \begin{option}{enablepatch,disablepatch} |
| 212 |
% \changes{v3.42}{2023/09/08}{added} |
| 213 |
% From version 3.42 there a several optional patches executed while |
| 214 |
% |\begin{document}|. Every one of that patch can be enabled or disabled. |
| 215 |
% \ExplSyntaxOn |
| 216 |
% \begin{macro}{\g_@@_patch_all_bool,\g_@@_patch_starttoc_bool, |
| 217 |
% \g_@@_patch_chapter_bool, |
| 218 |
% \g_@@_patch_listoffigures_bool,\g_@@_patch_listoftables_bool} |
| 219 |
% \ExplSyntaxOff |
| 220 |
% \changes{v3.42}{2023/09/08}{added} |
| 221 |
% \changes{v3.46}{2025/06/10}{respecting l3 naming convention} |
| 222 |
% Enabling and disabling will be done using a boolean variable with default |
| 223 |
% |false| (disabled). The |all| patch is somehow different. It enables or |
| 224 |
% disables doing all patches. So |disablepatch=all| does not disable all |
| 225 |
% patches but disables to ignore the single patches. |
| 226 |
% \begin{macrocode} |
| 227 |
%<*option> |
| 228 |
\if@tocbasic@old@latex@found\else |
| 229 |
\ExplSyntaxOn |
| 230 |
|
| 231 |
\bool_new:N \g_@@_patch_all_bool |
| 232 |
\bool_new:N \g_@@_patch_starttoc_bool |
| 233 |
\bool_new:N \g_@@_patch_chapter_bool |
| 234 |
\bool_new:c { g_@@_patch_chapter*_bool } |
| 235 |
\bool_new:N \g_@@_patch_listoffigures_bool |
| 236 |
\bool_new:N \g_@@_patch_listoftables_bool |
| 237 |
|
| 238 |
% \end{macrocode} |
| 239 |
% \end{macro} |
| 240 |
% \ExplSyntaxOff |
| 241 |
% \ExplSyntaxOn |
| 242 |
% \begin{macro}{\g_@@_patch_caption_bool} |
| 243 |
% \ExplSyntaxOff |
| 244 |
% \changes{v3.46}{2025/06/10}{added} |
| 245 |
% From version 3.46 the caption code of the \KOMAScript{} classes is |
| 246 |
% (partially) redesigned and move to \pkg*{tocbasic}. But it is only |
| 247 |
% activated with option \opt{enablepatch=caption}. The \KOMAScript{} classes |
| 248 |
% load \pkg*{tocbasic} with this option. Nevertheless you can overwrite it |
| 249 |
% an so get lost of all the extended caption features. |
| 250 |
% \begin{macrocode} |
| 251 |
\bool_new:N \g_@@_patch_caption_bool |
| 252 |
% \end{macrocode} |
| 253 |
% \end{macro} |
| 254 |
% \ExplSyntaxOff |
| 255 |
% The most simple part of the story is the definition of the two |
| 256 |
% options. Both allow a comma separated list of patches to set the |
| 257 |
% corresponding boolean value to |true| or |false|. |
| 258 |
% \begin{macrocode} |
| 259 |
\keys_define:nn { tocbasic } |
| 260 |
{ |
| 261 |
enablepatch .code = \@@_endisable_patch:nn {#1} \c_true_bool, |
| 262 |
enablepatch .usage = preamble, |
| 263 |
enablepatch .value_required:n = true, |
| 264 |
disablepatch .code = \@@_endisable_patch:nn {#1} \c_false_bool, |
| 265 |
disablepatch .usage = preamble, |
| 266 |
disablepatch .value_required:n = true, |
| 267 |
} |
| 268 |
|
| 269 |
% \end{macrocode} |
| 270 |
% \ExplSyntaxOn |
| 271 |
% \begin{macro}{\@@_endisable_patch:nn} |
| 272 |
% \ExplSyntaxOff |
| 273 |
% \changes{v3.42}{2023/09/08}{added} |
| 274 |
% \changes{v3.43}{2024/10/22}{deprecated \cs{char\_uppercase:N} replaced by |
| 275 |
% \cs{text\_uppercase:n}} |
| 276 |
% Switch the patch \#1 depending on argument \#2 or raise a warning for |
| 277 |
% unknown patches. |
| 278 |
% \begin{macrocode} |
| 279 |
\msg_new:nnnn { tocbasic } { unknown-patch } |
| 280 |
{ |
| 281 |
\text_uppercase:n #1bling~of~unknown~patch~#2~ignored. |
| 282 |
} |
| 283 |
{ |
| 284 |
You've~tried~to~#1able~patch~#2,~ |
| 285 |
but~this~is~not~a~known~patch.~ |
| 286 |
Because~of~this~your~attempt~is~ignored.~ |
| 287 |
See~the~KOMA-Script~user~manual~for~more~information~about~known~patches. |
| 288 |
} |
| 289 |
|
| 290 |
\cs_new:Nn \@@_endisable_patch:nn |
| 291 |
{ |
| 292 |
\clist_map_inline:nn { #1 } |
| 293 |
{ |
| 294 |
\cs_if_exist:cTF { g_@@_patch_##1_bool } |
| 295 |
{ |
| 296 |
\bool_set_eq:cN { g_@@_patch_##1_bool } #2 |
| 297 |
} |
| 298 |
{ |
| 299 |
\exp_args:Nnnx \msg_warning:nnnn { tocbasic } { unknown-patch } |
| 300 |
{ \bool_if:NTF #2 { en } { dis } } { ##1 } |
| 301 |
} |
| 302 |
} |
| 303 |
} |
| 304 |
|
| 305 |
\ExplSyntaxOff |
| 306 |
\fi |
| 307 |
%</option> |
| 308 |
% \end{macrocode} |
| 309 |
% \end{macro} |
| 310 |
% \ExplSyntaxOff |
| 311 |
% The patch codes are executed while |\begin{document}|. Some patches may be |
| 312 |
% dangerous, in which case message |dangerous-patch| is used. |
| 313 |
% \begin{description} |
| 314 |
% \item[ToDo:] We are using the old \cs{AtBeginDocument} here. Maybe a new |
| 315 |
% hook would be cleaner. |
| 316 |
% \end{description} |
| 317 |
% \begin{macrocode} |
| 318 |
%<*body> |
| 319 |
\if@tocbasic@old@latex@found\else |
| 320 |
\ExplSyntaxOn |
| 321 |
\msg_new:nnnn { tocbasic } { dangerous-patch } |
| 322 |
{ |
| 323 |
Dangerous~#2~patch~enabled \str_if_empty:nF { #1 } { ~using~#1 } . |
| 324 |
} |
| 325 |
{ |
| 326 |
\str_if_empty:nF { #1 } { Class~#1~does~not~need~the~#2~patch.~ } |
| 327 |
Using~this~patch~can~even~result~in~harm.~ |
| 328 |
If~you~are~not~sure~that~this~patch~is~needed,~ |
| 329 |
you~should~not~enable~it.~ |
| 330 |
Please,~see~the~KOMA-Script~user~manual~for~more~information~about~ |
| 331 |
the~#2~patch. |
| 332 |
} |
| 333 |
|
| 334 |
\AtBeginDocument |
| 335 |
{ |
| 336 |
|
| 337 |
% \end{macrocode} |
| 338 |
% The patches are: |
| 339 |
% \begin{description} |
| 340 |
% \item[\texttt{all}:] |
| 341 |
% \changes{v3.46}{2025/06/13}{\opt{enablepath\quotechar=all} enables the |
| 342 |
% caption patch, if \pkg*{caption} has not been loaded} |
| 343 |
% activate all other patches. The \texttt{chapter} patch |
| 344 |
% is not enabled for \KOMAScript{} classes. So if you want to use this patch |
| 345 |
% with a \KOMAScript{} class\,---\,which usually will not make sense\,---\,, |
| 346 |
% you have to use an explicit |enabelpatch=chapter|. |
| 347 |
% \begin{macrocode} |
| 348 |
\bool_if:NT \g_@@_patch_all_bool |
| 349 |
{ |
| 350 |
\bool_set_true:N \g_@@_patch_starttoc_bool |
| 351 |
\cs_if_exist:NF \KOMAClassName |
| 352 |
{ |
| 353 |
\bool_set_true:N \g_@@_patch_chapter_bool |
| 354 |
\bool_set_true:c { g_@@_patch_chapter*_bool } |
| 355 |
} |
| 356 |
\bool_set_true:N \g_@@_patch_listoffigures_bool |
| 357 |
\bool_set_true:N \g_@@_patch_listoftables_bool |
| 358 |
\IfPackageLoadedTF{ caption } { } |
| 359 |
{ \bool_set_true:N \g_@@_patch_caption_bool } |
| 360 |
} |
| 361 |
|
| 362 |
% \end{macrocode} |
| 363 |
% \item[\texttt{chapter}:] patches \cs{@makechapterhead} to add \cs{addvspace} |
| 364 |
% to every float list. It does \emph{not} patch \cs{@makeschapterhead}. Note |
| 365 |
% that this patch should not be activated using a \KOMAScript{} class unless |
| 366 |
% you are using an incompatible \cs{chapter} definition. This patch is |
| 367 |
% potentially dangerous. So we raise at least a note and maybe a warning. |
| 368 |
% \begin{macrocode} |
| 369 |
\bool_if:NT \g_@@_patch_chapter_bool |
| 370 |
{ |
| 371 |
\@@_chapter_patch_code: |
| 372 |
} |
| 373 |
|
| 374 |
% \end{macrocode} |
| 375 |
% \item[\texttt{starttoc}:] executes \cs{tocbasicautomode} |
| 376 |
% \begin{macrocode} |
| 377 |
\bool_if:NT \g_@@_patch_starttoc_bool \tocbasicautomode |
| 378 |
|
| 379 |
% \end{macrocode} |
| 380 |
% \item[\texttt{listoffigures}] redefines \cs{listoffigures} to use |
| 381 |
% \pkg*{tocbasic} (but without changing \cs{l@figure}, because |
| 382 |
% \cs{DeclareTOCSTyleEntry} already has defaults for \texttt{figure}). |
| 383 |
% \begin{macrocode} |
| 384 |
\bool_if:NT \g_@@_patch_listoffigures_bool |
| 385 |
{ |
| 386 |
\@@_listof_patch_code:n{figure} |
| 387 |
} |
| 388 |
|
| 389 |
% \end{macrocode} |
| 390 |
% \item[\texttt{listoftables}] redefines \cs{listoftables} to use |
| 391 |
% \pkg*{tocbasic} (but without changing \cs{l@table}, because |
| 392 |
% \cs{DeclareTOCSTyleEntry} already has defaults for \texttt{table}). |
| 393 |
% \begin{macrocode} |
| 394 |
\bool_if:NT \g_@@_patch_listoftables_bool |
| 395 |
{ |
| 396 |
\@@_listof_patch_code:n{table} |
| 397 |
} |
| 398 |
|
| 399 |
% \end{macrocode} |
| 400 |
% \end{description} |
| 401 |
% \begin{macrocode} |
| 402 |
} |
| 403 |
|
| 404 |
\ExplSyntaxOff |
| 405 |
\fi |
| 406 |
%</body> |
| 407 |
% \end{macrocode} |
| 408 |
% \end{option} |
| 409 |
% \ExplSyntaxOff |
| 410 |
% |
| 411 |
% \begin{macrocode} |
| 412 |
%<*execoption> |
| 413 |
\if@tocbasic@old@latex@found |
| 414 |
\ProcessOptions\relax |
| 415 |
\else |
| 416 |
\ProcessKeyOptions[tocbasic] |
| 417 |
\fi |
| 418 |
%</execoption> |
| 419 |
% \end{macrocode} |
| 420 |
% |
| 421 |
% |
| 422 |
% \subsection{Unwanted packages} |
| 423 |
% \label{sec:unpackages} |
| 424 |
% |
| 425 |
% There are packages, that are not recommended to be used together with |
| 426 |
% \pkg*{tocbasic}: |
| 427 |
% \begin{macrocode} |
| 428 |
%<*body> |
| 429 |
% \end{macrocode} |
| 430 |
% \begin{description} |
| 431 |
% \item[\pkg{multitoc}:] This package implements multi-column ToCs using |
| 432 |
% \pkg{multicol}. Unfortunately there is a bug in that package, that |
| 433 |
% disables all extensions but \file{toc}, \file{lof} and \file{lot} and |
| 434 |
% even these if the corresponding option has not been set. |
| 435 |
% \begin{macrocode} |
| 436 |
\AfterPackage*{multitoc}{% |
| 437 |
\@ifpackagelater{multitoc}{2022/02/10}{}{% |
| 438 |
\PackageWarningNoLine{tocbasic}{% |
| 439 |
Usage of package `multitoc' is not recommended!\MessageBreak |
| 440 |
Note, this package generally results in empty ToCs\MessageBreak |
| 441 |
for all extension but `toc', `lof' and `lot' and\MessageBreak |
| 442 |
even for these extensions if you do not use the\MessageBreak |
| 443 |
corresponding multitoc options.\MessageBreak |
| 444 |
It is recommended to use:\MessageBreak |
| 445 |
\space\space\string\usepackage{multicol}\MessageBreak |
| 446 |
\space\space\string\BeforeStartingTOC{\string\begin{multicols}{2}}% |
| 447 |
\MessageBreak |
| 448 |
\space\space\string\AfterStartingTOC{\string\end{multicols}}% |
| 449 |
\MessageBreak |
| 450 |
instead of loading package `multitoc'.\MessageBreak |
| 451 |
See the KOMA-Script manual for more information\MessageBreak |
| 452 |
about using \string\BeforeStartingTOC\space and |
| 453 |
\string\AfterStartingTOC\MessageBreak |
| 454 |
and the multicol manual for more information\MessageBreak |
| 455 |
about the `multicols' environment% |
| 456 |
}% |
| 457 |
}% |
| 458 |
} |
| 459 |
% \end{macrocode} |
| 460 |
% \end{description} |
| 461 |
% \begin{macrocode} |
| 462 |
%</body> |
| 463 |
% \end{macrocode} |
| 464 |
% |
| 465 |
% |
| 466 |
% \subsection{Having a list of all toc-files} |
| 467 |
% \label{sec:listoftocs} |
| 468 |
% |
| 469 |
% If we have a list of all toc-files we may do commands for all |
| 470 |
% toc-files. Somethimes it may be usefull to known the package, that created |
| 471 |
% the toc-file, so this information will be stored additionally. |
| 472 |
% |
| 473 |
% \begin{macro}{\tb@listoftocs} |
| 474 |
% This is the list of toc-files. The list will be: |
| 475 |
% \begin{quote} |
| 476 |
% \cs{do}\marg{extension}\marg{class or |
| 477 |
% package}\cs{do}\marg{extension}\marg{class or package}\dots |
| 478 |
% \end{quote} |
| 479 |
% With this, adding and processing the list will be very fast but removing |
| 480 |
% an element will be very slow. |
| 481 |
% |
| 482 |
% The initial state of the list will be \emph{empty}. |
| 483 |
% \begin{macrocode} |
| 484 |
%<*body> |
| 485 |
\newcommand*{\tb@listoftocs}{} |
| 486 |
% \end{macrocode} |
| 487 |
% \end{macro} |
| 488 |
% |
| 489 |
% \begin{command}{\ifattoclist,\Ifattoclist} |
| 490 |
% \changes{v3.28}{2019/11/19}{\cs{ifattoclist} renamed to \cs{Ifattoclist}} |
| 491 |
% This command tests, if an extension is already at the list of toc-files. The |
| 492 |
% extension has to be the first argument. The second argument will be done, if |
| 493 |
% the extension is already at the list of toc-files. The third argument will |
| 494 |
% be done, if the extension is at the list of toc-files not yet. |
| 495 |
% \begin{macrocode} |
| 496 |
\providecommand*{\ifattoclist}{% |
| 497 |
\PackageWarning{tocbasic}{Usage of deprecated command |
| 498 |
`\string\ifattoclist'.\MessageBreak |
| 499 |
The command has been renamed because of a\MessageBreak |
| 500 |
recommendation of The LaTeX Project Team.\MessageBreak |
| 501 |
Please replace `\string\ifattoclist' by `\string\Ifattoclist'% |
| 502 |
}% |
| 503 |
\Ifattoclist |
| 504 |
} |
| 505 |
\newcommand{\Ifattoclist}[1]{% |
| 506 |
\begingroup |
| 507 |
\def\do##1##2{% |
| 508 |
\edef\reserved@a{##1}% |
| 509 |
\ifx\reserved@a\reserved@b\@tempswatrue\fi |
| 510 |
}% |
| 511 |
\edef\reserved@b{#1}\@tempswafalse\tb@listoftocs |
| 512 |
\if@tempswa\aftergroup\@firstoftwo\else\aftergroup\@secondoftwo\fi |
| 513 |
\endgroup |
| 514 |
} |
| 515 |
% \end{macrocode} |
| 516 |
% \end{command}^^A \ifattoclist,\Ifattoclist |
| 517 |
% |
| 518 |
% \begin{macro}{\tb@optowner} |
| 519 |
% \changes{v3.41}{2023/06/28}{added} |
| 520 |
% Several of the following commands use an optional argument for the |
| 521 |
% owner. Almost always if the argument is not given but \cs{@currname} is not |
| 522 |
% empty \texttt{\cs{@currname}.\cs{@currext}} should be used. If the argument |
| 523 |
% is not given but \cs{@currname} is empty, an empty value should be used. And |
| 524 |
% if the optional argument is given, it should be used unchanged. So here is a |
| 525 |
% helper macro for exactly this logic. Note, that argument here is not |
| 526 |
% optional but mandatory and should be an optional argument of |
| 527 |
% \cs{NewDocumentCommand}. |
| 528 |
% \begin{macrocode} |
| 529 |
\newcommand*{\tb@optowner}[1]{% |
| 530 |
\IfValueTF{#1}{% |
| 531 |
#1% |
| 532 |
}{% |
| 533 |
\ifx\@currname\@empty\else |
| 534 |
\@currname.\@currext% |
| 535 |
\fi |
| 536 |
}% |
| 537 |
} |
| 538 |
% \end{macrocode} |
| 539 |
% \end{macro} |
| 540 |
% \begin{command}{\addtotoclist} |
| 541 |
% \changes{v3.06a}{2010/09/14}{expand the arguments while adding them to the |
| 542 |
% internal list} |
| 543 |
% \changes{v3.41}{2023/06/28}{using \cs{NewDocumentCommand} to not need all |
| 544 |
% the helpers} |
| 545 |
% This command adds an extension to the list of toc-files. The first, |
| 546 |
% optional argument is the class or package name with the corresponding |
| 547 |
% extension of class or package files. If this argument was omitted |
| 548 |
% \pkg*{tocbasic} tries to get it automatically. This should be |
| 549 |
% successfull while loading a class or package but not while processing any |
| 550 |
% command of a class or package after loading the class or package. The |
| 551 |
% second, mandatory argument is the extension of the toc-file. NOTE: An |
| 552 |
% empty first argument is not the same like omitting the first argument! |
| 553 |
% \begin{macrocode} |
| 554 |
%<@@=> |
| 555 |
\NewDocumentCommand\addtotoclist{om}{% |
| 556 |
\edef\reserved@b{\tb@optowner{#1}}% |
| 557 |
\Ifattoclist{#2}{% |
| 558 |
\PackageError{tocbasic}{% |
| 559 |
file extension `#2' cannot be used twice |
| 560 |
}{% |
| 561 |
File extension `#2' is already used by a toc-file, while |
| 562 |
\ifx\relax#1\relax someone\else #2\fi\MessageBreak |
| 563 |
tried to use it again for a toc-file.\MessageBreak |
| 564 |
This may be either an incompatibility of packages, an error at a |
| 565 |
package,\MessageBreak |
| 566 |
or a mistake by the user.\MessageBreak |
| 567 |
}% |
| 568 |
}{% |
| 569 |
\begingroup |
| 570 |
\edef\reserved@a{% |
| 571 |
\noexpand\g@addto@macro\noexpand\tb@listoftocs{% |
| 572 |
\noexpand\do{#2}{\reserved@b}}}\reserved@a |
| 573 |
\endgroup |
| 574 |
\ifx\reserved@b\@empty\else |
| 575 |
\@ifundefined{tb@\reserved@b @add@hook}{}{% |
| 576 |
\edef\reserved@a{% |
| 577 |
\noexpand\def\noexpand\@currext{#2}% |
| 578 |
\noexpand\@nameuse{tb@\reserved@b @add@hook}% |
| 579 |
\noexpand\def\noexpand\@currext{\@currext}% |
| 580 |
}\reserved@a |
| 581 |
}% |
| 582 |
\fi |
| 583 |
\edef\reserved@a{% |
| 584 |
\noexpand\def\noexpand\@currext{#2}% |
| 585 |
\noexpand\@nameuse{tb@@add@hook}% |
| 586 |
\noexpand\def\noexpand\@currext{\@currext}% |
| 587 |
}\reserved@a |
| 588 |
}% |
| 589 |
} |
| 590 |
%<@@=tocbasic> |
| 591 |
% \end{macrocode} |
| 592 |
% \end{command} |
| 593 |
% |
| 594 |
% \begin{command}{\owneroftoc} |
| 595 |
% \changes{v3.22}{2016/08/09}{added} |
| 596 |
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}} |
| 597 |
% Returns the owner of a TOC or uses the owner of a TOC as argument of the |
| 598 |
% optional argument, if it exists. |
| 599 |
% \begin{macrocode} |
| 600 |
\newcommand*{\owneroftoc}[2][\@firstofone]{% |
| 601 |
\begingroup |
| 602 |
\let\reserved@a\endgroup |
| 603 |
\def\do##1##2{\Ifstr{#2}{##1}{\def\reserved@a{\endgroup#1{##2}}}{}}% |
| 604 |
\tb@listoftocs |
| 605 |
\reserved@a |
| 606 |
} |
| 607 |
% \end{macrocode} |
| 608 |
% \end{command} |
| 609 |
% \begin{command}{\categoryoftoc} |
| 610 |
% \changes{v3.27}{2019/05/12}{added} |
| 611 |
% Synonym for \cs{owneroftoc}. |
| 612 |
% \begin{macrocode} |
| 613 |
\newcommand*{\categoryoftoc}{\owneroftoc} |
| 614 |
% \end{macrocode} |
| 615 |
% \end{command} |
| 616 |
% |
| 617 |
% \begin{command}{\AtAddToTocList} |
| 618 |
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by |
| 619 |
% \cs{kernel@ifnextchar}} |
| 620 |
% \changes{v3.41}{2023/06/28}{using \cs{NewDocumentCommand} to not need all |
| 621 |
% the helpers} |
| 622 |
% Action to be done, when adding a toc-file of a known owner. The first |
| 623 |
% optional argument is the owner. The second, mandatory argument is the |
| 624 |
% action. While doing the action \cs{@currext} will be the extension of the |
| 625 |
% added toc-file. If the first argument was omitted \pkg*{tocbasic} tries |
| 626 |
% to get it automatically. This should be successfull while loading a class |
| 627 |
% or package but not while processing any command of a class or package |
| 628 |
% after loading the class or package. The second, mandatory argument is the |
| 629 |
% extension of the toc-file. NOTE: An empty first argument is not the same |
| 630 |
% like omitting the first argument, but set's up the general hook. The |
| 631 |
% general hook will be done for every adding after the individual hook (this |
| 632 |
% means, you may dactivate features at the individual hook before processing |
| 633 |
% the general hook). But the individual hook will not be processed for |
| 634 |
% toc-files without any owner! |
| 635 |
% \begin{macrocode} |
| 636 |
\NewDocumentCommand\AtAddToTocList{o}{% |
| 637 |
\edef\reserved@a{\tb@optowner{#1}}% |
| 638 |
\@ifundefined{tb@\reserved@a @add@hook}% |
| 639 |
{\@namedef{tb@\reserved@a @add@hook}{}}% |
| 640 |
{}% |
| 641 |
\expandafter\g@addto@macro\csname tb@\reserved@a @add@hook\endcsname |
| 642 |
} |
| 643 |
% \end{macrocode} |
| 644 |
% \end{command} |
| 645 |
% |
| 646 |
% \begin{macro}{\tocbasic@extend@babel} |
| 647 |
% \changes{v3.28}{2019/11/19}{\cs{iftocfeature} replaced by |
| 648 |
% \cs{Iftocfeature}} |
| 649 |
% \changes{v3.38}{2022/07/22}{first test feature than availability} |
| 650 |
% NOTE: To extend the original \cs{bbl@set@language} the argument of |
| 651 |
% \cs{tocbasic@extend@babel} must not be a local macro (like \cs{@currext}) |
| 652 |
% \begin{macrocode} |
| 653 |
\newcommand*{\tocbasic@extend@babel}[1]{% |
| 654 |
\Iftocfeature{#1}{nobabel}{% |
| 655 |
\PackageInfo{tocbasic}{omitting babel extension for `#1'\MessageBreak |
| 656 |
because of feature `nobabel' available\MessageBreak |
| 657 |
for `#1'}% |
| 658 |
}{% |
| 659 |
\scr@ifundefinedorrelax{bbl@set@language}{% |
| 660 |
\PackageInfo{tocbasic}{omitting babel extension for `#1'\MessageBreak |
| 661 |
because of missing \string\bbl@set@language}% |
| 662 |
}{% |
| 663 |
% \end{macrocode} |
| 664 |
% \changes{v3.23}{2017/02/23}{using \cs{BabelContentsFiles} if available} |
| 665 |
% Since version 3.9a provides adding extensions to the language switch |
| 666 |
% preparation. So it is used if it is available. |
| 667 |
% \begin{macrocode} |
| 668 |
\scr@ifundefinedorrelax{BabelContentsFiles}{% |
| 669 |
\PackageInfo{tocbasic}{setting babel extension for `#1'}% |
| 670 |
\expandafter\gdef\expandafter\bbl@set@language |
| 671 |
\expandafter##\expandafter1% |
| 672 |
\expandafter{% |
| 673 |
\bbl@set@language{##1}% |
| 674 |
\addtocontents{#1}{\xstring\select@language{\languagename}}% |
| 675 |
}% |
| 676 |
}{% |
| 677 |
\@expandtwoargs\in@{,#1,}{,\BabelContentsFiles,}% |
| 678 |
\ifin@ |
| 679 |
\PackageInfo{tocbasic}{omitting babel extension for |
| 680 |
`#1'\MessageBreak |
| 681 |
because it is already in \string\BabelContentsFiles}% |
| 682 |
\else |
| 683 |
\PackageInfo{tocbasic}{setting babel extension for `#1'}% |
| 684 |
\xdef\BabelContentsFiles{\BabelContentsFiles,#1}% |
| 685 |
\fi |
| 686 |
}% |
| 687 |
}% |
| 688 |
}% |
| 689 |
} |
| 690 |
% \end{macrocode} |
| 691 |
% This feature should be used for all toc-files (unless feature |
| 692 |
% \opt{nobabel} was set for the toc-file). |
| 693 |
% \begin{macrocode} |
| 694 |
\AtAddToTocList[]{\expandafter\tocbasic@extend@babel\expandafter{\@currext}} |
| 695 |
% \end{macrocode} |
| 696 |
% \end{macro} |
| 697 |
% |
| 698 |
% \begin{command}{\removefromtoclist} |
| 699 |
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by |
| 700 |
% \cs{kernel@ifnextchar}} |
| 701 |
% \changes{v3.22}{2016/09/06}{missing \cs{global} added} |
| 702 |
% \changes{v3.41}{2023/06/28}{using \cs{NewDocumentCommand} to not need all |
| 703 |
% the helpers} |
| 704 |
% This command will remove an extension from the list of toc-files. If the |
| 705 |
% first, optional argument is given, the extension will only be removed, if |
| 706 |
% it was added by the given owner. NOTE: An empty first argument is not the |
| 707 |
% same like omitting the first argument! |
| 708 |
% \begin{macrocode} |
| 709 |
\NewDocumentCommand\removefromtoclist{om}{% |
| 710 |
\begingroup |
| 711 |
\let\tb@oldlist\tb@listoftocs |
| 712 |
\edef\reserved@b{#2}% |
| 713 |
\global\let\tb@listoftocs\empty |
| 714 |
\def\do##1##2{% |
| 715 |
\edef\reserved@a{##1}% |
| 716 |
\ifx\reserved@a\reserved@b |
| 717 |
\IfValueT{#1}{% |
| 718 |
\begingroup |
| 719 |
\edef\@currext{##2}% |
| 720 |
\edef\reserved@b{#1}% |
| 721 |
\ifx\@currext\reserved@b |
| 722 |
\else |
| 723 |
\g@addto@macro\tb@listoftocs{\do{##1}{##2}}% |
| 724 |
\fi |
| 725 |
\endgroup |
| 726 |
}% |
| 727 |
\else |
| 728 |
\g@addto@macro\tb@listoftocs{\do{##1}{##2}}% |
| 729 |
\fi |
| 730 |
}% |
| 731 |
\tb@oldlist |
| 732 |
\endgroup |
| 733 |
} |
| 734 |
% \end{macrocode} |
| 735 |
% \end{command} |
| 736 |
% |
| 737 |
% \begin{command}{\doforeachtocfile} |
| 738 |
% \changes{v3.09}{2011/03/01}{\cs{@currext} defined using \cs{edef} instead |
| 739 |
% of \cs{def}} |
| 740 |
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by |
| 741 |
% \cs{kernel@ifnextchar}} |
| 742 |
% \changes{v3.41}{2023/06/28}{using \cs{NewDocumentCommand} to not need all |
| 743 |
% the helpers} |
| 744 |
% This command does the second, mandatory argument for each toc-file at the |
| 745 |
% list of toc-files. If the first, optional argument was given this will be |
| 746 |
% done only for the toc-files of that owner. NOTE: An empty first argument |
| 747 |
% is not the same like omitting the first argument! |
| 748 |
% While processing the second argument \cs{@currext} is the extension of |
| 749 |
% the toc-file. The second argument will be processed with increased group |
| 750 |
% level! |
| 751 |
% See \cs{addtoeachtocfile} for an example of usage of |
| 752 |
% \cs{doforeachtocfile}. |
| 753 |
% \begin{macrocode} |
| 754 |
\NewDocumentCommand\doforeachtocfile{o+m}{% |
| 755 |
\IfValueTF{#1}{% |
| 756 |
\def\do##1##2{% |
| 757 |
\edef\reserved@a{#1}\edef\reserved@b{##2}% |
| 758 |
\ifx\reserved@a\reserved@b \edef\@currext{##1}#2\fi |
| 759 |
}% |
| 760 |
}{% |
| 761 |
\def\do##1##2{\edef\@currext{##1}#2}% |
| 762 |
}% |
| 763 |
\edef\reserved@a{% |
| 764 |
\noexpand\tb@listoftocs |
| 765 |
\noexpand\def\noexpand\@currext{\@currext}% |
| 766 |
}\reserved@a |
| 767 |
% \end{macrocode} |
| 768 |
% \changes{v3.41}{2023/05/16}{don't \cs{let}\cs{do}\cs{relax}} |
| 769 |
% Former versions of \KOMAScript{} have used |\let\do\relax| to undefined |
| 770 |
% \cs{do} after the walk-through. But some packages like \pkg{dynkin-diagrams} |
| 771 |
% have had problems using \cs{renewcommand} instead of \cs{def} or \cs{let} to |
| 772 |
% change \cs{do}. So from version 3.41 \KOMAScript{} has changed this to |
| 773 |
% |\let\do\noexpand|, because this is the default of \LaTeX{} after |
| 774 |
% |\begin{document}|. However, this is only a workaround for a |
| 775 |
% workaround. Best would be to remove the final change of \cs{do}. But this |
| 776 |
% could also break packages. |
| 777 |
% \begin{macrocode} |
| 778 |
\let\do\noexpand |
| 779 |
} |
| 780 |
% \end{macrocode} |
| 781 |
% \end{command} |
| 782 |
% |
| 783 |
% \begin{command}{\addtoeachtocfile} |
| 784 |
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by |
| 785 |
% \cs{kernel@ifnextchar}} |
| 786 |
% \changes{v3.41}{2023/06/28}{using \cs{NewDocumentCommand} to not need all |
| 787 |
% the helpers} |
| 788 |
% This command calls \cs{addtocontents} with the section, mandatory |
| 789 |
% argument for each toc-file at the list of toc-files. If the first, |
| 790 |
% optional argument was given this will be done only for the toc-files of |
| 791 |
% that owner. NOTE: An empty first argument is not the same like omitting |
| 792 |
% the first argument! And don't forget to protect the commands, that should |
| 793 |
% not be expanded, at the mandatory argument. |
| 794 |
% \begin{macrocode} |
| 795 |
\NewDocumentCommand\addtoeachtocfile{o+m}{% |
| 796 |
\doforeachtocfile[{#1}]{\addtocontents{\@currext}{#2}}% |
| 797 |
} |
| 798 |
%</body> |
| 799 |
% \end{macrocode} |
| 800 |
% \end{command} |
| 801 |
% |
| 802 |
% \subsection{Adding entries into toc-files} |
| 803 |
% |
| 804 |
% We have a new general command to add entries to several toc-files at |
| 805 |
% once. And we have some special commands for the table of contents. |
| 806 |
% |
| 807 |
% \begin{command}{\addcontentslinetoeachtocfile} |
| 808 |
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by |
| 809 |
% \cs{kernel@ifnextchar}} |
| 810 |
% \changes{v3.41}{2023/06/28}{using \cs{NewDocumentCommand} to not need all |
| 811 |
% the helpers} |
| 812 |
% Something like a combination of \cs{addtoeachtocfile} and |
| 813 |
% \cs{addcontentsline}. |
| 814 |
% \begin{macrocode} |
| 815 |
%<*body> |
| 816 |
\NewDocumentCommand\addcontentslinetoeachtocfile{omm}{% |
| 817 |
\doforeachtocfile[{#1}]{\addcontentsline{\@currext}{#2}{#3}}% |
| 818 |
} |
| 819 |
% \end{macrocode} |
| 820 |
% \end{command} |
| 821 |
% |
| 822 |
% \begin{command}{\addxcontentsline} |
| 823 |
% \changes{v3.12}{2013/09/24}{added} |
| 824 |
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by |
| 825 |
% \cs{kernel@ifnextchar}} |
| 826 |
% \changes{v3.41}{2023/06/28}{using \cs{NewDocumentCommand} to not need all |
| 827 |
% the helpers} |
| 828 |
% This will be used instead of \cs{addcontentsline} to generate numbered or |
| 829 |
% not numbered entries to a toc-file. First argument is the toc-file, second |
| 830 |
% the entry type, e.g., |chapter|, the third is the entry number or empty and |
| 831 |
% the fourth and last is the entry text. |
| 832 |
% \begin{macrocode} |
| 833 |
\NewDocumentCommand\addxcontentsline{mmO{}m}{% |
| 834 |
\scr@ifundefinedorrelax{add#2#1entry}{% |
| 835 |
\tocbasic@addxcontentsline{#1}{#2}{#3}{#4}% |
| 836 |
}{% |
| 837 |
\@nameuse{add#2#1entry}{#3}{#4}% |
| 838 |
}% |
| 839 |
} |
| 840 |
% \end{macrocode} |
| 841 |
% \begin{macro}[noprint]{\@addxcontentsline} |
| 842 |
% \changes{v3.12}{2013/09/24}{added} |
| 843 |
% \changes{v3.41}{2023/06/28}{removed} |
| 844 |
% \end{macro} |
| 845 |
% \begin{command}{\nonumberline} |
| 846 |
% \changes{v3.12}{2013/09/24}{added} |
| 847 |
% Either \cs{relax} or \cs{numberline} depending on the feature |
| 848 |
% \opt{numberline}. |
| 849 |
% \begin{macrocode} |
| 850 |
\newcommand*{\nonumberline}{}% |
| 851 |
% \end{macrocode} |
| 852 |
% \end{command} |
| 853 |
% \begin{macro}{\tocbasic@addxcontentsline} |
| 854 |
% This may be used to either use a heading type command or the general default |
| 855 |
% one. You are not allowed to use it in the definition of a heading type |
| 856 |
% command like \cs{addchaptertocentry}! You may use |
| 857 |
% \cs{tocbasic@addxcontentsline} at the definition of those commands. |
| 858 |
% \begin{macrocode} |
| 859 |
\newcommand*{\tocbasic@addxcontentsline}[4]{% |
| 860 |
\IfArgIsEmpty{#3}{% |
| 861 |
\addcontentsline{#1}{#2}{\protect\nonumberline#4}% |
| 862 |
}{% |
| 863 |
\addcontentsline{#1}{#2}{\protect\numberline{#3}#4}% |
| 864 |
}% |
| 865 |
} |
| 866 |
% \end{macrocode} |
| 867 |
% \end{macro} |
| 868 |
% \end{command} |
| 869 |
% |
| 870 |
% \begin{command}{\addxcontentslinetoeachtocfile} |
| 871 |
% \changes{v3.12}{2013/09/24}{added} |
| 872 |
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by |
| 873 |
% \cs{kernel@ifnextchar}} |
| 874 |
% \changes{v3.41}{2023/06/28}{using \cs{NewDocumentCommand} to not need all |
| 875 |
% the helpers} |
| 876 |
% Similar to \cs{addcontentslinetoeachtocfile} using |
| 877 |
% \cs{addxcontentsline} instead of \cs{addcontentsline}. |
| 878 |
% \begin{macrocode} |
| 879 |
\NewDocumentCommand\addxcontentslinetoeachtocfile{omom}{% |
| 880 |
\doforeachtocfile[{#1}]{\addxcontentsline{\@currext}{#2}[{#3}]{#4}} |
| 881 |
} |
| 882 |
%</body> |
| 883 |
% \end{macrocode} |
| 884 |
% \end{command} |
| 885 |
% |
| 886 |
% \ExplSyntaxOn |
| 887 |
% \begin{macro}{\@@_chapter_patch_code:,\tocbasic@chapter@skip} |
| 888 |
% \ExplSyntaxOff |
| 889 |
% From version 3.42 \pkg*{tocbasic} provides the feature to patch |
| 890 |
% \cs{@makechapterhead} to add a vertical space to every ToC of category |
| 891 |
% \texttt{float}. From version 3.46 this is extended to also allow |
| 892 |
% patching \cs{@makeschapterhead} and the code is moved to an internal |
| 893 |
% macro. Patching of \cs{@makeschapterhead} is only supported as extension |
| 894 |
% of \cs{@makechapterhead}. |
| 895 |
% \begin{macrocode} |
| 896 |
%<*body> |
| 897 |
\if@tocbasic@old@latex@found\else |
| 898 |
\ExplSyntaxOn |
| 899 |
\cs_new:Npn \@@_chapter_patch_code: |
| 900 |
{ |
| 901 |
\cs_if_exist:NTF \KOMAClassName |
| 902 |
{ |
| 903 |
\exp_args:Nnnx \msg_warn:nnnn { tocbasic } { dangerous-patch } |
| 904 |
{ \KOMAClassName } { chapter } |
| 905 |
} |
| 906 |
{ |
| 907 |
\exp_args:Nnnx \msg_note:nnnn { tocbasic } { dangerous-patch } |
| 908 |
{ } { chapter } |
| 909 |
} |
| 910 |
\hook_gput_code:nnn { cmd/@makechapterhead/before } { tocbasic } |
| 911 |
{ |
| 912 |
\doforeachtocfile[float]{ |
| 913 |
\addtocontents{\@currext}{\tocbasic@chapter@skip} |
| 914 |
} |
| 915 |
} |
| 916 |
\bool_if:cT { g_@@_patch_chapter*_bool } |
| 917 |
{ |
| 918 |
\hook_gput_code:nnn { cmd/@makeschapterhead/before } { tocbasic } |
| 919 |
{ |
| 920 |
\doforeachtocfile[float]{ |
| 921 |
\addtocontents{\@currext}{\tocbasic@chapter@skip} |
| 922 |
} |
| 923 |
} |
| 924 |
} |
| 925 |
\ProvideDocumentCommand \tocbasic@chapter@skip { } { \addvspace{10\p@} } |
| 926 |
} |
| 927 |
\ExplSyntaxOff |
| 928 |
\fi |
| 929 |
%</body> |
| 930 |
% \end{macrocode} |
| 931 |
% \end{macro} |
| 932 |
% \ExplSyntaxOff |
| 933 |
% |
| 934 |
% |
| 935 |
% \subsection{Show list of toc-file} |
| 936 |
% \label{sec:showlistoftocfile} |
| 937 |
% |
| 938 |
% If you have a toc-file you want a list-of-command for this toc-file, |
| 939 |
% too. Here are basics and high level commands for this. |
| 940 |
% |
| 941 |
% \begin{macro}{\tocbasic@starttoc} |
| 942 |
% \changes{v3.17}{2015/03/23}{usage of feature \opt{noparskipfake}} |
| 943 |
% \changes{v3.27}{2019/07/08}{hack to add \cs{par} at end of (main) file} |
| 944 |
% \changes{v3.28}{2019/11/19}{\cs{iftocfeature} replaced by |
| 945 |
% \cs{Iftocfeature}} |
| 946 |
% \changes{v3.32}{2020/08/25}{replace \cs{par} hack by \cs{par} solution} |
| 947 |
% \changes{v3.32}{2020/08/25}{reentrant warning} |
| 948 |
% Some basics are done like setting up \cs{parskip}, \cs{parindent} and |
| 949 |
% \cs{parfillskip}, a general hook will be called, an individual hook will |
| 950 |
% be called, the toc will be started, an individual hook will be called, an |
| 951 |
% general hook wil be called, that's it. |
| 952 |
% \begin{macrocode} |
| 953 |
%<*body> |
| 954 |
%<@@=> |
| 955 |
\newcommand*{\tocbasic@starttoc}[1]{% |
| 956 |
\begingroup |
| 957 |
\tocbasic@reentrant@warning |
| 958 |
\def\tocbasic@reentrant@warning{% |
| 959 |
\PackageWarning{tocbasic}{% |
| 960 |
Loading one auxiliary file inside the setup context\MessageBreak |
| 961 |
of another auxiliary file is not recommended.\MessageBreak |
| 962 |
In this case settings for `\@currext' could also influence\MessageBreak |
| 963 |
settings of `#1' and local states of `#1' can also\MessageBreak |
| 964 |
influence local states of `\@currext'% |
| 965 |
}% |
| 966 |
}% |
| 967 |
\edef\@currext{#1}% |
| 968 |
\Iftocfeature{\@currext}{noparskipfake}{}{% |
| 969 |
\ifvmode |
| 970 |
\@tempskipa\lastskip |
| 971 |
\vskip-\lastskip |
| 972 |
\addtolength{\@tempskipa}{\parskip}% |
| 973 |
\vskip\@tempskipa |
| 974 |
\fi |
| 975 |
}% |
| 976 |
\setlength{\parskip}{\z@}% |
| 977 |
\setlength{\parindent}{\z@}% |
| 978 |
\setlength{\parfillskip}{\z@\@plus 1fil}% |
| 979 |
\csname tocbasic@@before@hook\endcsname |
| 980 |
\csname tb@#1@before@hook\endcsname |
| 981 |
\@starttoc{#1}% |
| 982 |
\BeforeClosingMainAux{% |
| 983 |
\addtocontents{#1}{% |
| 984 |
\string\providecommand\string\tocbasic@end@toc@file{}% |
| 985 |
\string\tocbasic@end@toc@file |
| 986 |
}% |
| 987 |
}% |
| 988 |
\edef\@currext{#1}% |
| 989 |
\csname tb@#1@after@hook\endcsname |
| 990 |
\csname tocbasic@@after@hook\endcsname |
| 991 |
\endgroup |
| 992 |
} |
| 993 |
% \end{macrocode} |
| 994 |
% \begin{macro}{tocbasic@end@toc@file} |
| 995 |
% \changes{v3.32}{2020/08/25}{added} |
| 996 |
% \begin{macrocode} |
| 997 |
\newcommand*{\tocbasic@end@toc@file}{\par} |
| 998 |
% \end{macrocode} |
| 999 |
% \end{macro}^^A \tocbasic@end@toc@file |
| 1000 |
% \begin{macro}{\tocbasic@reentrant@warning} |
| 1001 |
% \changes{v3.32}{2020/08/25}{added} |
| 1002 |
% \begin{macrocode} |
| 1003 |
\newcommand*{\tocbasic@reentrant@warning}{} |
| 1004 |
% \end{macrocode} |
| 1005 |
% \end{macro}^^A \tocbasic@reentrant@warning |
| 1006 |
% \begin{macro}{\tocbasic@@before@hook,\tocbasic@@after@hook} |
| 1007 |
% These are the general hooks. They may be used by classes and packages for |
| 1008 |
% commands, that should be used for all lists of not only the own lists of, |
| 1009 |
% e.\,g., \KOMAScript{} may use it to handle option \opt{tocleft}. |
| 1010 |
% \begin{macrocode} |
| 1011 |
\newcommand*{\tocbasic@@before@hook}{} |
| 1012 |
\newcommand*{\tocbasic@@after@hook}{} |
| 1013 |
% \end{macrocode} |
| 1014 |
% \end{macro}^^A \tocbasic@@before@hook,\tocbasic@@after@hook |
| 1015 |
% \begin{command}{\BeforeStartingTOC,\AfterStartingTOC} |
| 1016 |
% \changes{v3.04b}{2010/01/05}{fix:define the hook if not already defined} |
| 1017 |
% \changes{v3.06}{2010/06/09}{fix: using \cs{@ifundefined} instead of |
| 1018 |
% undefined \cs{scr@ifundefinedorrelax}} |
| 1019 |
% \changes{v3.26}{2018/08/10}{message moved to \texttt{trace}} |
| 1020 |
% These are the commands to add code to the general or individual hooks. If |
| 1021 |
% the first, optional argument was given, the second, mandatory argument |
| 1022 |
% will be added to the individual hook, otherwise the general hook will be |
| 1023 |
% extended. |
| 1024 |
% \begin{macrocode} |
| 1025 |
\newcommand{\BeforeStartingTOC}[2][]{% |
| 1026 |
\ifx\relax#1\relax |
| 1027 |
\g@addto@macro\tocbasic@@before@hook{#2}% |
| 1028 |
\else |
| 1029 |
\@ifundefined{tb@#1@before@hook}{% |
| 1030 |
%<*trace> |
| 1031 |
\PackageInfo{tocbasic}{defining new hook before starting |
| 1032 |
\IfArgIsEmpty{#1}{any toc}{`#1'}}% |
| 1033 |
%</trace> |
| 1034 |
\expandafter\global\expandafter\let\csname tb@#1@before@hook\endcsname |
| 1035 |
\@empty |
| 1036 |
}{}% |
| 1037 |
\expandafter\g@addto@macro\csname tb@#1@before@hook\endcsname{#2}% |
| 1038 |
\fi |
| 1039 |
} |
| 1040 |
\newcommand{\AfterStartingTOC}[2][]{% |
| 1041 |
\ifx\relax#1\relax |
| 1042 |
\g@addto@macro\tocbasic@@after@hook{#2}% |
| 1043 |
\else |
| 1044 |
\@ifundefined{tb@#1@after@hook}{% |
| 1045 |
%<*trace> |
| 1046 |
\PackageInfo{tocbasic}{defining new hook after starting |
| 1047 |
\IfArgIsEmpty{#1}{any toc}{`#1'}}% |
| 1048 |
%</trace> |
| 1049 |
\expandafter\global\expandafter\let\csname tb@#1@after@hook\endcsname |
| 1050 |
\@empty |
| 1051 |
}{}% |
| 1052 |
\expandafter\g@addto@macro\csname tb@#1@after@hook\endcsname{#2}% |
| 1053 |
\fi |
| 1054 |
} |
| 1055 |
%<@@=tocbasic> |
| 1056 |
% \end{macrocode} |
| 1057 |
% \end{command}^^A \BeforeStartingTOC,\AfterStartingTOC |
| 1058 |
% \end{macro}^^A \tocbasic@starttoc |
| 1059 |
% |
| 1060 |
% \begin{command}{\listoftoc} |
| 1061 |
% \changes{v3.20}{2016/04/12}{\cs{@ifstar} replaced by \cs{kernel@ifstar}} |
| 1062 |
% \begin{macro}{\@listoftoc} |
| 1063 |
% \changes{v1.0a}{2008/11/12}{\cs{twocolumn} fixed} |
| 1064 |
% \changes{v1.01}{2008/11/13}{new feature \opt{onecolumn}} |
| 1065 |
% \changes{v3.09}{2011/03/01}{\cs{@currext} defined using \cs{edef} instead |
| 1066 |
% of \cs{def}} |
| 1067 |
% \changes{v3.28}{2019/11/19}{\cs{iftocfeature} replaced by |
| 1068 |
% \cs{Iftocfeature}} |
| 1069 |
% \changes{v3.31}{2020/07/08}{use one time expansion of local |
| 1070 |
% \cs{list@fname}} |
| 1071 |
% Command to handle the hole list of something. There are additional hooks |
| 1072 |
% for this. The first optional argument is the title for this list. If the |
| 1073 |
% optional argument was omitted \cs{listof\#2name} will be used. The star |
| 1074 |
% version does not set up a heading or switch the column number! |
| 1075 |
% \begin{macrocode} |
| 1076 |
\newcommand*{\listoftoc}{% |
| 1077 |
\kernel@ifstar \tocbasic@starttoc\@listoftoc |
| 1078 |
} |
| 1079 |
\newcommand*{\@listoftoc}[2][]{% |
| 1080 |
\begingroup |
| 1081 |
\def\list@fname{#1}% |
| 1082 |
\@ifundefined{listof#2name}{% |
| 1083 |
\ifx\list@fname\@empty |
| 1084 |
\PackageWarning{tocbasic}{% |
| 1085 |
You should either define \expandafter\string\csname |
| 1086 |
listof#2name\endcsname\MessageBreak |
| 1087 |
or use the optional argument of \string\listoftoc\space\MessageBreak |
| 1088 |
to set the term to be used for the\MessageBreak |
| 1089 |
heading of list of #2}% |
| 1090 |
\def\list@fname{\listofname~#2}% |
| 1091 |
\fi |
| 1092 |
}{% |
| 1093 |
\expandafter\let\expandafter\list@fname\csname listof#2name\endcsname |
| 1094 |
}% |
| 1095 |
\edef\@currext{#2}% |
| 1096 |
\Iftocfeature{\@currext}{onecolumn}{% |
| 1097 |
\Iftocfeature{\@currext}{leveldown}{}{% |
| 1098 |
\if@twocolumn |
| 1099 |
\aftergroup\twocolumn\onecolumn |
| 1100 |
\fi |
| 1101 |
}% |
| 1102 |
}{}% |
| 1103 |
\Iftocfeature{\@currext}{numberline}{\def\nonumberline{\numberline{}}}{}% |
| 1104 |
\expandafter\tocbasic@listhead\expandafter{\list@fname}% |
| 1105 |
\scr@ifundefinedorrelax{microtypesetup}{}{% |
| 1106 |
\Iftocfeature{\@currext}{noprotrusion}{}{% |
| 1107 |
\microtypesetup{protrusion=false}% |
| 1108 |
\PackageInfo{tocbasic}{% |
| 1109 |
character protrusion at \@currext\space deactivated}% |
| 1110 |
}% |
| 1111 |
}% |
| 1112 |
\tocbasic@starttoc{#2}% |
| 1113 |
\endgroup |
| 1114 |
} |
| 1115 |
% \end{macrocode} |
| 1116 |
% \end{macro} |
| 1117 |
% \end{command} |
| 1118 |
% |
| 1119 |
% \ExplSyntaxOn |
| 1120 |
% \begin{macro}{\@@_listof_patch_code:nn} |
| 1121 |
% \ExplSyntaxOff |
| 1122 |
% \changes{v3.46}{2025/06/10}{added} |
| 1123 |
% Patch \cs{listof\#1} with extension \texttt{\#2} to use \cs{listoftoc}. |
| 1124 |
% \begin{macrocode} |
| 1125 |
\if@tocbasic@old@latex@found\else |
| 1126 |
\ExplSyntaxOn |
| 1127 |
\cs_new:Nn \@@_listof_patch_code:n |
| 1128 |
{ |
| 1129 |
\cs_set:cpn { listof#1s } { \exp_args:Nc \listoftoc { ext@#1 } } |
| 1130 |
\cs_if_exist:cF { listof \use:c { ext@#1 } name } |
| 1131 |
{ |
| 1132 |
\cs_new:cpn { listof \use:c { ext@#1 } name } |
| 1133 |
{ \use:c { list#1name } } |
| 1134 |
} |
| 1135 |
} |
| 1136 |
\ExplSyntaxOff |
| 1137 |
\fi |
| 1138 |
% \end{macrocode} |
| 1139 |
% \end{macro} |
| 1140 |
% \ExplSyntaxOff |
| 1141 |
% |
| 1142 |
% \changes{v3.25}{2017/11/21}{\pkg{tocbibind} warning added} |
| 1143 |
% \changes{v3.46}{2025/06/16}{revert to \cs{IfPackageLoadedTF} instead of |
| 1144 |
% \cs{IfPackageLoadedF} and \cs{IfPackageLoadedT}, because in \LaTeX{} |
| 1145 |
% 2022-06-01 is only the first one available} |
| 1146 |
% Using \pkg{tocbibind} and \pkg*{tocbasic} together can break features |
| 1147 |
% either of \pkg{tocbibind} or \pkg*{tocbasic}. Here we add at least a |
| 1148 |
% warning: |
| 1149 |
% \begin{macrocode} |
| 1150 |
\IfPackageLoadedTF{tocbibind}{}{% |
| 1151 |
\AtBeginDocument{% |
| 1152 |
\IfPackageLoadedTF{tocbibind}{% |
| 1153 |
\PackageInfo{tocbasic}{usage of `tocbibind' detected}% |
| 1154 |
\newcommand*{\tb@tocbibindpatch}[3]{% |
| 1155 |
\long\def\reserved@a{\tocfile{#2}{#1} }% |
| 1156 |
\ifx #3\reserved@a |
| 1157 |
\PackageWarningNoLine{tocbasic}{% |
| 1158 |
`tocbibind' redefinition of `\string#3'\MessageBreak |
| 1159 |
detected.\MessageBreak |
| 1160 |
Note: Loading `tocbibind' without option `not#1'\MessageBreak |
| 1161 |
can break several features of `tocbasic'% |
| 1162 |
\scr@ifundefinedorrelax{KOMAClassName}{% |
| 1163 |
.\MessageBreak |
| 1164 |
Loading `tocbibind' before `tocbasic' would avoid\MessageBreak |
| 1165 |
this warning message% |
| 1166 |
}{}% |
| 1167 |
}% |
| 1168 |
\fi |
| 1169 |
}% |
| 1170 |
\tb@tocbibindpatch{toc}{\contentsname}{\tableofcontents}% |
| 1171 |
\tb@tocbibindpatch{lof}{\listfigurename}{\listoffigures}% |
| 1172 |
\tb@tocbibindpatch{lot}{\listtablename}{\listoftables}% |
| 1173 |
}{}% |
| 1174 |
}% |
| 1175 |
} |
| 1176 |
% \end{macrocode} |
| 1177 |
% |
| 1178 |
% \begin{command}{\listofname} |
| 1179 |
% While this is only an emergency command, we don't support languages. |
| 1180 |
% \begin{macrocode} |
| 1181 |
\newcommand*{\listofname}{List of} |
| 1182 |
% \end{macrocode} |
| 1183 |
% \end{command} |
| 1184 |
% |
| 1185 |
% \begin{command}{\listofeachtoc} |
| 1186 |
% \changes{v3.03b}{2009/06/08}{typo fix at usage of \cs{doforeachtocfile}} |
| 1187 |
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by |
| 1188 |
% \cs{kernel@ifnextchar}} |
| 1189 |
% \changes{v3.41}{2023/06/28}{using \cs{NewDocumentCommand} to not need all |
| 1190 |
% the helpers} |
| 1191 |
% Another example of using \cs{doforeachtocfile}. |
| 1192 |
% \begin{macrocode} |
| 1193 |
\NewDocumentCommand\listofeachtoc{o}{% |
| 1194 |
\doforeachtocfile[{#1}]{\listoftoc{\@currext}}% |
| 1195 |
} |
| 1196 |
% \end{macrocode} |
| 1197 |
% \end{command} |
| 1198 |
% |
| 1199 |
% \begin{macro}{\ext@toc} |
| 1200 |
% \changes{v3.23}{2017/02/23}{use indirect extension for toc} |
| 1201 |
% We do not longer hard code extension \file{toc} for the table of |
| 1202 |
% contents. This allowes users to change it. Classes or other packages may |
| 1203 |
% also define it. So it seems to be better to \cs{providecommand} instead of |
| 1204 |
% \cs{newcommand} here. |
| 1205 |
% \begin{macrocode} |
| 1206 |
\providecommand*{\ext@toc}{toc} |
| 1207 |
% \end{macrocode} |
| 1208 |
% \end{macro} |
| 1209 |
% |
| 1210 |
% \begin{macro}{\tocbasic@listhead} |
| 1211 |
% \changes{v3.02a}{2009/01/20}{no explicite marks if ``numbered''} |
| 1212 |
% \changes{v3.09a}{2011/04/12}{again no explicite marks if ``numbered''} |
| 1213 |
% \changes{v3.12}{2013/09/24}{usage of new \cs{tocbasic@addxcontentsline}} |
| 1214 |
% \changes{v3.15}{2014/12/10}{moved \cs{@mkboth} inside \cs{chapter*}} |
| 1215 |
% \changes{v3.15}{2014/12/10}{usage of \cs{addsec} if available} |
| 1216 |
% \changes{v3.15}{2014/12/10}{usage of \cs{@mkright} if available} |
| 1217 |
% \changes{v3.17}{2015/03/08}{moved \cs{@mkboth} outside \cs{chapter*}} |
| 1218 |
% \changes{v3.17}{2015/03/08}{usage of \cs{@mkdouble} if available} |
| 1219 |
% \changes{v3.17}{2015/03/25}{penalty and skip reconstruction after |
| 1220 |
% \cs{@mkright}, \cs{@mkboth}, or \cs{@mkdouble}} |
| 1221 |
% \changes{v3.26}{2018/06/22}{removed spurious group} |
| 1222 |
% \changes{v3.26}{2018/09/03}{usage of \cs{addsecmark} or \cs{sectionmark} |
| 1223 |
% instead of \cs{@mkright} or \cs{markright}} |
| 1224 |
% \changes{v3.28}{2019/11/19}{\cs{iftocfeature} replaced by |
| 1225 |
% \cs{Iftocfeature}} |
| 1226 |
% Setting the headings of a list of something. The heading is the only |
| 1227 |
% argument. |
| 1228 |
% \begin{macrocode} |
| 1229 |
%<@@=> |
| 1230 |
\newcommand*{\tocbasic@listhead}[1]{% |
| 1231 |
\@ifundefined{tocbasic@listhead@\@currext}{% |
| 1232 |
\scr@ifundefinedorrelax{chapter}{% |
| 1233 |
\expandafter\def\csname tocbasic@listhead@\@currext\endcsname##1{% |
| 1234 |
\Iftocfeature{\@currext}{leveldown}{% |
| 1235 |
\Iftocfeature{\@currext}{numbered}{% |
| 1236 |
\subsection[##1]{##1}% |
| 1237 |
}{% |
| 1238 |
\subsection*{##1}% |
| 1239 |
\ifvmode\@tempcnta\lastpenalty\@tempskipa\lastskip\unskip\fi |
| 1240 |
\begingroup |
| 1241 |
\Iftocfeature{\@currext}{totoc}{% |
| 1242 |
\expandafter\addxcontentsline\expandafter{\ext@toc}% |
| 1243 |
{subsection}{##1}% |
| 1244 |
}{}% |
| 1245 |
\c@secnumdepth=-\maxdimen |
| 1246 |
\subsectionmark{##1}% |
| 1247 |
\endgroup |
| 1248 |
\ifvmode\penalty\@tempcnta\vskip\@tempskipa\fi |
| 1249 |
}% |
| 1250 |
}{% |
| 1251 |
\Iftocfeature{\@currext}{numbered}{% |
| 1252 |
\section[##1]{##1}% |
| 1253 |
}{% |
| 1254 |
\section*{##1}% |
| 1255 |
\ifvmode\@tempcnta\lastpenalty\@tempskipa\lastskip\unskip\fi |
| 1256 |
\begingroup |
| 1257 |
\Iftocfeature{\@currext}{totoc}{% |
| 1258 |
\expandafter\addxcontentsline\expandafter{\ext@toc}% |
| 1259 |
{section}{##1}% |
| 1260 |
}{}% |
| 1261 |
\@ifundefined{@mkdouble}{% |
| 1262 |
\@mkboth{\MakeMarkcase{##1}}{\MakeMarkcase{##1}}% |
| 1263 |
}{% |
| 1264 |
\@mkdouble{\MakeMarkcase{##1}}% |
| 1265 |
}% |
| 1266 |
\endgroup |
| 1267 |
\ifvmode\penalty\@tempcnta\vskip\@tempskipa\fi |
| 1268 |
}% |
| 1269 |
}% |
| 1270 |
}% |
| 1271 |
}{% |
| 1272 |
\expandafter\def\csname tocbasic@listhead@\@currext\endcsname##1{% |
| 1273 |
\Iftocfeature{\@currext}{leveldown}{% |
| 1274 |
\Iftocfeature{\@currext}{numbered}{% |
| 1275 |
\section{##1}% |
| 1276 |
}{% |
| 1277 |
\Iftocfeature{\@currext}{totoc}{% |
| 1278 |
\@ifundefined{addsec}{% |
| 1279 |
\section*{##1}% |
| 1280 |
\ifvmode\@tempcnta\lastpenalty\@tempskipa\lastskip\unskip\fi |
| 1281 |
\begingroup |
| 1282 |
\@ifundefined{@mkright}{% |
| 1283 |
\IfActiveMkBoth{\markright{\MakeMarkcase{##1}}}{}% |
| 1284 |
}{% |
| 1285 |
\@mkright{\MakeMarkcase{##1}}% |
| 1286 |
}% |
| 1287 |
\expandafter\addxcontentsline\expandafter{\ext@toc}% |
| 1288 |
{section}{##1}% |
| 1289 |
\endgroup |
| 1290 |
\ifvmode\penalty\@tempcnta\vskip\@tempskipa\fi |
| 1291 |
}{% |
| 1292 |
\addsec{##1}% |
| 1293 |
}% |
| 1294 |
}{% |
| 1295 |
\section*{##1}% |
| 1296 |
\ifvmode\@tempcnta\lastpenalty\@tempskipa\lastskip\unskip\fi |
| 1297 |
\begingroup |
| 1298 |
\@ifundefined{addsecmark}{% |
| 1299 |
\c@secnumdepth=-\maxdimen |
| 1300 |
\sectionmark{##1}% |
| 1301 |
}{% |
| 1302 |
\addsecmark{##1}% |
| 1303 |
}% |
| 1304 |
\endgroup |
| 1305 |
\ifvmode\penalty\@tempcnta\vskip\@tempskipa\fi |
| 1306 |
}% |
| 1307 |
}% |
| 1308 |
}{% |
| 1309 |
\Iftocfeature{\@currext}{numbered}{% |
| 1310 |
\chapter[##1]{##1}% |
| 1311 |
}{% |
| 1312 |
\chapter*{##1}% |
| 1313 |
\ifvmode\@tempcnta\lastpenalty\@tempskipa\lastskip\unskip\fi |
| 1314 |
\begingroup |
| 1315 |
\@ifundefined{@mkdouble}{% |
| 1316 |
\@mkboth{\MakeMarkcase{##1}}{\MakeMarkcase{##1}}% |
| 1317 |
}{% |
| 1318 |
\@mkdouble{\MakeMarkcase{##1}}% |
| 1319 |
}% |
| 1320 |
\Iftocfeature{\@currext}{totoc}{% |
| 1321 |
\expandafter\addxcontentsline\expandafter{\ext@toc}% |
| 1322 |
{chapter}{##1}% |
| 1323 |
}{}% |
| 1324 |
\endgroup |
| 1325 |
\ifvmode\penalty\@tempcnta\vskip\@tempskipa\fi |
| 1326 |
}% |
| 1327 |
}% |
| 1328 |
}% |
| 1329 |
}% |
| 1330 |
}{}% |
| 1331 |
\csname tb@@beforehead@hook\endcsname |
| 1332 |
\csname tb@\@currext @beforehead@hook\endcsname |
| 1333 |
\csname tocbasic@listhead@\@currext\endcsname{#1}% |
| 1334 |
\csname tb@\@currext @afterhead@hook\endcsname |
| 1335 |
\csname tb@@afterhead@hook\endcsname |
| 1336 |
} |
| 1337 |
%<@@=tocbasic> |
| 1338 |
% \end{macrocode} |
| 1339 |
% \begin{command}{\BeforeTOCHead,\AfterTOCHead} |
| 1340 |
% \changes{v3.04b}{2010/01/05}{fix: define the hook if not already defined} |
| 1341 |
% \changes{v3.06}{2010/06/09}{fix: using \cs{@ifundefined} instead of |
| 1342 |
% undefined \cs{scr@ifundefinedorrelax}} |
| 1343 |
% \changes{v3.26}{2018/08/10}{message moved to \texttt{trace}} |
| 1344 |
% These are the commands to add code to the general or individual hooks. If |
| 1345 |
% the first, optional argument was given, the second, mandatory argument |
| 1346 |
% will be added to the individual hook, otherwise the general hook will be |
| 1347 |
% extended. |
| 1348 |
% \begin{macrocode} |
| 1349 |
\newcommand{\BeforeTOCHead}[2][]{% |
| 1350 |
\@ifundefined{tb@#1@beforehead@hook}{% |
| 1351 |
%<*trace> |
| 1352 |
\PackageInfo{tocbasic}{defining new hook before heading of |
| 1353 |
\IfArgIsEmpty{#1}{each toc}{`#1'}}% |
| 1354 |
%</trace> |
| 1355 |
\expandafter\global\expandafter\let\csname tb@#1@beforehead@hook\endcsname |
| 1356 |
\@empty |
| 1357 |
}{}% |
| 1358 |
\expandafter\g@addto@macro\csname tb@#1@beforehead@hook\endcsname{#2}% |
| 1359 |
} |
| 1360 |
\newcommand{\AfterTOCHead}[2][]{% |
| 1361 |
\@ifundefined{tb@#1@afterhead@hook}{% |
| 1362 |
%<*trace> |
| 1363 |
\PackageInfo{tocbasic}{defining new hook after heading of |
| 1364 |
\IfArgIsEmpty{#1}{each toc}{`#1'}}% |
| 1365 |
%</trace> |
| 1366 |
\expandafter\global\expandafter\let\csname tb@#1@afterhead@hook\endcsname |
| 1367 |
\@empty |
| 1368 |
}{}% |
| 1369 |
\expandafter\g@addto@macro\csname tb@#1@afterhead@hook\endcsname{#2}% |
| 1370 |
} |
| 1371 |
%</body> |
| 1372 |
% \end{macrocode} |
| 1373 |
% \end{command} |
| 1374 |
% \end{macro} |
| 1375 |
% |
| 1376 |
% \begin{command}{\MakeMarkcase} |
| 1377 |
% Use upper-case or not? |
| 1378 |
% \begin{macrocode} |
| 1379 |
%<*exit> |
| 1380 |
\AtBeginDocument{% |
| 1381 |
\@ifundefined{MakeMarkcase}{% |
| 1382 |
\scr@ifundefinedorrelax{KOMAClassName}{% |
| 1383 |
\let\MakeMarkcase\MakeUppercase |
| 1384 |
}{% |
| 1385 |
\let\MakeMarkcase\@firstofone |
| 1386 |
}% |
| 1387 |
}{}% |
| 1388 |
} |
| 1389 |
%</exit> |
| 1390 |
% \end{macrocode} |
| 1391 |
% \end{command} |
| 1392 |
% |
| 1393 |
% \begin{command}{\deftocheading} |
| 1394 |
% Define a toc headings command with one argument (the title). |
| 1395 |
% \begin{macrocode} |
| 1396 |
%<*body> |
| 1397 |
\newcommand*{\deftocheading}[1]{% |
| 1398 |
\@namedef{tocbasic@listhead@#1}##1} |
| 1399 |
% \end{macrocode} |
| 1400 |
% \end{command} |
| 1401 |
% |
| 1402 |
% \begin{command}{\setuptoc,\unsettoc} |
| 1403 |
% \changes{v3.26}{2018/08/29}{using \cs{scr@trim@spaces} instead of |
| 1404 |
% \cs{tb@@sp@def}} |
| 1405 |
% Known features are: |
| 1406 |
% \begin{description} |
| 1407 |
% \item[\opt{totoc}] writes the title of the list of to the table of |
| 1408 |
% contents |
| 1409 |
% \item[\opt{numberline}] redefines \cs{nonumberline} to use |
| 1410 |
% \cs{numberline} |
| 1411 |
% \item[\opt{numbered}] uses a numbered headings for the list of |
| 1412 |
% \item[\opt{leveldown}] uses not the top level heading (e.\,g., |
| 1413 |
% \cs{chapter} with book) but the first sub level (e.\,g., \cs{section} with |
| 1414 |
% book). |
| 1415 |
% \item[\opt{nobabel}] prevents the extension to be added to the babel |
| 1416 |
% handling of toc-files. To make this work, you have to set the feature |
| 1417 |
% before adding the extension to the list of known extension. |
| 1418 |
% \item[\opt{noprotrusion}] prevents disabling character protrusion at |
| 1419 |
% the toc. |
| 1420 |
% \end{description} |
| 1421 |
% Other features may be package dependent. You may test the feature using: |
| 1422 |
% \begin{quote} |
| 1423 |
% \cs{@ifundefined}\texttt{\{tocbasic@\meta{toc}@feature@\meta{feature}\}}\\ |
| 1424 |
% \phantom{\cs{@ifundefined}}\marg{do if feature not set}\\ |
| 1425 |
% \phantom{\cs{@ifundefined}}\marg{do if feature set} |
| 1426 |
% \end{quote} |
| 1427 |
% See \cs{tocbasic@listhead} for an example of this. |
| 1428 |
% \begin{macrocode} |
| 1429 |
\newcommand*{\setuptoc}[2]{% |
| 1430 |
\@for\@tempa:=#2\do{% |
| 1431 |
\scr@trim@spaces\@tempa |
| 1432 |
\@namedef{tocbasic@#1@feature@\@tempa}{}% |
| 1433 |
}% |
| 1434 |
} |
| 1435 |
\newcommand*{\unsettoc}[2]{% |
| 1436 |
\@for\@tempa:=#2\do{% |
| 1437 |
\scr@trim@spaces\@tempa |
| 1438 |
\expandafter\let\csname tocbasic@#1@feature@\@tempa\endcsname\relax |
| 1439 |
}% |
| 1440 |
} |
| 1441 |
% \end{macrocode} |
| 1442 |
% Do not add the files, that babel handles by default. |
| 1443 |
% \begin{macrocode} |
| 1444 |
\setuptoc{toc}{nobabel} |
| 1445 |
\setuptoc{lof}{nobabel} |
| 1446 |
\setuptoc{lot}{nobabel} |
| 1447 |
% \end{macrocode} |
| 1448 |
% \begin{command}{\Iftocfeature,\iftocfeature} |
| 1449 |
% \changes{v3.28}{2019/11/19}{\cs{iftocfeature} renamed to \cs{Iftocfeature}} |
| 1450 |
% We need a test for the features |
| 1451 |
% \begin{macrocode} |
| 1452 |
%<*deprecated> |
| 1453 |
\providecommand*{\iftocfeature}{% |
| 1454 |
\PackageWarning{tocbasic}{Usage of deprecated command |
| 1455 |
`\string\iftocfeature'.\MessageBreak |
| 1456 |
The command has been renamed because of a\MessageBreak |
| 1457 |
recommendation of The LaTeX Project Team.\MessageBreak |
| 1458 |
Please replace `\string\iftocfeature' by `\string\Iftocfeature'% |
| 1459 |
}% |
| 1460 |
\Iftocfeature |
| 1461 |
} |
| 1462 |
%</deprecated> |
| 1463 |
\newcommand*{\Iftocfeature}[2]{% |
| 1464 |
\scr@ifundefinedorrelax{tocbasic@#1@feature@#2}{% |
| 1465 |
\expandafter\@secondoftwo |
| 1466 |
}{% |
| 1467 |
\expandafter\@firstoftwo |
| 1468 |
}% |
| 1469 |
} |
| 1470 |
%</body> |
| 1471 |
% \end{macrocode} |
| 1472 |
% \end{command} |
| 1473 |
% \end{command} |
| 1474 |
% |
| 1475 |
% \begin{command}{\tocbasicautomode} |
| 1476 |
% \changes{v1.0a}{2008/11/11}{use of \cs{addtotoclist} instead of |
| 1477 |
% internal} |
| 1478 |
% \changes{v3.07a}{2010/11/25}{fix: added missing |
| 1479 |
% \cs{let}\cs{@starttoc}\cs{tocbasic@starttoc}} |
| 1480 |
% \changes{v3.28}{2019/11/19}{\cs{ifattoclist} replaced by |
| 1481 |
% \cs{Ifattoclist}} |
| 1482 |
% \pkg*{tocbasic} can overtake \cs{@starttoc} to automaticly add all |
| 1483 |
% used extensions to the list of known extensions and use |
| 1484 |
% \cs{tocbasic@starttoc} instead of \cs{@starttoc} from \LaTeX{} |
| 1485 |
% kernel. Please note, that we don't need a fix for the unfriendly |
| 1486 |
% redefinition of \cs{@starttoc} by \pkg{hyperref}, because hyperref |
| 1487 |
% does it only at the first \LaTeX{} run. So this action of \pkg{hyperref} |
| 1488 |
% may only result in the need of one more \LaTeX{} run, but not in a permanent |
| 1489 |
% mistake. |
| 1490 |
% \begin{macrocode} |
| 1491 |
%<*body> |
| 1492 |
\newcommand*{\tocbasicautomode}{% |
| 1493 |
\let\tb@saved@starttoc\@starttoc |
| 1494 |
\let\@starttoc\tocbasic@starttoc |
| 1495 |
\BeforeStartingTOC{% |
| 1496 |
\let\@starttoc\tb@saved@starttoc |
| 1497 |
\expandafter\Ifattoclist\expandafter{\@currext}{}{% |
| 1498 |
\addtotoclist[tocbasicautomode]{\@currext}% |
| 1499 |
}% |
| 1500 |
}% |
| 1501 |
} |
| 1502 |
%</body> |
| 1503 |
% \end{macrocode} |
| 1504 |
% \end{command} |
| 1505 |
% |
| 1506 |
% |
| 1507 |
% \subsection{High level interface for generating new ToCs and floats resp. nonfloats} |
| 1508 |
% \label{sec:newfloats} |
| 1509 |
% |
| 1510 |
% \begin{command}{\DeclareNewTOC} |
| 1511 |
% \changes{v3.06}{2010/06/01}{added} |
| 1512 |
% \changes{v3.18}{2015/06/20}{\cs{tb@nt@types} and \cs{tb@nt@listname} are |
| 1513 |
% initialised \cs{relax}} |
| 1514 |
% \changes{v3.20}{2016/04/12}{\cs{@ifnextchar} replaced by |
| 1515 |
% \cs{kernel@ifnextchar}} |
| 1516 |
% \changes{v3.26a}{2018/12/30}{fixed usage of \cs{kernel@ifnextchar}} |
| 1517 |
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}} |
| 1518 |
% This command defines only a new TOC and a new caption command for this |
| 1519 |
% TOC. It does not define a new foat unless option float was set! It does |
| 1520 |
% not define a new nonfloat unless option nonfloat was set! The optional |
| 1521 |
% argument is used to set up several settings using \pkg{keyval}. The |
| 1522 |
% mandatory argument is the shortcut. The default type is the shortcut. |
| 1523 |
% The extension is the shortcut. The default owner is ``\texttt{float}''. |
| 1524 |
% \begin{macrocode} |
| 1525 |
%<*body> |
| 1526 |
\DefineFamily{KOMAarg} |
| 1527 |
\DefineFamilyMember[.toc]{KOMAarg} |
| 1528 |
\newcommand*{\DeclareNewTOC}[2][]{% |
| 1529 |
\newif\iftb@nt@float |
| 1530 |
\newif\iftb@nt@nonfloat |
| 1531 |
\newif\iftb@nt@forcenames |
| 1532 |
\def\tb@nt@floattype{\tb@nt@autofloattype}% |
| 1533 |
\def\tb@nt@floatpos{tbp}% |
| 1534 |
\def\tb@nt@ext{#2}% |
| 1535 |
\edef\tb@nt@type{#2}% |
| 1536 |
\let\tb@nt@types\relax |
| 1537 |
\def\tb@nt@owner{float}% |
| 1538 |
% \end{macrocode} |
| 1539 |
% \begin{description} |
| 1540 |
% \item[ToDo:] We still do not use \cs{MakeTitlecase} of \LaTeX{} from |
| 1541 |
% 2022/06/01~PL\,5 here (and later), because \pkg{hyperref} 2022-06-20 |
| 1542 |
% v7.00s is still not able to process it. So we would get a warning message |
| 1543 |
% instead of switching to uppercase. But maybe in some future, this could be |
| 1544 |
% changed. |
| 1545 |
% \end{description} |
| 1546 |
% \begin{macrocode} |
| 1547 |
\def\tb@nt@name{\expandafter\protect\expandafter\MakeUppercase\tb@nt@type}% |
| 1548 |
\let\tb@nt@listname\relax |
| 1549 |
\let\tb@nt@counterwithin\@empty |
| 1550 |
\let\tb@nt@atbegin\@empty |
| 1551 |
\let\tb@nt@atend\@empty |
| 1552 |
\def\tb@nt@tocentrystyle{default}% |
| 1553 |
% \end{macrocode} |
| 1554 |
% \changes{v3.20}{2016/04/29}{need more initialization for empty optional |
| 1555 |
% argument} |
| 1556 |
% \begin{macrocode} |
| 1557 |
\def\tb@nt@tocstyle@options{level=1}% |
| 1558 |
\IfArgIsEmpty{#1}{% |
| 1559 |
% \end{macrocode} |
| 1560 |
% Also need to call the style init code, to set the defaults for options |
| 1561 |
% \opt{numwidth} and \opt{indent}. |
| 1562 |
% \begin{macrocode} |
| 1563 |
\begingroup |
| 1564 |
\let\scr@dte@current\tb@nt@type |
| 1565 |
\@ExecuteTOCEntryStyleInitCode{\tb@nt@tocentrystyle}{\tb@nt@type}% |
| 1566 |
\def\do@endgroup{\endgroup}% |
| 1567 |
\def\do##1{% |
| 1568 |
\Ifstr{##1}{numwidth}{% |
| 1569 |
\l@addto@macro\do@endgroup{% |
| 1570 |
\l@addto@macro{\tb@nt@tocstyle@options}{,numwidth=1.5em}% |
| 1571 |
}% |
| 1572 |
}{% |
| 1573 |
\Ifstr{##1}{indent}{% |
| 1574 |
%<trace> \PackageInfo{tocbasic}{% |
| 1575 |
%<trace> TRACE \string\DeclareNewTOC[...]{#2}: |
| 1576 |
%<trace> set default indent 1em}% |
| 1577 |
\l@addto@macro\do@endgroup{% |
| 1578 |
\l@addto@macro{\tb@nt@tocstyle@options}{,indent=1em}% |
| 1579 |
}% |
| 1580 |
}{}% |
| 1581 |
}% |
| 1582 |
\kernel@ifnextchar[%] |
| 1583 |
{\@dodefault}% |
| 1584 |
{}% |
| 1585 |
}% |
| 1586 |
\def\@dodefault[##1]{}% |
| 1587 |
\scr@dte@doopts |
| 1588 |
\do@endgroup |
| 1589 |
}{% |
| 1590 |
\let\tb@nt@extra@relax@opts\@empty |
| 1591 |
% \end{macrocode} |
| 1592 |
% After initialisation of the local values we need to know the style of the |
| 1593 |
% toc entry, to define style dependend options. |
| 1594 |
% \begin{macro}{\tb@nt@type} |
| 1595 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1596 |
% The type of list is used for environment and counter names and as part of |
| 1597 |
% several internal and user macros. It is needed before defining the style |
| 1598 |
% dependend options. So we use a first run to set it up. |
| 1599 |
% \begin{macrocode} |
| 1600 |
\DefineFamilyKey[.toc]{KOMAarg}{type}{% |
| 1601 |
\tb@ifvalueisnotempty{##1}{\edef\tb@nt@type{##1}}% |
| 1602 |
}% |
| 1603 |
% \end{macrocode} |
| 1604 |
% \end{macro} |
| 1605 |
% \begin{macro}{\tb@nt@tocentrystyle} |
| 1606 |
% \changes{v3.20}{2015/12/16}{added} |
| 1607 |
% The style of the toc entry. It is needed before defining the style |
| 1608 |
% dependend options. So we use a first run to set it up. |
| 1609 |
% \begin{macrocode} |
| 1610 |
\DefineFamilyKey[.toc]{KOMAarg}{tocentrystyle}[default]{% |
| 1611 |
\IfArgIsEmpty{##1}{% |
| 1612 |
\edef\tb@nt@tocentrystyle{##1}% |
| 1613 |
\FamilyKeyStateProcessed |
| 1614 |
}{% |
| 1615 |
\scr@ifundefinedorrelax{scr@dte@def@l@##1}{% |
| 1616 |
\FamilyKeyStateUnknownValue |
| 1617 |
}{% |
| 1618 |
\edef\tb@nt@tocentrystyle{##1}% |
| 1619 |
\FamilyKeyStateProcessed |
| 1620 |
}% |
| 1621 |
}% |
| 1622 |
}% |
| 1623 |
% \end{macrocode} |
| 1624 |
% \end{macro} |
| 1625 |
% \begin{macro}{\tb@nt@ext} |
| 1626 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1627 |
% \changes{v3.25}{2017/11/20}{moved to pass 1} |
| 1628 |
% Don't tell the user, that the mandatory argument of the command may be |
| 1629 |
% overloaded by this option. This was only done to simplify the definition. |
| 1630 |
% \begin{macrocode} |
| 1631 |
\DefineFamilyKey[.toc]{KOMAarg}{extension}{% |
| 1632 |
\tb@ifvalueisnotempty{##1}{\edef\tb@nt@ext{##1}}% |
| 1633 |
}% |
| 1634 |
% \end{macrocode} |
| 1635 |
% \end{macro} |
| 1636 |
% \begin{macro}{\tb@nt@owner} |
| 1637 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1638 |
% \changes{v3.26}{2018/06/09}{moved to pass 1} |
| 1639 |
% \changes{v3.27}{2019/05/12}{\opt{category} is a synonym for \opt{owner}} |
| 1640 |
% The owner of the new list extension. |
| 1641 |
% \begin{macrocode} |
| 1642 |
\DefineFamilyKey[.toc]{KOMAarg}{owner}{% |
| 1643 |
\tb@ifvalueisnotempty{##1}{\edef\tb@nt@owner{##1}}% |
| 1644 |
}% |
| 1645 |
\DefineFamilyKey[.toc]{KOMAarg}{category}{% |
| 1646 |
\tb@ifvalueisnotempty{##1}{\edef\tb@nt@owner{##1}}% |
| 1647 |
}% |
| 1648 |
% \end{macrocode} |
| 1649 |
% \end{macro} |
| 1650 |
% After this we define pseudo option \opt{@else@} to ignore all currently |
| 1651 |
% not needed options. After this we do the first option execution run. |
| 1652 |
% \begin{macrocode} |
| 1653 |
\DefineFamilyKey[.toc]{KOMAarg}{@else@}{\FamilyKeyStateProcessed}% |
| 1654 |
\FamilyExecuteOptions[.toc]{KOMAarg}{#1}% |
| 1655 |
\RelaxFamilyKey[.toc]{KOMAarg}{@else@}% |
| 1656 |
% \end{macrocode} |
| 1657 |
% \changes{v3.26}{2018/06/09}{add extension already after first pass} |
| 1658 |
% First of all, every TOC needs an extension, that should be added to the |
| 1659 |
% list of known extensions. This has to be done also, if no options has been |
| 1660 |
% given! |
| 1661 |
% \begin{macrocode} |
| 1662 |
}% |
| 1663 |
\expandafter\newcommand\csname ext@\tb@nt@type\endcsname{}% |
| 1664 |
\expandafter\let\csname ext@\tb@nt@type\endcsname\tb@nt@ext |
| 1665 |
\addtotoclist[\tb@nt@owner]{\csname ext@\tb@nt@type\endcsname}% |
| 1666 |
\IfArgIsEmpty{#1}{}{% |
| 1667 |
% \end{macrocode} |
| 1668 |
% For the second option pass we do not need to set up these options |
| 1669 |
% again. So define it as no-opt. |
| 1670 |
% \begin{macrocode} |
| 1671 |
\DefineFamilyKey[.toc]{KOMAarg}{type}{\FamilyKeyStateProcessed}% |
| 1672 |
\DefineFamilyKey[.toc]{KOMAarg}{tocentrystyle}{\FamilyKeyStateProcessed}% |
| 1673 |
\DefineFamilyKey[.toc]{KOMAarg}{extension}{\FamilyKeyStateProcessed}% |
| 1674 |
\DefineFamilyKey[.toc]{KOMAarg}{category}{\FamilyKeyStateProcessed}% |
| 1675 |
% \end{macrocode} |
| 1676 |
% \changes{v3.20}{2015/12/16}{defining toc style depending options} |
| 1677 |
% \changes{v3.20}{2016/06/12}{using prefix \opt{tocentry} instead of |
| 1678 |
% \opt{toc}} |
| 1679 |
% \changes{v3.27}{2019/10/02}{additional \opt{:}-options} |
| 1680 |
% If the toc style is empty we won't define any \cs{l@\dots}. Otherwise we |
| 1681 |
% need to define additional options. |
| 1682 |
% \begin{macrocode} |
| 1683 |
\Ifstr{\tb@nt@tocentrystyle}{}{}{% |
| 1684 |
\begingroup |
| 1685 |
\let\scr@dte@current\tb@nt@type |
| 1686 |
\@ExecuteTOCEntryStyleInitCode{\tb@nt@tocentrystyle}{\tb@nt@type}% |
| 1687 |
\def\do@endgroup{\endgroup}% |
| 1688 |
\def\do##1{% |
| 1689 |
\l@addto@macro\do@endgroup{% |
| 1690 |
\l@addto@macro\tb@nt@extra@relax@opts{% |
| 1691 |
\RelaxFamilyKey[.toc]{KOMAarg}{toc##1}% |
| 1692 |
\RelaxFamilyKey[.toc]{KOMAarg}{tocentry##1}% |
| 1693 |
\RelaxFamilyKey[.toc]{KOMAarg}{tocentry##1:}% |
| 1694 |
}% |
| 1695 |
}% |
| 1696 |
\kernel@ifnextchar[%] |
| 1697 |
{\@dodefault{##1}}% |
| 1698 |
{\@donodefault{##1}}% |
| 1699 |
}% |
| 1700 |
\def\@donodefault##1{% |
| 1701 |
\l@addto@macro\do@endgroup{% |
| 1702 |
\DefineFamilyKey[.toc]{KOMAarg}{toc##1}{% |
| 1703 |
\PackageWarning{tocbasic}{you should use `tocentry##1' |
| 1704 |
instead\MessageBreak |
| 1705 |
of `toc##1'}% |
| 1706 |
\l@addto@macro{\tb@nt@tocstyle@options}{,##1={####1}}% |
| 1707 |
\FamilyKeyStateProcessed |
| 1708 |
}% |
| 1709 |
\DefineFamilyKey[.toc]{KOMAarg}{tocentry##1}{% |
| 1710 |
\l@addto@macro{\tb@nt@tocstyle@options}{,##1={####1}}% |
| 1711 |
\FamilyKeyStateProcessed |
| 1712 |
}% |
| 1713 |
\DefineFamilyKey[.toc]{KOMAarg}{tocentry##1:}{% |
| 1714 |
\l@addto@macro{\tb@nt@tocstyle@options}{,##1:={####1}}% |
| 1715 |
}% |
| 1716 |
}% |
| 1717 |
}% |
| 1718 |
\def\@dodefault##1[##2]{% |
| 1719 |
\l@addto@macro\do@endgroup{% |
| 1720 |
\DefineFamilyKey[.toc]{KOMAarg}{toc##1}[##2]{% |
| 1721 |
\PackageWarning{tocbasic}{you should use `tocentry##1' |
| 1722 |
instead\MessageBreak |
| 1723 |
of `toc##1'}% |
| 1724 |
\l@addto@macro{\tb@nt@tocstyle@options}{,##1={####1}}% |
| 1725 |
\FamilyKeyStateProcessed |
| 1726 |
}% |
| 1727 |
\DefineFamilyKey[.toc]{KOMAarg}{tocentry##1}[##2]{% |
| 1728 |
\l@addto@macro{\tb@nt@tocstyle@options}{,##1={####1}}% |
| 1729 |
\FamilyKeyStateProcessed |
| 1730 |
}% |
| 1731 |
\DefineFamilyKey[.toc]{KOMAarg}{tocentry##1:}{% |
| 1732 |
\l@addto@macro{\tb@nt@tocstyle@options}{,##1:={####1}}% |
| 1733 |
}% |
| 1734 |
}% |
| 1735 |
}% |
| 1736 |
\scr@dte@doopts |
| 1737 |
\do@endgroup |
| 1738 |
}% |
| 1739 |
% \end{macrocode} |
| 1740 |
% After this, we need to define all the other options and do the real option |
| 1741 |
% execution. |
| 1742 |
% \begin{macro}{\tb@nt@atbegin} |
| 1743 |
% \changes{v3.09}{2011/03/01}{new optional identifier \opt{atbegin}} |
| 1744 |
% \changes{v3.11c}{2013/02/01}{\opt{atbegin} argument may be empty} |
| 1745 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1746 |
% Additional code executed at the begin of a new defined environment. |
| 1747 |
% \begin{macrocode} |
| 1748 |
\FamilyStringKey[.toc]{KOMAarg}{atbegin}{\tb@nt@atbegin}% |
| 1749 |
% \end{macrocode} |
| 1750 |
% \end{macro} |
| 1751 |
% \begin{macro}{\tb@nt@atend} |
| 1752 |
% \changes{v3.09}{2011/03/01}{new optional identifier \opt{atbend}} |
| 1753 |
% \changes{v3.11c}{2013/02/01}{\opt{atend} argument may be empty} |
| 1754 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1755 |
% Additional code executed at the end of a new defined environment. |
| 1756 |
% \begin{macrocode} |
| 1757 |
\FamilyStringKey[.toc]{KOMAarg}{atend}{\tb@nt@atend}% |
| 1758 |
% \end{macrocode} |
| 1759 |
% \end{macro} |
| 1760 |
% \begin{macro}{\tb@nt@counterwithin} |
| 1761 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1762 |
% If a counter will be defined, this counter may depend on another counter |
| 1763 |
% (like figure counter depends on chapter counter at book classes). If the |
| 1764 |
% value is empty, the counter does not depend on any other counter. |
| 1765 |
% \begin{macrocode} |
| 1766 |
\DefineFamilyKey[.toc]{KOMAarg}{counterwithin}{% |
| 1767 |
\edef\tb@nt@counterwithin{##1}\FamilyKeyStateProcessed |
| 1768 |
}% |
| 1769 |
% \end{macrocode} |
| 1770 |
% \end{macro} |
| 1771 |
% \begin{macro}{\iftb@nt@float} |
| 1772 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1773 |
% \changes{v3.06}{2010/06/01}{added} |
| 1774 |
% This boolean indicates, that float environments should also be defined. |
| 1775 |
% \begin{macrocode} |
| 1776 |
\FamilyBoolKey[.toc]{KOMAarg}{float}{tb@nt@float}% |
| 1777 |
% \end{macrocode} |
| 1778 |
% \end{macro} |
| 1779 |
% \begin{macro}{\tb@nt@floatpos} |
| 1780 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1781 |
% Simply the value for the |\fps@...| macro. |
| 1782 |
% \begin{macrocode} |
| 1783 |
\DefineFamilyKey[.toc]{KOMAarg}{floatpos}{% |
| 1784 |
\tb@ifvalueisnotempty{##1}{\edef\tb@nt@floatpos{##1}}% |
| 1785 |
}% |
| 1786 |
% \end{macrocode} |
| 1787 |
% \end{macro} |
| 1788 |
% \begin{macro}{\tb@nt@floattype} |
| 1789 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1790 |
% Simply the value for the |\ftype@...| macro. It has to be |
| 1791 |
% $1<=\textrm{value}<=31$. |
| 1792 |
% \begin{macrocode} |
| 1793 |
\DefineFamilyKey[.toc]{KOMAarg}{floattype}{% |
| 1794 |
\FamilySetCounterMacro{KOMAarg}{floattype}{\reserved@d}{##1}% |
| 1795 |
\ifx\FamilyKeyState\FamilyKeyStateProcessed |
| 1796 |
\ifnum 0= |
| 1797 |
\ifnum\reserved@d<1 0 \else\ifnum\reserved@d>31 0 \else 1 \fi\fi |
| 1798 |
\FamilyKeyStateUnknownValue |
| 1799 |
\else |
| 1800 |
\let\tb@nt@floattype\reserved@d |
| 1801 |
\fi |
| 1802 |
\fi |
| 1803 |
}% |
| 1804 |
% \end{macrocode} |
| 1805 |
% \end{macro} |
| 1806 |
% \begin{macro}{\iftb@nt@forcenames} |
| 1807 |
% \changes{v3.06}{2010/06/01}{added} |
| 1808 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1809 |
% The |\...name| commands will only be defined, if they are not already |
| 1810 |
% defined. But some users may want to define their own names even if there |
| 1811 |
% are already definitions. So this boolean option may switch to force the |
| 1812 |
% definition. |
| 1813 |
% \begin{macrocode} |
| 1814 |
\FamilyBoolKey[.toc]{KOMAarg}{forcenames}{tb@nt@forcenames}% |
| 1815 |
% \end{macrocode} |
| 1816 |
% \end{macro} |
| 1817 |
% \begin{macro}[noprint]{\tb@nt@hang} |
| 1818 |
% \changes{v3.20}{2015/12/16}{removed} |
| 1819 |
% \end{macro} |
| 1820 |
% Earch entry of a TOC/list of is idented on the left side. This is the |
| 1821 |
% amount of the indention of the text of the entry. |
| 1822 |
% \begin{macrocode} |
| 1823 |
%<*deprecated> |
| 1824 |
\DefineFamilyKey[.toc]{KOMAarg}{hang}{% |
| 1825 |
\scr@ifundefinedorrelax{[email protected]@tocnumwidth}{% |
| 1826 |
\PackageWarning{tocbasic}{% |
| 1827 |
deprecated option `hang'.\MessageBreak |
| 1828 |
Option will be ignored, because toc entry style\MessageBreak |
| 1829 |
`\tb@nt@tocentrystyle' does not provide option `numwidth'% |
| 1830 |
}% |
| 1831 |
}{% |
| 1832 |
\PackageWarning{tocbasic}{% |
| 1833 |
deprecated option `hang'.\MessageBreak |
| 1834 |
You should replace option `hang' by option\MessageBreak |
| 1835 |
`tocentrynumwidth'% |
| 1836 |
}% |
| 1837 |
\l@addto@macro\tb@nt@tocstyle@options{,numwidth={##1}}% |
| 1838 |
}% |
| 1839 |
\FamilyKeyStateProcessed |
| 1840 |
}% |
| 1841 |
%</deprecated> |
| 1842 |
\scr@ifundefinedorrelax{[email protected]@tocnumwidth}{}{% |
| 1843 |
\l@addto@macro\tb@nt@tocstyle@options{,numwidth=1.5em}% |
| 1844 |
}% |
| 1845 |
% \end{macrocode} |
| 1846 |
% \begin{macro}[noprint]{\tb@nt@indent} |
| 1847 |
% \changes{v3.20}{2015/12/16}{removed} |
| 1848 |
% \end{macro} |
| 1849 |
% Earch entry of a TOC/list of is idented on the left side. This is the |
| 1850 |
% amount of the indention of the number part. |
| 1851 |
% \begin{macrocode} |
| 1852 |
%<*deprecated> |
| 1853 |
\DefineFamilyKey[.toc]{KOMAarg}{indent}{% |
| 1854 |
\scr@ifundefinedorrelax{[email protected]@tocindent}{% |
| 1855 |
\PackageWarning{tocbasic}{% |
| 1856 |
deprecated option `indent'.\MessageBreak |
| 1857 |
Option will be ignored, because toc entry style\MessageBreak |
| 1858 |
`\tb@nt@tocentrystyle' does not provide option `indent'% |
| 1859 |
}% |
| 1860 |
}{% |
| 1861 |
\PackageWarning{tocbasic}{% |
| 1862 |
deprecated option `indent'.\MessageBreak |
| 1863 |
You should replace option `indent' by option\MessageBreak |
| 1864 |
`tocentryindent'% |
| 1865 |
}% |
| 1866 |
\l@addto@macro\tb@nt@tocstyle@options{,indent={##1}}% |
| 1867 |
}% |
| 1868 |
\FamilyKeyStateProcessed |
| 1869 |
}% |
| 1870 |
%</deprecated> |
| 1871 |
\scr@ifundefinedorrelax{[email protected]@tocindent}{}{% |
| 1872 |
%<trace> \PackageInfo{tocbasic}{% |
| 1873 |
%<trace> TRACE \string\DeclareNewTOC[...]{#2}: set default indent 1em}% |
| 1874 |
\l@addto@macro\tb@nt@tocstyle@options{,indent=1em}% |
| 1875 |
}% |
| 1876 |
% \end{macrocode} |
| 1877 |
% \begin{macro}[noprint]{\tb@nt@level} |
| 1878 |
% \changes{v3.20}{2015/12/16}{removed} |
| 1879 |
% \end{macro} |
| 1880 |
% \changes{v3.30}{2020/02/25}{spurious space in warning message removed} |
| 1881 |
% Each entry to a TOC/list of has a numeric level. You may set up your own |
| 1882 |
% level. |
| 1883 |
% \begin{macrocode} |
| 1884 |
%<*deprecated> |
| 1885 |
\DefineFamilyKey[.toc]{KOMAarg}{level}{% |
| 1886 |
\PackageWarning{tocbasic}{% |
| 1887 |
deprecated option `level'.\MessageBreak |
| 1888 |
You should replace option `level' by option\MessageBreak |
| 1889 |
`tocentrylevel'% |
| 1890 |
}% |
| 1891 |
\l@addto@macro\tb@nt@tocstyle@options{,level={##1}}% |
| 1892 |
\FamilyKeyStateProcessed |
| 1893 |
}% |
| 1894 |
%</deprecated> |
| 1895 |
% \end{macrocode} |
| 1896 |
% \begin{macro}{\tb@nt@listname} |
| 1897 |
% \changes{v3.18}{2015/06/20}{using \cs{def} instead of \cs{edef}} |
| 1898 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1899 |
% The list itself has a heading. A |\list<type>name| will also be defined. |
| 1900 |
% \begin{macrocode} |
| 1901 |
\DefineFamilyKey[.toc]{KOMAarg}{listname}{% |
| 1902 |
\tb@ifvalueisnotempty{##1}{\def\tb@nt@listname{##1}}% |
| 1903 |
}% |
| 1904 |
% \end{macrocode} |
| 1905 |
% \end{macro} |
| 1906 |
% \begin{macro}{\tb@nt@name} |
| 1907 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1908 |
% We need a name/term for the entries of the new list. This may e.\,g. be used |
| 1909 |
% for |caption| output. A |\<type>name| will also be defined. |
| 1910 |
% \begin{macrocode} |
| 1911 |
\DefineFamilyKey[.toc]{KOMAarg}{name}{% |
| 1912 |
\tb@ifvalueisnotempty{##1}{\edef\tb@nt@name{##1}}% |
| 1913 |
}% |
| 1914 |
% \end{macrocode} |
| 1915 |
% \end{macro} |
| 1916 |
% \begin{macro}{\iftb@nt@nonfloat} |
| 1917 |
% \changes{v3.06}{2010/06/01}{added} |
| 1918 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1919 |
% This boolean indicates, that non-float environment should also be |
| 1920 |
% defined. The environment has the postfix ``-''. |
| 1921 |
% \begin{macrocode} |
| 1922 |
\FamilyBoolKey[.toc]{KOMAarg}{nonfloat}{tb@nt@nonfloat}% |
| 1923 |
% \end{macrocode} |
| 1924 |
% \end{macro} |
| 1925 |
% \begin{macro}{\tb@nt@types} |
| 1926 |
% \changes{v3.20}{2015/12/16}{locally valid only} |
| 1927 |
% Sometimes the plural of the type is needed and may be defined by a |
| 1928 |
% seperate option. |
| 1929 |
% \begin{macrocode} |
| 1930 |
\DefineFamilyKey[.toc]{KOMAarg}{types}{% |
| 1931 |
\tb@ifvalueisnotempty{##1}{\edef\tb@nt@types{##1}}% |
| 1932 |
}% |
| 1933 |
% \end{macrocode} |
| 1934 |
% \end{macro} |
| 1935 |
% \changes{v3.25}{2017/11/20}{option \opt{setup} added} |
| 1936 |
% The new option \opt{setup} allowes to setup ToC features provided by |
| 1937 |
% \cs{setuptoc}. Note, currently there is no test whether or not a feature |
| 1938 |
% does exist! |
| 1939 |
% \begin{macrocode} |
| 1940 |
\DefineFamilyKey[.toc]{KOMAarg}{setup}{% |
| 1941 |
\setuptoc\tb@nt@ext{##1}% |
| 1942 |
}% |
| 1943 |
% \end{macrocode} |
| 1944 |
% \changes{v3.25}{2017/11/20}{option \opt{unset} added} |
| 1945 |
% The new option \opt{unset} allowes to unset ToC features provided |
| 1946 |
% by \cs{unsettoc}. Note, currently there is no test whether or not a |
| 1947 |
% feature does exist! |
| 1948 |
% \begin{macrocode} |
| 1949 |
\DefineFamilyKey[.toc]{KOMAarg}{unset}{% |
| 1950 |
\unsettoc\tb@nt@ext{##1}% |
| 1951 |
}% |
| 1952 |
% \end{macrocode} |
| 1953 |
% Last but not least we have to execute the options and reset the option |
| 1954 |
% definitions. |
| 1955 |
% \changes{v3.25}{2017/09/27}{\opt{nonfloat} fixed} |
| 1956 |
% \changes{v3.26}{2018/06/09}{added missing reset of \opt{unset} and |
| 1957 |
% \opt{setup}} |
| 1958 |
% \begin{macrocode} |
| 1959 |
\FamilyExecuteOptions[.toc]{KOMAarg}{#1}% |
| 1960 |
\RelaxFamilyKey[.toc]{KOMAarg}{unset}% |
| 1961 |
\RelaxFamilyKey[.toc]{KOMAarg}{setup}% |
| 1962 |
\RelaxFamilyKey[.toc]{KOMAarg}{types}% |
| 1963 |
\RelaxFamilyKey[.toc]{KOMAarg}{nonfloat}% |
| 1964 |
\RelaxFamilyKey[.toc]{KOMAarg}{name}% |
| 1965 |
\RelaxFamilyKey[.toc]{KOMAarg}{listname}% |
| 1966 |
\RelaxFamilyKey[.toc]{KOMAarg}{level}% |
| 1967 |
\RelaxFamilyKey[.toc]{KOMAarg}{indent}% |
| 1968 |
\RelaxFamilyKey[.toc]{KOMAarg}{hang}% |
| 1969 |
\RelaxFamilyKey[.toc]{KOMAarg}{forcenames}% |
| 1970 |
\RelaxFamilyKey[.toc]{KOMAarg}{floatpos}% |
| 1971 |
\RelaxFamilyKey[.toc]{KOMAarg}{float}% |
| 1972 |
\RelaxFamilyKey[.toc]{KOMAarg}{counterwithin}% |
| 1973 |
\RelaxFamilyKey[.toc]{KOMAarg}{atend}% |
| 1974 |
\RelaxFamilyKey[.toc]{KOMAarg}{atbegin}% |
| 1975 |
\tb@nt@extra@relax@opts |
| 1976 |
\RelaxFamilyKey[.toc]{KOMAarg}{category}% |
| 1977 |
\RelaxFamilyKey[.toc]{KOMAarg}{owner}% |
| 1978 |
\RelaxFamilyKey[.toc]{KOMAarg}{extension}% |
| 1979 |
\RelaxFamilyKey[.toc]{KOMAarg}{tocentrystyle}% |
| 1980 |
\RelaxFamilyKey[.toc]{KOMAarg}{type}% |
| 1981 |
}% |
| 1982 |
% \end{macrocode} |
| 1983 |
% We save the type of the extension at \cs{tb@nt@type@\meta{extension}} |
| 1984 |
% for later usage. |
| 1985 |
% \begin{macrocode} |
| 1986 |
\expandafter\let\csname tb@nt@type@\tb@nt@ext\endcsname\tb@nt@type |
| 1987 |
% \end{macrocode} |
| 1988 |
% Then we need the TOC itself with a name: |
| 1989 |
% \changes{v3.25}{2017/10/10}{use \cs{ext@\dots} instead of the extension |
| 1990 |
% itself in definition of \cs{listof\dots}} |
| 1991 |
% \begin{macrocode} |
| 1992 |
\scr@ifundefinedorrelax{tb@nt@types}{% |
| 1993 |
\edef\tb@nt@types{\tb@nt@type s}% |
| 1994 |
}{}% |
| 1995 |
\scr@ifundefinedorrelax{tb@nt@listname}{% |
| 1996 |
\protected@edef\tb@nt@listname{List of \protect\MakeUppercase\tb@nt@types}% |
| 1997 |
}{}% |
| 1998 |
\@ifundefined{\tb@nt@type name}{% |
| 1999 |
\expandafter\protected@edef\csname \tb@nt@type name\endcsname{\tb@nt@name}% |
| 2000 |
}{% |
| 2001 |
\iftb@nt@forcenames |
| 2002 |
\expandafter\protected@edef\csname \tb@nt@type name\endcsname |
| 2003 |
{\tb@nt@name}% |
| 2004 |
\fi |
| 2005 |
}% |
| 2006 |
\@ifundefined{list\tb@nt@type name}{% |
| 2007 |
\expandafter\let\csname list\tb@nt@type name\endcsname\tb@nt@listname |
| 2008 |
}{% |
| 2009 |
\iftb@nt@forcenames |
| 2010 |
\expandafter\let\csname list\tb@nt@type name\endcsname\tb@nt@listname |
| 2011 |
\fi |
| 2012 |
}% |
| 2013 |
\expandafter\newcommand\csname listof\tb@nt@ext name\expandafter\endcsname |
| 2014 |
\expandafter{\csname list\tb@nt@type name\endcsname}% |
| 2015 |
\begingroup\edef\@tempa{\endgroup |
| 2016 |
\noexpand\newcommand*\csname listof\tb@nt@types\endcsname{% |
| 2017 |
\noexpand\listoftoc{% |
| 2018 |
\expandafter\noexpand\csname ext@\tb@nt@type\endcsname}% |
| 2019 |
}% |
| 2020 |
}\@tempa |
| 2021 |
% \end{macrocode} |
| 2022 |
% The list entry: |
| 2023 |
% \changes{v3.20}{2016/04/05}{warning if \cs{l@\dots} is undefined} |
| 2024 |
% \begin{macrocode} |
| 2025 |
\Ifstr{\tb@nt@tocentrystyle}{}{% |
| 2026 |
\@ifundefined{l@\tb@nt@type}{% |
| 2027 |
\PackageWarning{tocbasic}{% |
| 2028 |
\expandafter\string\csname l@\tb@nt@type\endcsname\space |
| 2029 |
undefined!\MessageBreak |
| 2030 |
I hope you know, what you are doing, but\MessageBreak |
| 2031 |
maybe it would be better to use proper\MessageBreak |
| 2032 |
`tocentrystyle' settings% |
| 2033 |
}% |
| 2034 |
}{}% |
| 2035 |
}{% |
| 2036 |
\edef\reserved@a{% |
| 2037 |
\noexpand\DeclareTOCStyleEntry[% |
| 2038 |
{\unexpanded\expandafter{\tb@nt@tocstyle@options}}% |
| 2039 |
]{\tb@nt@tocentrystyle}{\tb@nt@type}% |
| 2040 |
}% |
| 2041 |
\reserved@a |
| 2042 |
}% |
| 2043 |
% \end{macrocode} |
| 2044 |
% \changes{v3.12}{2013/05/03}{fixed: definition of |
| 2045 |
% \cs{listof\meta{type}entryname} added as explained in the manual} |
| 2046 |
% \begin{macrocode} |
| 2047 |
\@ifundefined{listof\tb@nt@ext entryname}{% |
| 2048 |
\expandafter\let\csname listof\tb@nt@ext entryname\endcsname\tb@nt@name |
| 2049 |
}{}% |
| 2050 |
% \end{macrocode} |
| 2051 |
% The setup command: |
| 2052 |
% \begin{macrocode} |
| 2053 |
\begingroup\edef\@tempa{\endgroup |
| 2054 |
\noexpand\newcommand*\csname setup\tb@nt@types\endcsname{% |
| 2055 |
\noexpand\setuptoc{\tb@nt@ext}% |
| 2056 |
}% |
| 2057 |
}\@tempa |
| 2058 |
\@tempswafalse |
| 2059 |
% \end{macrocode} |
| 2060 |
% The float environments: |
| 2061 |
% \changes{v3.09a}{2011/05/30}{fixed: floats may have an optional argument} |
| 2062 |
% \changes{v3.12}{2013/12/10}{fixed: usage of default placement} |
| 2063 |
% \changes{v3.46}{2025/06/13}{keys definition added} |
| 2064 |
% \begin{macrocode} |
| 2065 |
\iftb@nt@float |
| 2066 |
\expandafter\newcommand\expandafter*\csname fps@\tb@nt@type\expandafter |
| 2067 |
\endcsname\expandafter{\tb@nt@floatpos}% |
| 2068 |
\expandafter\newcommand\expandafter*\csname ftype@\tb@nt@type\expandafter |
| 2069 |
\endcsname\expandafter{\tb@nt@floattype}% |
| 2070 |
\begingroup |
| 2071 |
\edef\@tempa{% |
| 2072 |
\noexpand\endgroup |
| 2073 |
\noexpand\newenvironment{\tb@nt@type}{% |
| 2074 |
\noexpand\kernel@ifnextchar[%] |
| 2075 |
{\noexpand\tb@atbegin@after\noexpand\@float{\tb@nt@type}}% |
| 2076 |
{\noexpand\edef\noexpand\reserved@a{% |
| 2077 |
\noexpand\noexpand\noexpand\tb@atbegin@after |
| 2078 |
\noexpand\noexpand\noexpand\@float{\tb@nt@type}% |
| 2079 |
[\noexpand\csname fps@\tb@nt@type\noexpand\endcsname]}% |
| 2080 |
\noexpand\reserved@a}% |
| 2081 |
}{% |
| 2082 |
\noexpand\csname \tb@nt@type @atend\noexpand\endcsname |
| 2083 |
\noexpand\end@float |
| 2084 |
}% |
| 2085 |
\noexpand\newenvironment{\tb@nt@type*}{% |
| 2086 |
\noexpand\kernel@ifnextchar[%] |
| 2087 |
{\noexpand\tb@atbegin@after\noexpand\@dblfloat{\tb@nt@type}}% |
| 2088 |
{\noexpand\edef\noexpand\reserved@a{% |
| 2089 |
\noexpand\noexpand\noexpand\tb@atbegin@after |
| 2090 |
\noexpand\noexpand\noexpand\@dblfloat{\tb@nt@type}% |
| 2091 |
[\noexpand\csname fps@\tb@nt@type\noexpand\endcsname]}% |
| 2092 |
\noexpand\reserved@a}% |
| 2093 |
}{% |
| 2094 |
\noexpand\csname \tb@nt@type @atend\noexpand\endcsname |
| 2095 |
\noexpand\end@dblfloat |
| 2096 |
}% |
| 2097 |
\if@tocbasic@old@latex@found\else |
| 2098 |
\expandafter\noexpand\csname tocbasic_define_caption_keys:n\endcsname |
| 2099 |
{\tb@nt@type}% |
| 2100 |
\fi |
| 2101 |
}% |
| 2102 |
\@tempa |
| 2103 |
\@tempswatrue |
| 2104 |
\fi |
| 2105 |
% \end{macrocode} |
| 2106 |
% The nonfloat environment: |
| 2107 |
% \begin{macrocode} |
| 2108 |
\iftb@nt@nonfloat |
| 2109 |
\begingroup |
| 2110 |
\edef\@tempa{% |
| 2111 |
\noexpand\endgroup |
| 2112 |
\noexpand\newenvironment{\tb@nt@type-}{% |
| 2113 |
\noexpand\trivlist\noexpand\item\noexpand\relax |
| 2114 |
\noexpand\minipage{\noexpand\linewidth}% |
| 2115 |
\noexpand\def\noexpand\@captype{\tb@nt@type}% |
| 2116 |
\noexpand\csname \tb@nt@type @atbegin\noexpand\endcsname |
| 2117 |
}{% |
| 2118 |
\noexpand\csname \tb@nt@type @atend\noexpand\endcsname |
| 2119 |
\noexpand\endminipage\noexpand\endtrivlist |
| 2120 |
}% |
| 2121 |
\if@tocbasic@old@latex@found\else |
| 2122 |
\expandafter\noexpand\csname tocbasic_define_caption_keys:n\endcsname |
| 2123 |
{\tb@nt@type}% |
| 2124 |
\fi |
| 2125 |
}% |
| 2126 |
\@tempa |
| 2127 |
\@tempswatrue |
| 2128 |
\fi |
| 2129 |
% \end{macrocode} |
| 2130 |
% The counter and hooks of float and nonfloat environments: |
| 2131 |
% \changes{v3.10b}{2012/04/04}{\cs{noexpand} added to fix problems using |
| 2132 |
% \cs{autodot}} |
| 2133 |
% \changes{v3.13}{2014/07/31}{add \cs{autodot} only to hierachical |
| 2134 |
% counters} |
| 2135 |
% \changes{v3.35}{2021/10/12}{ignore \opt{counterwithin} if it is |
| 2136 |
% ``\texttt{chapter}'' resp. ``\texttt{section}'' and \cs{if@mainmatter} is |
| 2137 |
% not \cs{iffalse} and the counterwithin counter is < 1} |
| 2138 |
% \changes{v3.37}{2022/05/24}{mainmatter test fixed} |
| 2139 |
% \begin{macrocode} |
| 2140 |
\if@tempswa |
| 2141 |
\@ifundefined{c@\tb@nt@type}{% |
| 2142 |
\newcounter{\tb@nt@type}% |
| 2143 |
}{% |
| 2144 |
\PackageWarning{tocbasic}{using already defined counter `\tb@nt@type'}% |
| 2145 |
}% |
| 2146 |
\ifx\tb@nt@counterwithin\@empty\else |
| 2147 |
\@addtoreset{\tb@nt@type}{\tb@nt@counterwithin}% |
| 2148 |
\begingroup |
| 2149 |
\def\reserved@c{section}% |
| 2150 |
\@ifundefined{chapter}{}{% |
| 2151 |
\@ifundefined{c@chapter}{}{% |
| 2152 |
\@ifundefined{l@chapter}{}{% |
| 2153 |
\def\reserved@c{chapter}}}}% |
| 2154 |
\expandafter\Ifstr\expandafter{\reserved@c}{\tb@nt@counterwithin}{% |
| 2155 |
\edef\@tempa{% |
| 2156 |
\noexpand\endgroup |
| 2157 |
\noexpand\renewcommand*\expandafter\noexpand |
| 2158 |
\csname the\tb@nt@type\endcsname{% |
| 2159 |
\unexpanded{% |
| 2160 |
\expandafter\ifx\csname if@mainmatter\expandafter\endcsname |
| 2161 |
\csname iffalse\endcsname\else |
| 2162 |
}% |
| 2163 |
\noexpand\ifnum |
| 2164 |
\expandafter\noexpand\csname c@\tb@nt@counterwithin\endcsname |
| 2165 |
>\noexpand\z@ |
| 2166 |
\expandafter\noexpand\csname the\tb@nt@counterwithin\endcsname |
| 2167 |
.% |
| 2168 |
\noexpand\fi |
| 2169 |
\noexpand\fi |
| 2170 |
\noexpand\arabic{\tb@nt@type}% |
| 2171 |
}% |
| 2172 |
}% |
| 2173 |
}{% |
| 2174 |
\edef\@tempa{% |
| 2175 |
\noexpand\endgroup |
| 2176 |
\noexpand\renewcommand*\expandafter\noexpand |
| 2177 |
\csname the\tb@nt@type\endcsname{% |
| 2178 |
\expandafter\noexpand\csname the\tb@nt@counterwithin\endcsname |
| 2179 |
.% |
| 2180 |
\noexpand\arabic{\tb@nt@type}% |
| 2181 |
}% |
| 2182 |
}% |
| 2183 |
}% |
| 2184 |
\@tempa |
| 2185 |
\fi |
| 2186 |
\begingroup |
| 2187 |
\edef\@tempa{% |
| 2188 |
\noexpand\endgroup |
| 2189 |
\noexpand\newcommand*\expandafter\noexpand |
| 2190 |
\csname \tb@nt@type format\endcsname{% |
| 2191 |
\expandafter\noexpand\csname \tb@nt@type name\endcsname |
| 2192 |
\noexpand\nobreakspace |
| 2193 |
\expandafter\noexpand\csname the\tb@nt@type\endcsname |
| 2194 |
\ifx\tb@nt@counterwithin\@empty\else |
| 2195 |
\noexpand\csname autodot\endcsname |
| 2196 |
\fi |
| 2197 |
}% |
| 2198 |
\noexpand\newcommand*\expandafter\noexpand |
| 2199 |
\csname fnum@\tb@nt@type\endcsname{% |
| 2200 |
\expandafter\noexpand\csname \tb@nt@type format\endcsname |
| 2201 |
}% |
| 2202 |
}% |
| 2203 |
\@tempa |
| 2204 |
\expandafter\newcommand\expandafter*\csname \tb@nt@type @atbegin\expandafter |
| 2205 |
\endcsname\expandafter{\tb@nt@atbegin}% |
| 2206 |
\expandafter\newcommand\expandafter*\csname \tb@nt@type @atend\expandafter |
| 2207 |
\endcsname\expandafter{\tb@nt@atend}% |
| 2208 |
\fi |
| 2209 |
} |
| 2210 |
% \end{macrocode} |
| 2211 |
% \begin{macro}{\tb@atbegin@after} |
| 2212 |
% \changes{v3.09a}{2011/05/30}{added} |
| 2213 |
% Processes command \#1 with argument \#2 and optional argument \#3 and than |
| 2214 |
% \verb|\csname #2@atbegin\endcsname|. This is used to add |
| 2215 |
% \verb|csname #2@atbegin\endcsname| at begin part of a float (but after |
| 2216 |
% optional argument of the float). |
| 2217 |
% \begin{macrocode} |
| 2218 |
\newcommand*{\tb@atbegin@after}[3]{} |
| 2219 |
\def\tb@atbegin@after#1#2[#3]{% |
| 2220 |
#1{#2}[#3]% |
| 2221 |
\csname #2@atbegin\endcsname |
| 2222 |
} |
| 2223 |
% \end{macrocode} |
| 2224 |
% \end{macro} |
| 2225 |
% \begin{macro}{\tb@ifvalueisnotempty} |
| 2226 |
% \changes{v3.06}{2010/05/21}{added} |
| 2227 |
% \changes{v3.20}{2015/12/16}{simpler definition} |
| 2228 |
% \changes{v3.28}{2019/11/18}{\cs{ifstr} renamed to \cs{Ifstr}} |
| 2229 |
% This is only a helper for defining some of the keys. |
| 2230 |
% \begin{macrocode} |
| 2231 |
\newcommand*{\tb@ifvalueisnotempty}[1]{% |
| 2232 |
\Ifstr{#1}{}{% |
| 2233 |
\FamilyKeyStateUnknownValue |
| 2234 |
\expandafter\@gobble |
| 2235 |
}{% |
| 2236 |
\FamilyKeyStateProcessed |
| 2237 |
\expandafter\@firstofone |
| 2238 |
}% |
| 2239 |
} |
| 2240 |
% \end{macrocode} |
| 2241 |
% \end{macro} |
| 2242 |
% \begin{macro}[noprint]{\tb@boolkey,\tb@dimkey,\tb@numkey} |
| 2243 |
% \changes{v3.06}{2010/05/21}{added} |
| 2244 |
% \changes{v3.20}{2015/12/16}{removed} |
| 2245 |
% \end{macro} |
| 2246 |
% \begin{macro}{\tb@nt@autofloattype} |
| 2247 |
% \changes{v3.06}{2010/06/01}{added} |
| 2248 |
% This macro saves the float type for auto generated float types. |
| 2249 |
% \begin{macrocode} |
| 2250 |
\newcommand*{\tb@nt@autofloattype}{16} |
| 2251 |
%</body> |
| 2252 |
% \end{macrocode} |
| 2253 |
% \end{macro} |
| 2254 |
% \end{command} |
| 2255 |
% |
| 2256 |
% \subsection{Caption handling} |
| 2257 |
% |
| 2258 |
% \changes{v3.46}{2025/06/10}{\pkg*{tocbasic} handles captions} |
| 2259 |
% From version 3.46 package \pkg*{tocbasic} not only supports but provides the |
| 2260 |
% caption handling that was formerly part of the \KOMAScript{} classes. This |
| 2261 |
% allows us also a (partial) redesign of the implementation. Nevertheless, we |
| 2262 |
% try to keep it compatible. When package \pkg{caption} is loaded, most of the |
| 2263 |
% features are delegated to that package. |
| 2264 |
% |
| 2265 |
% \ExplSyntaxOn |
| 2266 |
% \begin{macro}{\g_@@__caption_above_bool} |
| 2267 |
% \ExplSyntaxOff |
| 2268 |
% \changes{v3.46}{2025/06/13}{added} |
| 2269 |
% The default formation for captions should above (instead of below) the |
| 2270 |
% content. This has to be predefined, because |
| 2271 |
% \cs{tocbasic\_define\_caption\_keys:n} does not automatically define |
| 2272 |
% it. The initial value is \optvalue{false}. |
| 2273 |
% \begin{macrocode} |
| 2274 |
%<*option> |
| 2275 |
\if@tocbasic@old@latex@found\else |
| 2276 |
\ExplSyntaxOn |
| 2277 |
\bool_new:N \g_@@__caption_above_bool |
| 2278 |
% \end{macrocode} |
| 2279 |
% \end{macro} |
| 2280 |
% \begin{command}{\tocbasic_define_caption_keys:n} |
| 2281 |
% \ExplSyntaxOff |
| 2282 |
% \changes{v3.46}{2025/06/13}{added} |
| 2283 |
% Allows to define the boolean looking choice options \opt{\#1captionabove} |
| 2284 |
% and \opt{\#1captionbelow} and the choice options \opt{\#1captionposition} |
| 2285 |
% with the three values \optvalue{top}, \optvalue{bottom} and |
| 2286 |
% \optvalue{default}. Value \optvalue{default} resets the caption position |
| 2287 |
% for \texttt{\#1} to the default caption position. If \texttt{\#1} is |
| 2288 |
% empty, the default value is not defined! The code not only respects |
| 2289 |
% package \pkg{caption} but actively supports its use. This is the main |
| 2290 |
% reason, why it cannot use real boolean options, but needs to simulate them |
| 2291 |
% using choice options. The code looks complicated because resetting the |
| 2292 |
% \pkg{caption} options for floats is different for \env{figures} and |
| 2293 |
% \env{tables} than for other floats. Also resetting \pkg{caption} options |
| 2294 |
% of single floats needs an extra command (at least after |
| 2295 |
% \verb|\begin{document}|). |
| 2296 |
% \begin{macrocode} |
| 2297 |
\cs_new:Nn \tocbasic_define_caption_keys:n |
| 2298 |
{ |
| 2299 |
\keys_if_exist:nnF { tocbasic } { #1captionabove } |
| 2300 |
{ |
| 2301 |
\keys_define:nn { tocbasic } |
| 2302 |
{ |
| 2303 |
#1captionabove .choice:, |
| 2304 |
#1captionabove / true .code:n = |
| 2305 |
{ \@@_set_caption_position_top_bottom:nn { #1 } { t } }, |
| 2306 |
#1captionabove / false .code:n = |
| 2307 |
{ \@@_set_caption_position_top_bottom:nn { #1 } { b } }, |
| 2308 |
#1captionabove / unknown .code:n = |
| 2309 |
{ \msg_error:nne { keys } { boolean-values-only } \l_keys_path_str }, |
| 2310 |
#1captionabove .usage:n = general, |
| 2311 |
#1captionabove .default:n = true, |
| 2312 |
#1captionbelow .choice:, |
| 2313 |
#1captionbelow / true .code:n = |
| 2314 |
{ \@@_set_caption_position_top_bottom:nn { #1 } { b } }, |
| 2315 |
#1captionbelow / false .code:n = |
| 2316 |
{ \@@_set_caption_position_top_bottom:nn { #1 } { t } }, |
| 2317 |
#1captionbelow / unknown .code:n = |
| 2318 |
{ \msg_error:nne { keys } { boolean-values-only } \l_keys_path_str }, |
| 2319 |
#1captionbelow .usage:n = general, |
| 2320 |
#1captionbelow .default:n = true, |
| 2321 |
#1captionposition .choice:, |
| 2322 |
#1captionposition / top .code:n = |
| 2323 |
{ \@@_set_caption_position_top_bottom:nn { #1 } { t } }, |
| 2324 |
#1captionposition / bottom .code:n = |
| 2325 |
{ \@@_set_caption_position_top_bottom:nn { #1 } { b } }, |
| 2326 |
#1captionposition .usage:n = general, |
| 2327 |
#1captionposition .value_required:n = true, |
| 2328 |
} |
| 2329 |
\str_if_empty:nF { #1 } |
| 2330 |
{ |
| 2331 |
\keys_define:nn { tocbasic } |
| 2332 |
{ |
| 2333 |
#1captionposition / default .code:n = |
| 2334 |
{ \@@_set_caption_position_top_bottom:nn { #1 } { default } }, |
| 2335 |
#1captionposition .initial:n = default |
| 2336 |
} |
| 2337 |
} |
| 2338 |
\cs_if_exist:NTF \captionsetup |
| 2339 |
{ |
| 2340 |
\bool_if_exist:cTF { g_@@_ #1 _caption_above_bool } |
| 2341 |
{ |
| 2342 |
\exp_last_unbraced:Ne \captionsetup |
| 2343 |
{ |
| 2344 |
\str_if_empty:nF {#1} {[#1]} |
| 2345 |
{ |
| 2346 |
#1position= |
| 2347 |
{ \bool_if:cTF { g_@@_ #1 _caption_above_bool } tb } |
| 2348 |
} |
| 2349 |
} |
| 2350 |
} |
| 2351 |
{ |
| 2352 |
\tl_if_exist:cT { caption@opt@#1 } |
| 2353 |
{ |
| 2354 |
\tl_if_empty:cF { caption@opt@#1 } |
| 2355 |
{ \clearcaptionsetup[position]{#1} } |
| 2356 |
} |
| 2357 |
} |
| 2358 |
} |
| 2359 |
{ |
| 2360 |
\tl_if_eq:VnT \everypar { \@nodocument } |
| 2361 |
{ |
| 2362 |
\str_if_in:nnTF { ,table,figure,, } { ,#1, } |
| 2363 |
{ |
| 2364 |
\exp_args:Ne \PassOptionsToPackage |
| 2365 |
{ |
| 2366 |
#1position= |
| 2367 |
\bool_if_exist:cTF { g_@@_ #1 _caption_above_bool } |
| 2368 |
{ \bool_if:cTF { g_@@_ #1 _caption_above_bool } tb } |
| 2369 |
{ default } |
| 2370 |
} |
| 2371 |
{ caption } |
| 2372 |
} |
| 2373 |
{ |
| 2374 |
\hook_gput_code:nnn { package / caption / after } { tocbasic } |
| 2375 |
{ |
| 2376 |
\bool_if_exist:cT { g_@@_ #1 _caption_above_bool } |
| 2377 |
{ |
| 2378 |
\exp_last_unbraced:Ne \captionsetup |
| 2379 |
{ |
| 2380 |
\str_if_empty:nF {#1} {[#1]} |
| 2381 |
{ position=\bool_if:cTF { g_@@_ #1 _caption_above_bool } tb } |
| 2382 |
} |
| 2383 |
} |
| 2384 |
} |
| 2385 |
} |
| 2386 |
} |
| 2387 |
} |
| 2388 |
} |
| 2389 |
} |
| 2390 |
% \end{macrocode} |
| 2391 |
% \ExplSyntaxOn |
| 2392 |
% \begin{macro}{\@@_set_caption_position_top_bottom:nn} |
| 2393 |
% \ExplSyntaxOff |
| 2394 |
% This is the helper to set option \opt{position} to top (\texttt{\#2=t}) or |
| 2395 |
% bottom (\texttt{\#2=b}). If \texttt{\#1} is not empty but the name of a |
| 2396 |
% float, it can also be \optvalue{default}. Most of the logic of the options |
| 2397 |
% and the \pkg{caption} support is here. |
| 2398 |
% \begin{macrocode} |
| 2399 |
\cs_new:Nn \@@_set_caption_position_top_bottom:nn |
| 2400 |
{ |
| 2401 |
\str_if_eq:nnTF { #2 } { default } |
| 2402 |
{ |
| 2403 |
\bool_if_exist:cT { g_@@_ #1 _caption_above_bool } |
| 2404 |
{ \cs_undefine:c { g_@@_ #1 _caption_above_bool } } |
| 2405 |
\cs_if_exist:NTF \clearcaptionsetup |
| 2406 |
{ |
| 2407 |
\tl_if_exist:cT { caption@opt@#1 } |
| 2408 |
{ |
| 2409 |
\tl_if_empty:cF { caption@opt@#1 } |
| 2410 |
{ \clearcaptionsetup[position]{ #1 } } |
| 2411 |
} |
| 2412 |
} |
| 2413 |
{ |
| 2414 |
\tl_if_eq:VnT \everypar { \@nodocument } |
| 2415 |
{ |
| 2416 |
\str_if_in:nnT { ,table,figure,, } { ,#1, } |
| 2417 |
{ |
| 2418 |
\PassOptionsToPackage { #1position=#2 } { caption } |
| 2419 |
} |
| 2420 |
} |
| 2421 |
} |
| 2422 |
} |
| 2423 |
{ |
| 2424 |
\bool_if_exist:cF { g_@@_ #1 _caption_above_bool } |
| 2425 |
{ \bool_new:c { g_@@_ #1 _caption_above_bool } } |
| 2426 |
\str_if_eq:nnTF { #2 } { t } |
| 2427 |
{ \bool_set_true:c } |
| 2428 |
{ \bool_set_false:c } |
| 2429 |
{ g_@@_ #1 _caption_above_bool } |
| 2430 |
\cs_if_exist:NTF \captionsetup |
| 2431 |
{ |
| 2432 |
\exp_last_unbraced:Ne \captionsetup |
| 2433 |
{ \str_if_empty:nF {#1} {[#1]} } |
| 2434 |
{ position=#2 } |
| 2435 |
} |
| 2436 |
{ |
| 2437 |
\tl_if_eq:VnT \everypar { \@nodocument } |
| 2438 |
{ |
| 2439 |
\str_if_in:nnT { ,table,figure,, } { ,#1, } |
| 2440 |
{ |
| 2441 |
\PassOptionsToPackage { #1position=#2 } { caption } |
| 2442 |
} |
| 2443 |
} |
| 2444 |
} |
| 2445 |
} |
| 2446 |
} |
| 2447 |
% \end{macrocode} |
| 2448 |
% \end{macro} |
| 2449 |
% \ExplSyntaxOff |
| 2450 |
% Now, we can initialize not only the option for the default caption position |
| 2451 |
% \begin{macrocode} |
| 2452 |
\tocbasic_define_caption_keys:n {} |
| 2453 |
% \end{macrocode} |
| 2454 |
% but also for usual floats like \env{table} and \env{figure}. Note, that the |
| 2455 |
% captions of \env{lstlisting} are not configured here. If you want, you can |
| 2456 |
% add such configuration using: |
| 2457 |
% \begin{verbatim} |
| 2458 |
% \tocbasic_define_caption_keys:n { lstlisting } |
| 2459 |
% \end{verbatim} |
| 2460 |
% \begin{macrocode} |
| 2461 |
\clist_map_inline:nn { table, figure } |
| 2462 |
{ |
| 2463 |
\bool_if:nT |
| 2464 |
{ |
| 2465 |
{ \cs_if_exist_p:c { #1 } && \cs_if_exist_p:c { end#1 } } |
| 2466 |
|| |
| 2467 |
{ \cs_if_exist_p:c { #1- } && \cs_if_exist_p:c { end#1- } } |
| 2468 |
} |
| 2469 |
{ |
| 2470 |
\tocbasic_define_caption_keys:n { #1 } |
| 2471 |
} |
| 2472 |
} |
| 2473 |
|
| 2474 |
\ExplSyntaxOff |
| 2475 |
\fi |
| 2476 |
%</option> |
| 2477 |
% \end{macrocode} |
| 2478 |
% \end{command} |
| 2479 |
% |
| 2480 |
% \ExplSyntaxOn |
| 2481 |
% \begin{macro}{\@@_caption_patch_code:} |
| 2482 |
% \ExplSyntaxOff |
| 2483 |
% \changes{v3.46}{2025/06/13}{added} |
| 2484 |
% \changes{v3.48}{2025/08/29}{% |
| 2485 |
% \cs{cs\_set\_eq:NN} replaced by \cs{DeclareCommandCopy}} |
| 2486 |
% Now we can define the patch code. Note, that the caption patch is not |
| 2487 |
% automatically activated if the \pkg{caption} package is detected. And if |
| 2488 |
% you manually activate it, you will get a warning. |
| 2489 |
% \begin{macrocode} |
| 2490 |
%<*body> |
| 2491 |
\if@tocbasic@old@latex@found\else |
| 2492 |
\ExplSyntaxOn |
| 2493 |
\hook_gput_code:nnn { begindocument } { tocbasic } |
| 2494 |
{ |
| 2495 |
\DeclareCommandCopy { \@@_saved_caption:w } { \caption } |
| 2496 |
\bool_if:NT \g_@@_patch_caption_bool |
| 2497 |
{ |
| 2498 |
\@@_caption_patch_code: |
| 2499 |
} |
| 2500 |
} |
| 2501 |
|
| 2502 |
\hook_gset_rule:nnnn { begindocument } { tocbasic } { after } { caption } |
| 2503 |
\hook_gset_rule:nnnn { begindocument } { tocbasic } { after } { caption3 } |
| 2504 |
|
| 2505 |
\cs_new:Npn \@@_caption_patch_code: |
| 2506 |
{ |
| 2507 |
\DeclareCommandCopy { \caption } { \@@_caption:w } |
| 2508 |
\DeclareCommandCopy { \captionof } { \@@_caption_of:w } |
| 2509 |
} |
| 2510 |
% \end{macrocode} |
| 2511 |
% \changes{v3.49}{2025/11/05}{set \cs{caption@documentclass} if loaded |
| 2512 |
% before package \pkg{caption3}} |
| 2513 |
% \changes{v3.50}{2025/12/31}{set \cs{caption@documentclass} only with |
| 2514 |
% \KOMAScript{} classes} |
| 2515 |
% And as long as the \pkg{caption3} package does not load special code for |
| 2516 |
% the standard classes, we fake here \cs{caption@documentclass}, to avoid |
| 2517 |
% loading of extra caption code, when package \pkg{tocbasic} is used. |
| 2518 |
% \begin{macrocode} |
| 2519 |
\msg_new:nnnn { tocbasic } { caption-code-by-class-deactivated } |
| 2520 |
{ |
| 2521 |
Loading~of~class-dependent~code~for~package~caption3\\ |
| 2522 |
prevented~\msg_line_context:. |
| 2523 |
} |
| 2524 |
{ |
| 2525 |
The~caption3~package~attempts~to~detect~classes~known~to~it~ |
| 2526 |
using~a~number~of~heuristics~and,~if~necessary,~ |
| 2527 |
reload~class-dependent~code.~ |
| 2528 |
Unfortunately,~the~code~from~caption-koma.sto,~for~example,~ |
| 2529 |
is~no~longer~compatible~with~the~KOMA-Script~package~tocbasic~ |
| 2530 |
since~KOMA-Script~3.46.~ |
| 2531 |
Therefore,~the~tocbasic~package~attempts~to~prevent~this~file~ |
| 2532 |
from~being~loaded~by~pretending~to~caption3~that~a~standard~class~ |
| 2533 |
is~being~used.~ |
| 2534 |
Since~the~caption3~package,~as~part~of~the~caption~collection,~ |
| 2535 |
is~no~longer~maintained,~and~since~the~KOMA-Script~author~himself~ |
| 2536 |
is~trying~to~maintain~the~compatibility~of~the~caption~package~ |
| 2537 |
with~KOMA-Script,~this~is~currently~the~best~known~method~ |
| 2538 |
to~prevent~unnecessary~warnings~from~caption~or~caption3. |
| 2539 |
} |
| 2540 |
\cs_if_exist:NT \KOMAClassName |
| 2541 |
{ |
| 2542 |
\hook_gput_code:nnn { package / caption3 / before } { tocbasic } |
| 2543 |
{ |
| 2544 |
\cs_set:Npn \caption@documentclass { standard } |
| 2545 |
\msg_info:nn { tocbasic } { caption-code-by-class-deactivated } |
| 2546 |
} |
| 2547 |
} |
| 2548 |
% \end{macrocode} |
| 2549 |
% \end{macro} |
| 2550 |
% \ExplSyntaxOn |
| 2551 |
% \begin{command}{\tocbasic_if_caption_above_p:n, |
| 2552 |
% \tocbasic_if_caption_above:nT, |
| 2553 |
% \tocbasic_if_caption_above:nF, |
| 2554 |
% \tocbasic_if_caption_above:nTF, |
| 2555 |
% \tocbasic_if_caption_above_p:, |
| 2556 |
% \tocbasic_if_caption_above:T, |
| 2557 |
% \tocbasic_if_caption_above:F, |
| 2558 |
% \tocbasic_if_caption_above:TF} |
| 2559 |
% \ExplSyntaxOff |
| 2560 |
% \begin{macrocode} |
| 2561 |
\prg_new_conditional:Nnn \tocbasic_if_caption_above:n { p, T, F, TF } |
| 2562 |
{ |
| 2563 |
\bool_if:nTF |
| 2564 |
{ |
| 2565 |
\cs_if_exist_use:cF { g_@@_ #1 _caption_above_bool } |
| 2566 |
{ |
| 2567 |
\g_@@__caption_above_bool |
| 2568 |
} |
| 2569 |
} |
| 2570 |
{ |
| 2571 |
\prg_return_true: |
| 2572 |
} |
| 2573 |
{ |
| 2574 |
\prg_return_false: |
| 2575 |
} |
| 2576 |
} |
| 2577 |
\prg_new_conditional:Npnn \tocbasic_if_caption_above: { p, T, F, TF } |
| 2578 |
{ |
| 2579 |
\bool_if:nTF |
| 2580 |
{ |
| 2581 |
\cs_if_exist_use:cF { g_@@_ \@captype _caption_above_bool } |
| 2582 |
{ |
| 2583 |
\g_@@__caption_above_bool |
| 2584 |
} |
| 2585 |
} |
| 2586 |
{ |
| 2587 |
\prg_return_true: |
| 2588 |
} |
| 2589 |
{ |
| 2590 |
\prg_return_false: |
| 2591 |
} |
| 2592 |
} |
| 2593 |
% \end{macrocode} |
| 2594 |
% \end{command} |
| 2595 |
% \ExplSyntaxOn |
| 2596 |
% \begin{macro}{\@@_caption_setup:,\@@_captionof_setup:n} |
| 2597 |
% \changes{v3.46}{2025/06/13}{added} |
| 2598 |
% \changes{v3.49}{2025/10/31}{renamed to remove double \texttt{tocbasic}} |
| 2599 |
% \begin{macro}{\@@_caption_setup:nn} |
| 2600 |
% \changes{v3.47}{2025/08/25}{added} |
| 2601 |
% \changes{v3.49}{2025/10/31}{renamed to remove double \texttt{tocbasic}} |
| 2602 |
% \ExplSyntaxOff |
| 2603 |
% Does all the setup needed before being able to call |
| 2604 |
% \cs{@@\_saved\_caption:w} either for a given caption type or |
| 2605 |
% \cs{@captype}. This should be used local only! |
| 2606 |
% \begin{macrocode} |
| 2607 |
\cs_new:Nn \@@_caption_setup: |
| 2608 |
{ |
| 2609 |
\tocbasic_if_caption_above:TF |
| 2610 |
{ |
| 2611 |
\cs_if_exist:NTF \captionsetup |
| 2612 |
{ \captionsetup { position=top } } |
| 2613 |
{ \@@_swap_skip: } |
| 2614 |
} |
| 2615 |
{ |
| 2616 |
\cs_if_exist:NT \captionsetup |
| 2617 |
{ \captionsetup { position=bottom } } |
| 2618 |
} |
| 2619 |
} |
| 2620 |
\cs_new:Nn \@@_captionof_setup:n |
| 2621 |
{ |
| 2622 |
\exp_args:Nne \hook_gput_next_code:nn { tocbasic / caption / after } |
| 2623 |
{ |
| 2624 |
\cs_if_exist:NTF \@captype |
| 2625 |
{ \exp_not:N \tl_set:Nn \exp_not:N \@captype { \@captype } } |
| 2626 |
{ \exp_not:n { \cs_set_eq:NN \@captype \tex_undefined:D } } |
| 2627 |
} |
| 2628 |
\tocbasic_if_caption_above:nTF { #1 } |
| 2629 |
{ |
| 2630 |
\cs_if_exist:NTF \captionsetup |
| 2631 |
{ \captionsetup { type=#1, position=top } } |
| 2632 |
{ |
| 2633 |
\tl_set:Ne \@captype { #1 } |
| 2634 |
\@@_swap_skip: |
| 2635 |
} |
| 2636 |
} |
| 2637 |
{ |
| 2638 |
\cs_if_exist:NTF \captionsetup |
| 2639 |
{ \captionsetup { type=#1, position=bottom } } |
| 2640 |
{ \tl_set:Ne \@captype { #1 } } |
| 2641 |
} |
| 2642 |
} |
| 2643 |
\cs_new:Nn \@@_captionof_setup:nn |
| 2644 |
{ |
| 2645 |
\exp_args:Nne \hook_gput_next_code:nn { tocbasic / caption / after } |
| 2646 |
{ |
| 2647 |
\cs_if_exist:NTF \@captype |
| 2648 |
{ \exp_not:N \tl_set:Nn \exp_not:N \@captype { \@captype } } |
| 2649 |
{ \exp_not:n { \cs_set_eq:NN \@captype \tex_undefined:D } } |
| 2650 |
} |
| 2651 |
\str_if_eq:eeTF { #2 } { top } |
| 2652 |
{ |
| 2653 |
\cs_if_exist:NTF \captionsetup |
| 2654 |
{ \captionsetup { type=#1, position=top } } |
| 2655 |
{ |
| 2656 |
\tl_set:Ne \@captype { #1 } |
| 2657 |
\@@_swap_skip: |
| 2658 |
} |
| 2659 |
} |
| 2660 |
{ |
| 2661 |
\cs_if_exist:NTF \captionsetup |
| 2662 |
{ \captionsetup { type=#1, position=#2 } } |
| 2663 |
{ \tl_set:Ne \@captype { #1 } } |
| 2664 |
} |
| 2665 |
} |
| 2666 |
% \end{macrocode} |
| 2667 |
% \end{macro} |
| 2668 |
% \end{macro} |
| 2669 |
% \ExplSyntaxOn |
| 2670 |
% \begin{macro}{\@@_caption:w} |
| 2671 |
% \ExplSyntaxOff |
| 2672 |
% \changes{v3.46}{2025/06/13}{added} |
| 2673 |
% \changes{v3.47}{2025/08/25}{extra group eliminted} |
| 2674 |
% \changes{v3.49}{2025/10/31}{use optional argument only, if used} |
| 2675 |
% \changes{v3.50}{2025/12/01}{use long mandatory argument} |
| 2676 |
% This is, what will be \cs{caption}, if \cs{caption} is patched. |
| 2677 |
% \begin{macrocode} |
| 2678 |
\NewDocumentCommand \@@_caption:w { s o +m } |
| 2679 |
{ |
| 2680 |
\@@_caption_setup: |
| 2681 |
\exp_last_unbraced:Ne \@@_saved_caption:w |
| 2682 |
{ \IfBooleanT{#1}* \IfValueT{#2} { \exp_not:n {[{#2}]} } } |
| 2683 |
{#3} |
| 2684 |
\hook_use:n { tocbasic / caption / after } |
| 2685 |
} |
| 2686 |
% \end{macrocode} |
| 2687 |
% \end{macro} |
| 2688 |
% \ExplSyntaxOff |
| 2689 |
% \begin{command}{\captionabove,\captionbelow} |
| 2690 |
% \changes{v3.46}{2025/06/13}{new implementation moved to \pkg*{tocbasic}} |
| 2691 |
% \changes{v3.47}{2025/08/25}{extra group eliminted} |
| 2692 |
% \changes{v3.50}{2025/12/01}{use long mandatory argument} |
| 2693 |
% \begin{macrocode} |
| 2694 |
\NewDocumentCommand \captionabove { s O{#3} +m } |
| 2695 |
{ |
| 2696 |
\cs_if_exist:NTF \captionsetup |
| 2697 |
{ \captionsetup { position=top } } |
| 2698 |
{ \@@_swap_skip: } |
| 2699 |
\exp_last_unbraced:Ne \@@_saved_caption:w { \IfBooleanT{#1}* } |
| 2700 |
[{#2}] {#3} |
| 2701 |
\hook_use:n { tocbasic / caption / after } |
| 2702 |
} |
| 2703 |
|
| 2704 |
\NewDocumentCommand \captionbelow { s O{#3} +m } |
| 2705 |
{ |
| 2706 |
\cs_if_exist:NT \captionsetup |
| 2707 |
{ \captionsetup { position=bottom } } |
| 2708 |
\exp_last_unbraced:Ne \@@_saved_caption:w { \IfBooleanT{#1}* } |
| 2709 |
[{#2}] {#3} |
| 2710 |
\hook_use:n { tocbasic / caption / after } |
| 2711 |
} |
| 2712 |
% \end{macrocode} |
| 2713 |
% \end{command} |
| 2714 |
% \ExplSyntaxOn |
| 2715 |
% \begin{command}{\captionof,\@@_caption_of:w} |
| 2716 |
% \ExplSyntaxOff |
| 2717 |
% \changes{v3.46}{2025/06/13}{added} |
| 2718 |
% \changes{v3.47}{2025/08/25}{extra group eliminted} |
| 2719 |
% \changes{v3.48}{2025/08/29}{% |
| 2720 |
% \cs{cs\_set\_eq:NN} replaced by \cs{DeclareCommandCopy}} |
| 2721 |
% \changes{v3.49}{2025/10/31}{use optional argument only, if used} |
| 2722 |
% \changes{v3.50}{2025/12/01}{use long last mandatory argument} |
| 2723 |
% This is, what will be \cs{captionof}, if \cs{captionof} is patched or not |
| 2724 |
% defined. |
| 2725 |
% \begin{macrocode} |
| 2726 |
\NewDocumentCommand \@@_caption_of:w { s m o +m } |
| 2727 |
{ |
| 2728 |
\@@_captionof_setup:n { #2 } |
| 2729 |
\exp_last_unbraced:Ne \@@_saved_caption:w |
| 2730 |
{ \IfBooleanT{#1}* \IfValueT{#3} { \exp_not:n {[{#3}]} } } |
| 2731 |
{#4} |
| 2732 |
\hook_use:n { tocbasic / caption / after } |
| 2733 |
} |
| 2734 |
|
| 2735 |
\cs_if_exist:NF { \captionof } |
| 2736 |
{ \DeclareCommandCopy { \captionof } { \@@_caption_of:w } } |
| 2737 |
% \end{macrocode} |
| 2738 |
% \ExplSyntaxOn |
| 2739 |
% \begin{macro}{\@@_swap_skips:} |
| 2740 |
% \ExplSyntaxOff |
| 2741 |
% Helper to (locally) interchange the values of \cs{abovecaptionskip} and |
| 2742 |
% \cs{belowcaptionskip}. We also provide a socket (with older \LaTeX{} |
| 2743 |
% kernels a hook) to react on the swap. |
| 2744 |
% \begin{macrocode} |
| 2745 |
\cs_if_exist:NTF \socket_new:nn |
| 2746 |
{ \socket_new:nn { tocbasic / swapskip / after } { 0 } } |
| 2747 |
{ \hook_new:n { tocbasic / swapskip / after } } |
| 2748 |
\hook_new:n { tocbasic / caption / after } |
| 2749 |
\cs_new:Nn \@@_swap_skip: |
| 2750 |
{ |
| 2751 |
\skip_set_eq:NN \l_tmpa_skip \abovecaptionskip |
| 2752 |
\skip_set_eq:NN \abovecaptionskip \belowcaptionskip |
| 2753 |
\skip_set_eq:NN \belowcaptionskip \l_tmpa_skip |
| 2754 |
\hook_gput_next_code:nn { tocbasic / caption / after } { |
| 2755 |
\skip_set_eq:NN \l_tmpa_skip \abovecaptionskip |
| 2756 |
\skip_set_eq:NN \abovecaptionskip \belowcaptionskip |
| 2757 |
\skip_set_eq:NN \belowcaptionskip \l_tmpa_skip |
| 2758 |
} |
| 2759 |
\cs_if_exist_use:NF \socket_use:n \hook_use:n |
| 2760 |
{ tocbasic / swapskip / after } |
| 2761 |
} |
| 2762 |
% \end{macrocode} |
| 2763 |
% \end{macro} |
| 2764 |
% \end{command} |
| 2765 |
% \ExplSyntaxOff |
| 2766 |
% \begin{command}{\captionaboveof,\captionbelowof} |
| 2767 |
% \changes{v3.46}{2025/06/13}{new implementation moved to \pkg*{tocbasic}} |
| 2768 |
% \changes{v3.47}{2025/08/25}{extra group eliminted} |
| 2769 |
% \changes{v3.50}{2025/12/01}{use long last mandatory argument} |
| 2770 |
% \begin{macrocode} |
| 2771 |
\NewDocumentCommand \captionaboveof { s m O{#4} +m } |
| 2772 |
{ |
| 2773 |
\@@_captionof_setup:nn { #2 } { top } |
| 2774 |
\exp_last_unbraced:Ne \@@_saved_caption:w { \IfBooleanT{#1}* } |
| 2775 |
[{#3}] {#4} |
| 2776 |
\hook_use:n { tocbasic / caption / after } |
| 2777 |
} |
| 2778 |
|
| 2779 |
\NewDocumentCommand \captionbelowof { s m O{#4} +m } |
| 2780 |
{ |
| 2781 |
\@@_captionof_setup:nn { #2 } { bottom } |
| 2782 |
\exp_last_unbraced:Ne \@@_saved_caption:w { \IfBooleanT{#1}* } |
| 2783 |
[{#3}] {#4} |
| 2784 |
\hook_use:n { tocbasic / caption / after } |
| 2785 |
} |
| 2786 |
\ExplSyntaxOff |
| 2787 |
\fi |
| 2788 |
%<@@=> |
| 2789 |
%</body> |
| 2790 |
% \end{macrocode} |
| 2791 |
% \end{command} |
| 2792 |
% \ExplSyntaxOff |
| 2793 |
% |
| 2794 |
% \begin{macrocode} |
| 2795 |
%</package> |
| 2796 |
% \end{macrocode} |
| 2797 |
% |
| 2798 |
% \subsection{Loading the package} |
| 2799 |
% Used at \KOMAScript{} packages and classes to load the package. |
| 2800 |
% \changes{v3.46}{2025/06/13}{\KOMAScript{} classes need to load |
| 2801 |
% \pkg*{tocbasic} with option \opt{enablepatch\quotechar=caption}} |
| 2802 |
% \begin{macrocode} |
| 2803 |
%<*load> |
| 2804 |
\RequirePackage[enablepatch=caption]{tocbasic}[% |
| 2805 |
%!KOMAScriptVersion |
| 2806 |
] |
| 2807 |
% \end{macrocode} |
| 2808 |
% And do an early initialization of additional keys. |
| 2809 |
% \begin{macrocode} |
| 2810 |
\ExplSyntaxOn |
| 2811 |
\tocbasic_define_caption_keys:n { table } |
| 2812 |
\tocbasic_define_caption_keys:n { figure } |
| 2813 |
\ExplSyntaxOff |
| 2814 |
%</load> |
| 2815 |
% \end{macrocode} |
| 2816 |
% |
| 2817 |
% |
| 2818 |
% \Finale |
| 2819 |
% \PrintChanges |
| 2820 |
% |
| 2821 |
\endinput |
| 2822 |
% Local Variables: |
| 2823 |
% mode: doctex |
| 2824 |
% ispell-local-dictionary: "en_US" |
| 2825 |
% eval: (flyspell-mode 1) |
| 2826 |
% TeX-master: t |
| 2827 |
% TeX-engine: luatex-dev |
| 2828 |
% eval: (setcar (or (cl-member "Index" (setq-local TeX-command-list (copy-alist TeX-command-list)) :key #'car :test #'string-equal) (setq-local TeX-command-list (cons nil TeX-command-list))) '("Index" "mkindex %s" TeX-run-index nil t :help "makeindex for dtx")) |
| 2829 |
% End: |