summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/koma-script/source/scrkernel-index.dtx
blob: 34972167b6a29ff640d0feaebb4a7dacfa77da1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
% \iffalse meta-comment
% ======================================================================
% scrkernel-index.dtx
% Copyright (c) Markus Kohm, 2002-2022
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX 
% version 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in manifest.txt.
% ======================================================================
%%% From File: $Id: scrkernel-index.dtx 3706 2022-02-15 09:36:50Z kohm $
%<option>%%%            (run: option)
%<body>%%%            (run: body)
%<*dtx>
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
\begingroup
  \def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}}
  \filedate$Date: 2022-02-15 10:36:50 +0100 (Di, 15. Feb 2022) $
  \def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
  \filerevision$Revision: 3706 $
  \edef\reserved@a{%
    \noexpand\endgroup
    \noexpand\ProvidesFile{scrkernel-index.dtx}%
                          [\filedate\space\filerevision\space
                           KOMA-Script source
                           (index)]%
  }%
\reserved@a
\documentclass[USenglish]{koma-script-source-doc}
\usepackage{babel}
\setcounter{StandardModuleDepth}{2}
\begin{document}
\DocInput{scrkernel-index.dtx}
\end{document}
%</dtx>
% \fi
%
% \changes{v2.95}{2002/07/01}{new by splitting \file{scrclass.dtx}}
% \changes{v3.36}{2022/02/15}{switch over from \cls*{scrdoc} to
%   \cls*{koma-script-source-doc}}
% \changes{v3.36}{2022/02/15}{whole implementation documentation in English}
%
% \GetFileInfo{scrkernel-index.dtx}
% \title{Index Code of the 
%   \href{https://komascript.de}{\KOMAScript} Classes}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}}
% \date{Revision \fileversion{} of \filedate}
% \maketitle
% \begin{abstract}
%   The index code of the \KOMAScript{} classes in \file{scrkernel-index.dtx}
%   is somehow different from the code of the standard classes. It provides
%   several options and other configuration possibilities.
% \end{abstract}
% \tableofcontents
%
% \section{User Manual}
%
% You can find the user documentation the commands implemented here in the
% \KOMAScript{} manual, either the German \file{scrguide} or the English
% \file{scrguien}.
% 
% \MaybeStop{\PrintIndex}
%
% \section{Implementation of the Index}
%
% The letter class \cls*{scrlttr2} does not provide an index. All other
% classes do.
%
%    \begin{macrocode}
%<*!letter>
%    \end{macrocode}
%
%
% \subsection{Options}
%
% \begin{option}{index}
% \changes{v2.98c}{2008/03/04}{added}
% \changes{v3.17}{2015/03/12}{internal value storage}
% \changes{v3.18}{2015/06/15}{new value \opt{numbered}}
% \changes{v3.18}{2015/06/15}{new value \opt{leveldown}}
% \changes{v3.18}{2015/06/15}{new value \opt{standardlevel}}
% \changes{v2.7a}{2001/01/04}{improved link generation with \cls*{scrbook} or
%   \cls*{scrreprt} and \pkg{hyperref}}
% \changes{v2.98c}{2008/03/04}{redefining \cs{idx@@heading} instead of
%   \cs{idx@@heading}}
% \changes{v3.18}{2015/06/15}{new value \opt{leveldown}}
% The option allow several values for several features:
% \begin{labeling}{\opt{=standardlevel}:}
% \item[\opt{=default}:]       use not numbered heading without ToC entry, but
%   without affecting the heading level;
% \item[\opt{=totoc}:]         use not numbered heading with ToC entry, but
%   without affecting the heading level;
% \item[\opt{=numbered}:]      use numbered heading (with ToC entry), but
%   without affecting the heading level;
% \item[\opt{=leveldown}:]     use a subheading (e.g. \cs{subsection} instead
%   of \cs{section} in \cls*{scrartcl}), without affecting numbered or not and
%   ToC entry or not;
% \item[\opt{=standardlevel}:] don't use a subheading, without affecting
%   numbered or not and ToC entry or not.
% \end{labeling}
% To do so, the option redefines \cs{idx@heading}.
% \begin{macro}{\idx@@heading}
% \changes{v2.98c}{2008/03/04}{added}
% \changes{v3.18}{2015/06/15}{using \opt{leveldown}}
% This is the macro to print the heading of the index (nothing else). It has
% one mandatory argument: the text to be used as heading. There will be one
% additional code level above this: \cs{idx@heading}, that will be defined in
% the \texttt{body} run. \cs{idx@heading} has to be defined before, so it can
% be redefined by the \opt{index} option. In opposite to the standard classes
% we want to use \cs{chapter} in two column mode. This can be done, because of
% significant changes of \cs{chapter} definition. Note: If someone uses the
% standard classes hack of package \pkg*{scrhack} or even another headings
% package like \pkg*{titlesec} this could fail. But this is not my problem,
% because usage of such packages and hacks is not recommended at all.
%    \begin{macrocode}
%<*option>
\newcommand*{\idx@@heading}{%
  \ifidx@leveldown
%<article>    \expandafter\subsection
%<book|report>    \expandafter\section
  \else
%<article>    \expandafter\section
%<book|report>    \expandafter\chapter
  \fi*%
}
%    \end{macrocode}
% \begin{macro}{\idx@leveldowntrue,\idx@leveldownfalse,\ifidx@leveldown}
% \changes{v3.18}{2015/06/15}{added}
% The boolean switch \cs{ididx@leveldown} is needed to distinguish the heading
% level to be used (option values \opt{leveldown} and \opt{standardlevel}).
%    \begin{macrocode}
\newif\ifidx@leveldown
\KOMA@key{index}{%
  \KOMA@set@ncmdkey{index}{@tempa}{%
    {notoc}{0},{nottotoc}{0},{default}{0},{plainheading}{0},%
    {totoc}{1},{toc}{1},{notnumbered}{1},%
    {numbered}{2},{totocnumbered}{2},{numberedtotoc}{2},{tocnumbered}{2},%
    {numberedtoc}{2},%
    {leveldown}{3},%
    {standardlevel}{4}%
  }{#1}%
  \ifx\FamilyKeyState\FamilyKeyStateProcessed
    \ifcase \@tempa\relax
      \KOMA@kav@remove{.\KOMAClassFileName}{toc}{noindex}%
      \KOMA@kav@remove{.\KOMAClassFileName}{toc}{indexnumbered}%
      \KOMA@kav@remove{.\KOMAClassFileName}{toc}{index}%
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{notoc}%
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{numbered}%
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{toc}%
      \KOMA@kav@add{.\KOMAClassFileName}{toc}{noindex}%
      \KOMA@kav@add{.\KOMAClassFileName}{index}{notoc}%
      \renewcommand*{\idx@@heading}{%
        \ifidx@leveldown
%<article>        \expandafter\subsection
%<book|report>        \expandafter\section
        \else
%<article>        \expandafter\section
%<book|report>        \expandafter\chapter
        \fi*%
      }%
    \or
      \KOMA@kav@remove{.\KOMAClassFileName}{toc}{noindex}%
      \KOMA@kav@remove{.\KOMAClassFileName}{toc}{indexnumbered}%
      \KOMA@kav@remove{.\KOMAClassFileName}{toc}{index}%
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{notoc}%
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{numbered}%
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{toc}%
      \KOMA@kav@add{.\KOMAClassFileName}{toc}{index}%
      \KOMA@kav@add{.\KOMAClassFileName}{index}{toc}%
      \renewcommand*{\idx@@heading}{%
        \ifidx@leveldown
%<article>        \expandafter\subsection\expandafter*
%<book|report>        \expandafter\addsec
        \else
%<article>        \expandafter\addsec
%<book|report>        \expandafter\addchap
        \fi
      }%
    \or
      \KOMA@kav@remove{.\KOMAClassFileName}{toc}{noindex}%
      \KOMA@kav@remove{.\KOMAClassFileName}{toc}{indexnumbered}%
      \KOMA@kav@remove{.\KOMAClassFileName}{toc}{index}%
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{notoc}%
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{numbered}%
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{toc}%
      \KOMA@kav@add{.\KOMAClassFileName}{toc}{indexnumbered}%
      \KOMA@kav@add{.\KOMAClassFileName}{index}{numbered}%
      \renewcommand*{\idx@@heading}{%
        \ifidx@leveldown
%<article>        \expandafter\subsection
%<book|report>        \expandafter\section
        \else
%<article>        \expandafter\section
%<book|report>        \expandafter\chapter
        \fi
      }%
    \or
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{leveldown}%
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{standardlevel}%
      \KOMA@kav@add{.\KOMAClassFileName}{index}{leveldown}%
      \idx@leveldowntrue
    \or
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{leveldown}%
      \KOMA@kav@remove{.\KOMAClassFileName}{index}{standardlevel}%
      \KOMA@kav@add{.\KOMAClassFileName}{index}{standardlevel}%
      \idx@leveldownfalse
    \fi
  \fi
}
\KOMA@kav@add{.\KOMAClassFileName}{toc}{noindex}
\KOMA@kav@add{.\KOMAClassFileName}{index}{notoc}
\KOMA@kav@add{.\KOMAClassFileName}{index}{standardlevel}
%    \end{macrocode}
% \end{macro}^^A \ifidx@leveldown …
% \end{macro}^^A \idx@@heading
% \end{option}^^A index
%
% \begin{option}{idxtotoc}
% \changes{v2.3h}{1995/01/21}{new}
% \changes{v2.98c}{2008/03/04}{obsolete}
% \changes{v3.01a}{2008/11/20}{deprecated}
%    \begin{macrocode}
\KOMA@DeclareDeprecatedOption{idxtotoc}{index=totoc}
%</option>
%    \end{macrocode}
% \end{option}
%
%
% \subsection{User commands and macros}
%
% \begin{command}{\setindexpreamble}
% \changes{v2.6c}{2000/06/10}{added}
% \changes{v2.6d}{2000/07/20}{\cs{let} replaced by \cs{newcommand*}}
% \changes{v2.95}{2002/07/01}{\cs{let} and \cs{def}}
% \begin{macro}{\index@preamble}
% \changes{v2.6c}{2000/06/10}{added}
% The index preamble is placed between the heading an the index itself. The
% user can define it using \cs{setindexpreamble}. \cs{index@preamble} is the
% storage. Note: \cs{setindexpreamble} does read the argument itself. This
% makes it easier to patch the user level command. But because of this it has
% to long.
%    \begin{macrocode}
%<*body>
\newcommand*{\index@preamble}{}
\let\index@preamble=\relax
\newcommand{\setindexpreamble}[1]{\def\index@preamble{#1}}
%    \end{macrocode}
% \end{macro}
% \end{command}
%
% \begin{macro}{\idx@heading}
% \changes{v2.3h}{1995/01/21}{added}
% \changes{v2.4c}{1996/04/04}{handling of running heads fixed}
% \changes{v2.4g}{1996/11/04}{two-columned index with \cls*{scrartcl} fixed}
% \changes{v2.6c}{2000/06/10}{support for index preamble after heading}
% \changes{v2.7j}{2001/05/27}{output of preamble moved to \env{theindex}}
% \changes{v2.9l}{2003/01/19}{\cs{if@twoside} replaced by \cs{if@openright}}
% \changes{v2.98c}{2008/03/04}{using \cs{idx@@heading}}
% \changes{v3.10}{2011/08/31}{using \cs{MakeMarkcase}}
% \changes{v3.10a}{2012/03/08}{brackets from previous change fixed}
% \changes{v3.12}{2013/09/24}{never make an index entry to the other ToC but
%   the table of contents}
% \changes{v3.25}{2017/10/13}{using \cs{@mkright} and \cs{@mkdouble}}
% \changes{v3.26}{2018/09/03}{usage of \cs{addsecmark} or \cs{subsectionmark}
%   instead of \cs{@mkright}}
% Macro to make the index heading and preamble.
%    \begin{macrocode}
\newcommand*{\idx@heading}{%
%<report|book>  \if@openright\cleardoublepage\else\clearpage\fi%
  \twocolumn[%
%<report|book>    \@chaptertolistsfalse
                  \idx@@heading{\indexname}]%
  \ifidx@leveldown
%<report|book>    \addsecmark{\indexname}%
%<*article>
    \begingroup
      \c@secnumdepth=-\maxdimen
      \subsectionmark{\indexname}%
    \endgroup
%</article>
  \else
    \@mkdouble{\MakeMarkcase{\indexname}}%
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{theindex}
% \changes{v2.8d}{2001/07/05}{\cs{indexpagestyle} instead of \pstyle{plain}}
% \changes{v2.3h}{1995/01/21}{using \cs{idx@heading}}
% \changes{v2.7j}{2001/05/27}{output of preamble added}
% \changes{v3.19}{2015/08/25}{using \cs{indexpagestyle} only if not empty}
% This definition is similar to the definition of the standard classes. As
% addition it supports a preamble text, a variable heading, and resets the
% paragraph end line fill.
%    \begin{macrocode}
\newenvironment{theindex}{%
  \if@twocolumn
    \@restonecolfalse
  \else
    \@restonecoltrue
  \fi
  \columnseprule \z@
  \columnsep 35\p@
%<book|report>  \setchapterpreamble{\index@preamble}%
  \idx@heading
%<article>  \index@preamble\par\nobreak
  \ifx\indexpagestyle\@empty\else\thispagestyle{\indexpagestyle}\fi
  \parindent\z@
  \setlength{\parskip}{\z@ \@plus .3\p@}%
  \setlength{\parfillskip}{\z@ \@plus 1fil}%
  \let\item\@idxitem
}{%
  \if@restonecol\onecolumn\else\clearpage\fi
}
%    \end{macrocode}
% \begin{macro}{\@idxitem}
% A new index entry
% \begin{command}{\subitem,\subsubitem}
% \changes{v2.3g}{1996/01/14}{using \cs{@idxitem} saves memory}
% sub-entry, sub-sub-entry,
% \begin{command}{\indexspace}
% or (vertical) distance.
%    \begin{macrocode}
\newcommand*\@idxitem{\par\hangindent 40\p@}
%    \begin{macrocode}
\newcommand*\subitem{\@idxitem \hspace*{20\p@}}
\newcommand*\subsubitem{\@idxitem \hspace*{30\p@}}
\newcommand*\indexspace{%
  \par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax
}
%    \end{macrocode}
% \end{command}^^A \indexspace
% \end{command}^^A \subitem,\subsubitem
% \end{macro}^^A \@idxitem
% \end{environment}^^A theindex
%
%
% \subsection{Language dependent terms}
%
% \begin{command}{\indexname}
% \changes{v3.36}{2022/02/15}{explicit definition for English languages}
% The name of the index (used by \cs{idx@heading}).
%    \begin{macrocode}
\newcommand*\indexname{Index}
\providecaptionname{american,australian,british,canadian,english,newzealand,%
  UKenglish,ukenglish,USenglish,usenglish}\indexname{Index}
%</body>
%    \end{macrocode}
% \end{command}
%
%
%    \begin{macrocode}
%</!letter>
%    \end{macrocode}
%
% \Finale
% \PrintChanges
% 
\endinput
% Local Variables:
% mode: doctex
% ispell-local-dictionary: "en_US"
% eval: (flyspell-mode 1)
% TeX-master: t
% TeX-engine: luatex-dev
% 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"))
% End: