Debian Codegraph @

texmf-dist/source/latex-dev/base/doc.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 1993-2026
4 % The LaTeX Project and any individual authors listed elsewhere
5 % in this file.
6 %
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
9 %
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % https://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2008 or later.
17 %
18 % This file has the LPPL maintenance status "maintained".
19 %
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
22 % information.
23 %
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
27 %
28 % \fi
29 % ^^A -*-LaTeX-*-
30 %
31 % ^^A These shouldn't come out in .ist files, hence the module
32 % ^^A comments, or in the printed version, hence temporary comment
33 % ^^A category for `<'
34 %\catcode`\<=14
35 %<+package|shortvrb>\NeedsTeXFormat{LaTeX2e}[1994/12/01]
36 %<+package>
37 % ^^A Any rollback request before 2016-02-15 we try to fulfill with the 2016 version:
38 %<+package>\DeclareRelease{}{1994-06-01}
39 %<+package> {doc-2016-02-15.sty}
40 %<+package>\DeclareRelease{v2.1g}{2016-02-15}
41 %<+package> {doc-2016-02-15.sty}
42 %<+package>\DeclareRelease{v2}{2021-06-01}
43 %<+package> {doc-2021-06-01.sty}
44 %<+package>\DeclareCurrentRelease{v3}{2022-06-01}
45 %<+package>
46 %<+package>\ProvidesPackage{doc}
47 %<+shortvrb>\ProvidesPackage{shortvrb}
48 %<+package|shortvrb> [2026-03-13 v3.0r
49 %<+package|shortvrb> Standard LaTeX documentation package V3 (FMi)]
50 %\catcode`\<=12
51 %
52 %%
53 %\iffalse This is a METACOMMENT
54 % Everything up to the next `\ fi' (without a blank) will
55 % be ignored. This is necessary because `%' may no longer
56 % be a comment mark when this file is read in.
57 %
58 %
59 %% Package `doc' to use with LaTeX 2e
60 %% Copyright (C) 1989-2023 Frank Mittelbach, all rights reserved.
61 %
62 %
63 % Version: Date: Changes:
64 %
65 % 1.0a 5.5.88 This is nothing but a collection of tests and
66 % hacks. It is certainly going to be greatly
67 % changed.
68 % Better not to use it!
69 % 1.5a and earlier... are not longer recorded
70 % 1.5b and higher... are documented with the (undocumented) \changes
71 % feature.
72 %\fi
73 % \changes{v1.5f}{1989/04/29}{Thanks to Brian who documented the
74 % \cs{changes} macro feature.}
75 % \changes{v1.5g}{1989/05/07}{MacroTopsep now called MacrocodeTopsep and
76 % new MacroTopsep added}
77 % \changes{v1.5h}{1989/05/17}{All lines shortened to <72 characters}
78 % \changes{v1.5j}{1989/06/09}{Corrections by Ron Whitney added}
79 % \changes{v1.5q}{1989/11/03}{`\ldots{}Listing macros renamed to
80 % `\ldots{}Input. Suggested by R. Wonneberger}
81 % \changes{v1.5w}{1990/02/05}{Counter codelineno renamed to CodelineNo}
82 % \changes{v1.9a}{1993/12/02}{Upgrade for LaTeX2e}
83 % \changes{v1.9d}{1993/12/20}{Protected changes entry.}
84 % \changes{v1.0p}{1994/05/21}{Use new error commands}
85 % \changes{v3.0m}{2022/11/13}{Redefinitions of \cs{verb} removed as
86 % no longer needed (gh/953)}
87 % \changes{v3.0r}{2026-03-12}{Switch from \texttt{x}- to \texttt{e}-type
88 % expansion in expl3 code}
89 %
90 %
91 % \hyphenation{make-index}
92 %
93 % \DoNotIndex{\@,\@@par,\@beginparpenalty,\@empty}
94 % \DoNotIndex{\@flushglue,\@gobble,\@input}
95 % \DoNotIndex{\@makefnmark,\@makeother,\@maketitle}
96 % \DoNotIndex{\@namedef,\@ne,\@spaces,\@tempa}
97 % \DoNotIndex{\@tempb,\@tempswafalse,\@tempswatrue}
98 % \DoNotIndex{\@thanks,\@thefnmark,\@topnum}
99 % \DoNotIndex{\@@,\@elt,\@forloop,\@fortmp,\@gtempa,\@totalleftmargin}
100 % \DoNotIndex{\",\/,\@ifundefined,\@nil,\@verbatim,\@vobeyspaces}
101 % \DoNotIndex{\|,\~,\ ,\active,\advance,\aftergroup,\begingroup,\bgroup}
102 % \DoNotIndex{\mathcal,\csname,\def,\documentstyle,\dospecials,\edef}
103 % \DoNotIndex{\egroup}
104 % \DoNotIndex{\else,\endcsname,\endgroup,\endinput,\endtrivlist}
105 % \DoNotIndex{\expandafter,\fi,\fnsymbol,\futurelet,\gdef,\global}
106 % \DoNotIndex{\hbox,\hss,\if,\if@inlabel,\if@tempswa,\if@twocolumn}
107 % \DoNotIndex{\ifcase}
108 % \DoNotIndex{\ifcat,\iffalse,\ifx,\ignorespaces,\index,\input,\item}
109 % \DoNotIndex{\jobname,\kern,\leavevmode,\leftskip,\let,\llap,\lower}
110 % \DoNotIndex{\m@ne,\next,\newpage,\nobreak,\noexpand,\nonfrenchspacing}
111 % \DoNotIndex{\obeylines,\or,\protect,\raggedleft,\rightskip,\rm,\sc}
112 % \DoNotIndex{\setbox,\setcounter,\small,\space,\string,\strut}
113 % \DoNotIndex{\strutbox}
114 % \DoNotIndex{\thefootnote,\thispagestyle,\topmargin,\trivlist,\tt}
115 % \DoNotIndex{\twocolumn,\typeout,\vss,\vtop,\xdef,\z@}
116 % \DoNotIndex{\,,\@bsphack,\@esphack,\@noligs,\@vobeyspaces,\@xverbatim}
117 % \DoNotIndex{\`,\catcode,\end,\escapechar,\frenchspacing,\glossary}
118 % \DoNotIndex{\hangindent,\hfil,\hfill,\hskip,\hspace,\ht,\it,\langle}
119 % \DoNotIndex{\leaders,\long,\makelabel,\marginpar,\markboth,\mathcode}
120 % \DoNotIndex{\mathsurround,\mbox,\newcount,\newdimen,\newskip}
121 % \DoNotIndex{\nopagebreak}
122 % \DoNotIndex{\parfillskip,\parindent,\parskip,\penalty,\raise,\rangle}
123 % \DoNotIndex{\section,\setlength,\TeX,\topsep,\underline,\unskip,\verb}
124 % \DoNotIndex{\vskip,\vspace,\widetilde,\\,\%,\@date,\@defpar}
125 % \DoNotIndex{\[,\{,\},\]}
126 % \DoNotIndex{\count@,\ifnum,\loop,\today,\uppercase,\uccode}
127 % \DoNotIndex{\baselineskip,\begin,\tw@}
128 % \DoNotIndex{\a,\b,\c,\d,\e,\f,\g,\h,\i,\j,\k,\l,\m,\n,\o,\p,\q}
129 % \DoNotIndex{\r,\s,\t,\u,\v,\w,\x,\y,\z,\A,\B,\C,\D,\E,\F,\G,\H}
130 % \DoNotIndex{\I,\J,\K,\L,\M,\N,\O,\P,\Q,\R,\S,\T,\U,\V,\W,\X,\Y,\Z}
131 % \DoNotIndex{\1,\2,\3,\4,\5,\6,\7,\8,\9,\0}
132 % \DoNotIndex{\!,\#,\$,\&,\',\(,\),\+,\.,\:,\;,\<,\=,\>,\?,\_}
133 % \DoNotIndex{\discretionary,\immediate,\makeatletter,\makeatother}
134 % \DoNotIndex{\meaning,\newenvironment,\par,\relax,\renewenvironment}
135 % \DoNotIndex{\repeat,\scriptsize,\selectfont,\the,\undefined}
136 % \DoNotIndex{\arabic,\do,\makeindex,\null,\number,\show,\write,\@ehc}
137 % \DoNotIndex{\@author,\@ehc,\@ifstar,\@sanitize,\@title,\everypar}
138 % \DoNotIndex{\if@minipage,\if@restonecol,\ifeof,\ifmmode}
139 % \DoNotIndex{\lccode,\newtoks,\onecolumn,\openin,\p@,\SelfDocumenting}
140 % \DoNotIndex{\settowidth,\@resetonecoltrue,\@resetonecolfalse,\bf}
141 % \DoNotIndex{\clearpage,\closein,\lowercase,\@inlabelfalse}
142 % \DoNotIndex{\selectfont,\mathcode,\newmathalphabet,\rmdefault}
143 % \DoNotIndex{\bfdefault}
144 %
145 % \MakeShortVerb{\|}
146 % \setcounter{StandardModuleDepth}{1}
147 %
148 % {\catcode`\p=12 \catcode`\t=12 ^^A hack used later on to print a
149 % \gdef\dimenvalue#1pt{$#1$pt}} ^^A register value with a - sign
150 %
151 % \newcommand{\DOC}{\texttt{doc}\xspace}
152 %
153 % \changes{v3.0j}{2022/06/02}{Use \cs{providecommand} to define \cs{pkg}}
154 % \providecommand\env{\texttt}
155 % \providecommand\opt{\texttt}
156 % \providecommand\cls{\texttt}
157 % \providecommand\pkg{\texttt}
158 % \providecommand\prg{\textsf}
159 %
160 % \newcommand\DOX{\env{DoX}\xspace}
161 % \newcommand\api{\textsc{api}\xspace}
162 %
163 % \newcommand\fmi[1]{\par\textbf{TODO: }\textit{#1}\par}
164 %
165 % \newcommand\NewIn[1]{\leavevmode
166 % \marginpar{\hfill\fbox{\fbox{New in #1}}\hspace*{1em}}\ignorespaces}
167 %
168 %
169 %\RenewDocElement[macrolike = true ,
170 % toplevel = false,
171 % idxtype = ,
172 % idxgroup = LaTeX commands\actualchar\LaTeX{} commands ,
173 % printtype =
174 % ]{Macro}{macro}
175 %
176 %\RenewDocElement[macrolike = false ,
177 % toplevel = false,
178 % idxtype = env. ,
179 % idxgroup = Package environments,
180 % printtype = \textit{env.}
181 % ]{Env}{environment}
182 %
183 %
184 %\NewDocElement[macrolike = true ,
185 % toplevel = false,
186 % idxtype = ,
187 % idxgroup = Package commands,
188 % printtype =
189 % ]{InterfaceMacro}{imacro}
190 %
191 %\NewDocElement[macrolike = true ,
192 % toplevel = false,
193 % idxtype = ,
194 % idxgroup = Package commands (obsolete),
195 % printtype =
196 % ]{ObsoleteInterfaceMacro}{omacro}
197 %
198 %\NewDocElement[macrolike = false ,
199 % toplevel = false,
200 % idxtype = counter ,
201 % idxgroup = LaTeX counters\actualchar \LaTeX{} counters ,
202 % printtype = \textit{counter}
203 % ]{LaTeXCounter}{lcounter}
204 %
205 %\NewDocElement[macrolike = true ,
206 % toplevel = false,
207 % idxtype = counter ,
208 % idxgroup = TeX counters\actualchar \protect\TeX{} counters ,
209 % printtype = \textit{counter}
210 % ]{TeXCounter}{tcounter}
211 %
212 %
213 %\NewDocElement[macrolike = true ,
214 % toplevel = false,
215 % idxtype = skip ,
216 % idxgroup = LaTeX length\actualchar \LaTeX{} length (skip) ,
217 % printtype = \textit{skip}
218 % ]{LaTeXSkip}{lskip}
219 %
220 %\NewDocElement[macrolike = true ,
221 % toplevel = false,
222 % idxtype = dimen ,
223 % idxgroup = LaTeX length\actualchar \LaTeX{} length (dimen) ,
224 % printtype = \textit{dimen}
225 % ]{LaTeXDimen}{ldimen}
226 %
227 %\NewDocElement[macrolike = false ,
228 % toplevel = false,
229 % idxtype = option ,
230 % idxgroup = Package options ,
231 % printtype = \textit{option}
232 % ]{Option}{option}
233 %
234 % \renewcommand\code[1]{\mbox{$\ell$-#1}}
235 % \renewcommand\main[1]{\underline{\mbox{$\ell$-#1}}}
236 % \setcounter{IndexColumns}{2}
237 %
238 %
239 % \changes{v1.9t}{1995/05/11}{Use \cs{GetFileInfo}}
240 % \GetFileInfo{doc.sty}
241 %
242 % \CheckSum{0}
243 %
244 % \title{The \DOC{} and \texttt{shortvrb} Packages\thanks
245 % {This file has version number \fileversion{} dated \filedate{}.}}
246 % \author{Frank Mittelbach\thanks{Further commentary added at Royal
247 % Military College of Science by B. Hamilton Kelly; English
248 % translation of parts of the original German commentary
249 % provided by Andrew Mills; fairly substantial additions,
250 % particularly from \texttt{newdoc}, and
251 % documentation of post-v1.5q features added at v1.7a by Dave
252 % Love (SERC Daresbury Lab).}~\thanks
253 % {Extraction of \texttt{shortvrb}
254 % package added by Joachim Schrod (TU~Darmstadt).}~\thanks
255 % {Version~3 now integrates code from Didier Verna's
256 % \DOX package and some of his documentation was
257 % reused (a.k.a.\ stolen).}}
258 % \date{Printed \today}
259 %
260 % \MaintainedByLaTeXTeam{latex}
261 %
262 % \maketitle
263 %
264 % \begin{abstract}
265 % Roughly 30 years ago (version 1.0 was dated 1988/05/05) I wrote
266 % the first version of the \DOC package, a package to provide code
267 % documentation for \TeX{} code. Since then it has been used all
268 % over the place to document the \LaTeX{} kernel and most of the
269 % packages that are nowadays available. The core code of version 2
270 % (which is the current version) exists since 1998, i.e., for 20
271 % years.
272 %
273 % If I would restart from scratch I would do a lot of things
274 % differently these days and in fact several other people have
275 % tried to come up with better solutions. However, as the saying
276 % goes, a bad standard is better than none, \DOC has prevailed and
277 % changing it now in incompatible ways is probably not really
278 % helpful.
279 %
280 % So this is version 3 of the package with some smaller extensions
281 % that are upwards compatible but hopefully serve well. Most
282 % important modifications are the integration of the
283 % \pkg{hypdoc} package to enable links within the document (in
284 % particular from the index) if so desired. Also integrated are the
285 % ideas from the \DOX package by Didier Verna (although I
286 % offer a different interface that imho fits better with the rest
287 % of \DOC's interfaces). Finally I updated a few odds and ends.
288 % \end{abstract}
289 %
290 %
291 % \newpage
292 %
293 % \addtocontents{toc}{\protect\begin{multicols}{2}}
294 %
295 % ^^A{\parskip 0pt ^^A We have to reset \parskip
296 % ^^A (bug in \LaTeX)
297 % \tableofcontents
298 % ^^A}
299 %
300 % \changes{v1.7a}{1992/02/25}{Miscellaneous small changes to the text}
301 % \changes{v3.0a}{2018/03/04}{Integrated DoX package}
302 % \changes{v3.0a}{2018/03/04}{Interfaced hypdoc package}
303 %
304 %
305 %
306 % \section{Introduction}
307 %
308 % This is a new version of the \DOC package, written roughly 30 years
309 % after the initial release. As the package has been used for so long
310 % (and largely unchanged)
311 % it is absolutely important to preserve existing interfaces, even if
312 % we can agree that they could have been done better.
313 %
314 % So this is a light-weight change, basically adding hyperlink support
315 % and adding a way to provide generally \DOC elements (not just macros
316 % and environments) and try to do this properly (which wasn't the case
317 % for environments either in the past). The ideas for this have been
318 % stolen from the \DOX package by Didier Verna even though I
319 % didn't keep his interfaces.
320 %
321 % Most of the documentation below is from the earlier release which
322 % accounts for some inconsistencies in presentation, mea culpa.
323 %
324 %
325 % \section{The User Interface}\label{sec:interface}
326 % \subsection{The driver file}
327 %
328 % If one is going to document a set of macros with the \DOC{}
329 % package one has to prepare a special driver file which produces the
330 % formatted document. This driver file has the following
331 % characteristics:
332 % \begin{quote}
333 % \noindent |\documentclass|\oarg{options}^^A
334 % \marg{document-class}\\[1pt]
335 % |\usepackage{doc}|\\[3pt]
336 % \hspace*{10pt}\meta{preamble}\\[3pt]
337 % |\begin{document}|\\[3pt]
338 % \hspace*{10pt}\meta{special input commands}\\[3pt]
339 % |\end{document}|
340 % \end{quote}
341 % The \meta{document-class} might be any document class, I usually
342 % use \texttt{article}.
343 %
344 % In the \meta{preamble} one should place declarations which
345 % manipulate the behavior of the \DOC{} package like
346 % |\DisableCrossrefs| or |\OnlyDescription|.
347 %
348 %
349 % \DescribeInterfaceMacro\DocInput \DescribeInterfaceMacro\IndexInput
350 % Finally
351 % the \meta{special input commands} part should contain one or
352 % more |\DocInput|\marg{file name} and/or
353 % |\IndexInput|\marg{file name} commands. The
354 % |\DocInput| command is used for files prepared for the
355 % \DOC{} package whereas |\IndexInput| can be used for all kinds of
356 % macro files. See page \pageref{..Input} for more details of
357 % |\IndexInput|. Multiple |\DocInput|s can be used with a
358 % number of included files which are each self-contained
359 % self-documenting packages---for instance, each containing
360 % |\maketitle|.
361 %
362 % As an example, the driver file for the \DOC{} package itself is
363 % the following text surrounded by |%<*driver>| and |%</driver>|.
364 % To produce the documentation you can simply run the \texttt{.dtx}
365 % file through \LaTeX{} in which case this code will be executed
366 % (loading the document class \texttt{ltxdoc}, etc.) or you can
367 % extract this into a separate file by using
368 % the \texttt{docstrip} program.
369 % The line numbers below are added by
370 % \DOC{}'s formatting.
371 % Note that the class \cls{ltxdoc} has the \DOC{} package
372 % preloaded.
373 % \changes{v1.7a}{1992/03/06}{Added
374 % docstrip-derivable driver file as example.}
375 % \changes{v1.7c}{1992/04/01}{Expurgated ltugboat.sty from driver.}
376 % \begin{macrocode}
377 %<*driver>
378 \documentclass{ltxdoc}
379
380 \usepackage[T1]{fontenc}
381 \usepackage{xspace}
382
383 \OnlyDescription
384
385 \EnableCrossrefs
386 %\DisableCrossrefs % Say \DisableCrossrefs if index is ready
387 \CodelineIndex
388 \RecordChanges % Gather update information
389 \SetupDoc{reportchangedates}
390 %\OnlyDescription % comment out for implementation details
391 \setlength\hfuzz{15pt} % don't show so many
392 \hbadness=7000 % over- and underfull box warnings
393 \begin{document}
394 \DocInput{doc.dtx}
395 \end{document}
396 %</driver>
397 % \end{macrocode}
398 %
399 % \RecordIndexType{\CodelineIndex}{InterfaceMacro}
400 % \RecordIndexType{\DisableCrossrefs}{InterfaceMacro}
401 % \RecordIndexType{\DocInput}{InterfaceMacro}
402 % \RecordIndexType{\EnableCrossrefs}{InterfaceMacro}
403 % \RecordIndexType{\OnlyDescription}{InterfaceMacro}
404 % \RecordIndexType{\RecordChanges}{InterfaceMacro}
405 % \RecordIndexType{\hbadness}{TeXCounter}
406 % \RecordIndexType{\hfuzz}{LaTeXDimen}
407 %
408 %
409 % \subsection{Package options}
410 %
411 % \NewIn{v3}
412 % Starting with version~3 the \DOC package now offers a small number
413 % of package options to modify its overall behavior. These are:
414 % \DescribeOption[noprint]{multicol}
415 % \DescribeOption[noprint]{nomulticol}
416 % \DescribeOption[noprint]{hyperref}
417 % \DescribeOption[noprint]{nohyperref}
418 % \DescribeOption[noprint]{debugshow}
419 % \DescribeOption[noprint]{noindex}
420 % \DescribeOption[noprint]{noprint}
421 % \DescribeOption[noprint]{reportchangedates}
422 % \begin{description}
423 % \item[\opt{hyperref}, \opt{nohyperref}] Boolean (default \texttt{true}). Load the
424 % \pkg{hyperref} package and make index references to code lines
425 % and pages and other items clickable links. \opt{nohyperref} is
426 % the complementary key.
427 %
428 % \item[\opt{multicol}, \opt{nomulticol}] Boolean (default \texttt{true}). Load the
429 % \pkg{multicol} package for use in typesetting the index and the
430 % list of changes. \opt{nomulticol} is
431 % the complementary key.
432 %
433 % \item[\opt{debugshow}] Boolean (default \texttt{false}). Provide
434 % various tracing information at the terminal and in the transcript
435 % file. In particular show which elements are indexed.
436 %
437 % \item[\opt{noindex}] Boolean (default \texttt{false}). If set, all
438 % automatic indexing is suppressed. This option can also be used on
439 % individual elements as described below.
440 %
441 % \item[\opt{noprint}] Boolean (default \texttt{false}). If set, then
442 % printing of element names in the margin will be suppressed. This
443 % option can also be used on individual elements as described
444 % below.
445 % \item[\opt{reportchangedates}] Boolean (default \texttt{false}). If
446 % set, then change entries list the date after the version number in
447 % the change log.
448 % \end{description}
449 %
450 % \DescribeInterfaceMacro{\SetupDoc} Instead of providing options to the \DOC
451 % package you can call \cs{SetupDoc} and provide them there. This
452 % allows, for example, to change default values in case \DOC was already
453 % loaded earlier.
454 %
455 %
456 %
457 % \subsection{General conventions}
458 %
459 % A \TeX{} file prepared to be used with the `doc' package
460 % consists of `documentation parts' intermixed with `definition
461 % parts'.
462 %
463 % Every line of a `documentation part' starts with a percent sign
464 % (|%|) in column one. It may contain arbitrary \TeX{} or
465 % \LaTeX{} commands except that the character `|%|' cannot be
466 % used as a comment character.
467 % \SortIndex{\string^\string^A}{\string\verb\verbatimchar
468 % \string^\string^A\verbatimchar \encapchar usage}^^A
469 % \SortIndex{\string^\string^X}{\string\verb\verbatimchar
470 % \string^\string^X\verbatimchar \encapchar usage}
471 % To allow user
472 % comments, the characters |^^A| and |^^X| are both defined as a comment character
473 % later on.\footnote{In version 2 it was only
474 % \texttt{\string^\string^A}, but many keyboards combine
475 % \texttt{\string^} and \texttt{A} and automatically turn it into
476 % ``Ä''; so \texttt{\string^\string^X} was added as an
477 % alternative in version 3.}
478 % Such `metacomments' may be also be included simply by
479 % surrounding them with |\iffalse| \ldots~|\fi|.
480 %
481 % All other parts of the file are called `definition parts'. They
482 % contain fractions of the macros described in the `documentation
483 % parts'.
484 %
485 % If the file is used to define new macros (e.g.\ as a package file in
486 % the |\usepackage| macro), the `documentation parts' are
487 % bypassed at high speed and the macro definitions are pasted
488 % together, even if they are split into several `definition parts'.
489 %
490 % \DescribeEnv{macrocode}
491 % On the other hand, if the documentation of these macros is to be
492 % produced, the `definition parts' should be typeset verbatim. To
493 % achieve this, these parts are surrounded by the \env{macrocode}
494 % environment.
495 % More exactly: before a `definition part' there should be a line
496 % containing
497 % \begin{flushleft}
498 % \hspace*{\MacroIndent}\verb*+% \begin{macrocode}+
499 % \end{flushleft}
500 % and after this part a line
501 % \begin{flushleft}
502 % \hspace*{\MacroIndent}\verb*+% \end{macrocode}+
503 % \end{flushleft}
504 % There must be {\em exactly\/} four spaces between the |%|
505 % and |\end{macrocode}| --- \TeX{} is looking for this string
506 % and not for the macro while processing a `definition part'.
507 %
508 % Inside a `definition part' all \TeX{} commands are allowed; even the
509 % percent sign could be used to suppress unwanted spaces etc.
510 %
511 % \DescribeEnv{macrocode*} Instead of the \env{macrocode}
512 % environment one can also use the \env{macrocode$*$} environment
513 % which produces the same results except that spaces are printed as
514 % \nopagebreak\verb*+ + characters.
515 %
516 %
517 %
518 % \subsection{Describing the usage of macros and environments}
519 %
520 % \DescribeInterfaceMacro\DescribeMacro
521 % When you describe a new macro you may use |\DescribeMacro| to
522 % indicate that at this point the usage of a specific macro is
523 % explained. It takes one argument which will be printed in the margin
524 % and also produces a special index entry. For example, I used
525 % |\DescribeMacro{\DescribeMacro}| to make clear that this is the
526 % point where the usage of |\DescribeMacro| is explained.
527 %
528 % As the argument to |\DescribeMacro| is a command name, many people
529 % got used to using the (incorrect) short form, i.e., omitting the
530 % braces around the argument as in |\DescribeMacro\foo|. This does
531 % work as long as the macro name consists only of ``letters''.
532 % However, if the name contains special characters that are normally
533 % not of type ``letter'' (such as |@|, or in case of \pkg{expl3} |_|
534 % and |:|) this will fail dramatically. |\DescribeMacro| would then
535 % receive only a partial command name (up to the first ``non-letter'')
536 % e.g., |\DescribeMacro\foo@bar| would be equivalent to
537 % |\DescribeMacro{\foo} @bar| and you can guess that this can
538 % resulting in both incorrect output and possibly low-level error
539 % messages.
540 %
541 % \DescribeInterfaceMacro\DescribeEnv
542 % An analogous macro |\DescribeEnv| should be used to indicate that a
543 % \LaTeX{} environment is explained. It will produce a somewhat
544 % different index entry and a slightly different display in the
545 % margin. Below I used |\DescribeEnv{verbatim}|.
546 %
547 %
548 % \NewIn{v3}
549 % Starting with version~3 the \cs{Describe...} commands accept an
550 % optional argument in which you can specify either \opt{noindex}
551 % or \opt{noprint} to suppress indexing or printing for that
552 % particular instance. Using both would be possible too, but pointless
553 % as then the commands wouldn't do anything any more.
554 %
555 %
556 % \subsection{Describing the definition of macros and environments}
557 %
558 % \DescribeEnv{macro}
559 % To describe the definition of a (new) macro we use the \env{macro}
560 % environment. It has one argument: the name of the new
561 % macro.\footnote{This is a change to the style design I described in
562 % ^^A \TUB ^^A removed in case ltugboat.sty not used
563 % \textsl{TUGboat\/}\ 10\#1 (Jan.~89). We finally decided
564 % that it would
565 % be better to use the macro name {\em with\/} the
566 % backslash as an argument.}
567 % This argument is also used to print the name in the margin and to
568 % produce an index entry.
569 % Actually the index entries for usage and definition are different to
570 % allow an easy reference.
571 % This environment might be nested. In this case the
572 % labels in the margin are placed under each other.
573 % \changes{v1.7a}{1992/02/26}{Note on need for some text in macro env.}
574 % There should be some text---even if it's just an empty
575 % |\mbox{}|---in this environment before |\begin{macrocode}| or the
576 % marginal label won't print in the right place.
577 %
578 % \NewIn{v3}
579 % In fact it is now allowed to specify several macros in the argument,
580 % separated by commas. This is a short form for starting several
581 % \env{macro} environments in direct succession. Of course, you
582 % should then have also only one matching |\end{macro}|.
583 %
584 % \DescribeLaTeXSkip\MacrocodeTopsep
585 % \DescribeLaTeXSkip\MacroTopsep
586 % There also exist four style parameters: |\MacrocodeTopsep| and
587 % |\MacroTopsep| are used to control the vertical spacing above
588 % and below the \env{macrocode} and the \env{macro}
589 % \DescribeLaTeXDimen\MacroIndent
590 % environment, |\MacroIndent| is used to indent the lines of code
591 % and
592 % \DescribeInterfaceMacro\MacroFont \label{sec:macrofont}
593 % |\MacroFont| holds the font and a possible size change command
594 % for the code lines, the |verbatim|[|*|] environment and the macro
595 % names printed in the margin. If you want
596 % to change their default values in a
597 % class file (like \texttt{ltugboat.cls}) use the |\DocstyleParms|
598 % command described below. Starting with release 2.0a it can now
599 % be changed directly as long as the redefinition happens before
600 % the |\begin{document}| (if you change it later you might see strange
601 % typesetting effects if you are unlucky).
602 %
603 % |\MacroFont| does not alter the font of
604 % |\verb| or |\verb*| because it is often used to make the font size of
605 % the code displays smaller, which would look odd if used within a
606 % paragraph. If you decide to use a different font family and want to
607 % use the same family with
608 % |\verb| you need to alter the font setup for |\ttfamily| in addition
609 % to |\MacroFont|.
610 %
611 % \DescribeEnv{environment}
612 % For documenting the definition of environments one can use the
613 % environment \texttt{environment} which works like the \texttt{macro}
614 % environment, except that it expects an \meta{env-name}
615 % (without a backslash)
616 % as its argument and internally provides different index
617 % entries suitable for environments.
618 % Nowadays you can alternatively specify a comma-separated list of environments.
619 %
620 % \NewIn{v3}
621 % Starting with version~3 these environments accept an optional
622 % argument in which you can specify \opt{noindex} or \opt{noprint} or
623 % both to suppress indexing or printing for that particular
624 % instance. If any such setting is made on the environment level it
625 % overwrites whatever default was given when the \DOC element was
626 % defined or when the package was loaded.
627 %
628 %
629 %
630 %
631 % \subsection{Formatting names in the margin}
632 %
633 % \DescribeInterfaceMacro\PrintDescribeMacro
634 % \DescribeInterfaceMacro\PrintDescribeEnv
635 % \DescribeInterfaceMacro\PrintMacroName
636 % \DescribeInterfaceMacro\PrintEnvName
637 % As mentioned earlier, some macros and environment
638 % print their arguments in the margin. The actual formatting is done by four
639 % macros which are user
640 % definable.\footnote{You may place the changed definitions in a
641 % separate package
642 % file or at the beginning of the documentation
643 % file.
644 % For example, if you don't like any names in the
645 % margin
646 % but want a fine index you can simply redefine them
647 % accept their argument and do nothing with it.}
648 % They are named |\PrintDescribeMacro| and |\PrintDescribeEnv| (defining
649 % how |\DescribeMacro| and |\DescribeEnv| behave) and
650 % |\PrintMacroName| and
651 % |\PrintEnvName| (called by the \env{macro} and \env{environment}
652 % environments, respectively).
653 %
654 %
655 % \subsection{Providing further documentation items}
656 %
657 % Out of the box the \DOC package offers the above commands and
658 % environments to document macros and environments.
659 % \NewIn{v3}
660 % With version 3
661 % this has now been extended in a generic fashion so that you can
662 % easily provide your own items, such as counters, length register,
663 % options etc.
664 %
665 % \DescribeInterfaceMacro{\NewDocElement}
666 % The general syntax for providing a new \DOC element is
667 % \begin{quote}
668 % \cs{NewDocElement}\oarg{options}\marg{element-name}\marg{env-name}
669 % \end{quote}
670 % By convention the \meta{element-name} has the first letter
671 % uppercased as in \texttt{Env} or \texttt{Macro}.
672 %
673 % Such a declaration will define for you
674 % \begin{itemize}
675 % \item the command |\Describe|\meta{element-name} which has the
676 % syntax
677 % \begin{quote}
678 % |\Describe|\meta{element-name}\oarg{options}\marg{element}
679 % \end{quote}
680 %
681 % \item the environment \meta{env-name} which has the syntax
682 % \begin{quote}
683 % \cs{begin}\marg{env-name}\oarg{options}\marg{element}
684 % \end{quote}
685 %
686 % \item the display command |\PrintDescribe|\meta{element-name} with
687 % the syntax
688 % \begin{quote}
689 % |\PrintDescribe|\meta{element-name}\marg{element}
690 % \end{quote}
691 %
692 % \item and the
693 % |\Print|\meta{element-name}|Name| display command for the
694 % environment.
695 % \end{itemize}
696 % If any of the commands or the environment is already defined (which
697 % especially with the \meta{env-name} is a danger) then you will
698 % receive an error telling you so.
699 %
700 % \DescribeInterfaceMacro{\RenewDocElement}
701 % If you want to modify an existing \DOC element use
702 % |\RenewDocElement| instead.
703 %
704 % For example, the already provided ``\texttt{Env}'' \DOC element could have been
705 % defined simply by making the declaration
706 % |\NewDocElement{Env}{environment}|
707 % though that's not quite what has been done, as we will see later.
708 %
709 % \DescribeInterfaceMacro{\ProvideDocElement}
710 % This declaration does nothing when the doc element is already
711 % declared, otherwise it works like \cs{NewDocElement}. It can be
712 % useful if you have many documentation files that you may want to
713 % process individually as well as together.
714 %
715 % \DescribeOption[noprint]{macrolike}
716 % \DescribeOption[noprint]{envlike}
717 % \DescribeOption[noprint]{toplevel}
718 % \DescribeOption[noprint]{notoplevel}
719 % \DescribeOption[noprint]{idxtype}
720 % \DescribeOption[noprint]{printtype}
721 % \DescribeOption[noprint]{idxgroup}
722 % The \meta{options} are keyword/value and define further details on
723 % how that \DOC element should behave. They are:
724 % \begin{description}
725 % \item[\opt{macrolike}] Boolean (default \opt{false}). Does this \DOC
726 % element starts with a backslash?
727 %
728 % \item[\opt{envlike}] Boolean. Complementary option to
729 % \opt{macrolike}.
730 %
731 % \item[\opt{toplevel}] Boolean (default \opt{true}). Should all
732 % a top-level index entry be made? If set to \texttt{false} then
733 % either no index entries are produced or only grouped index entries
734 % (see \opt{idxgroup} for details).
735 %
736 % \item[\opt{notoplevel}] Boolean. Complementary option to
737 % \opt{toplevel}.
738 %
739 % \item[\opt{idxtype}] String (default \meta{env-name}). What to put
740 % (in parentheses if non-empty) at the end of a top-level index entry.
741 %
742 % \item[\opt{printtype}] String (default \meta{env-name}). What to put
743 % (in parentheses if non-empty) after an element name in the margin.
744 %
745 % \item[\opt{idxgroup}] String (default
746 % \meta{env-name}\texttt{s}). Name of the top-level index entry if
747 % entries are grouped. They are only grouped if this option is
748 % non-empty.
749 %
750 % \item[\opt{noindex}] Boolean (default \texttt{false}). If set this
751 % will suppress indexing for elements of this type. This setting
752 % overwrite any global setting of \opt{noindex}.
753 %
754 % \item[\opt{noprint}] Boolean (default \texttt{false}). If set this
755 % will suppress printing the element name in the margin. This setting
756 % overwrite any global setting of \opt{noprint}.
757 % \end{description}
758 % As usual giving a boolean option without a value sets it to
759 % \texttt{true}.
760
761
762
763
764 % \subsection{Displaying sample code verbatim}
765 %
766 % \DescribeEnv{verbatim}
767 % It is often a good idea to include examples of the usage of new macros
768 % in the text. Because of the |%| sign in the first column of every
769 % row, the \env{verbatim} environment is slightly altered to suppress
770 % those
771 % characters.\footnote{These macros were written by Rainer
772 % Schöpf~\cite{art:verbatim}. He also
773 % provided a new \env{verbatim} environment
774 % which can be used inside of other macros.}
775 % \DescribeEnv{verbatim*}
776 % The \env{verbatim$*$} environment is changed in the same way.
777 % \changes{v1.7a}{1992/02/26}{Documented \cs{verb} change.}
778 % \DescribeInterfaceMacro\verb
779 % The |\verb| command is re-implemented to give an error report if a
780 % newline appears in its argument.
781 % The \env{verbatim} and \env{verbatim$*$} environments set text
782 % in the style defined by |\MacroFont|~(\S\ref{sec:macrofont}).
783 %
784 %
785
786 % \subsection{Using a special escape character}
787 %
788 % \DescribeInterfaceMacro\SpecialEscapechar
789 % If one defines complicated macros it is sometimes necessary to
790 % introduce a new escape character because the `|\|' has got a
791 % special |\catcode|. In this case one can use
792 % |\SpecialEscapechar| to indicate which character is actually
793 % used to play the r\^ole of the `|\|'. A scheme like this is
794 % needed because the \env{macrocode} environment and its counterpart
795 % \env{macrocode$*$} produce an index entry for every occurrence of a
796 % macro name. They would be very confused if you didn't tell them that
797 % you'd changed |\catcode|$\,$s. The argument to
798 % |\SpecialEscapechar| is a single-letter control sequence, that
799 % is, one has to use \verb=\|= for example to denote that `\verb+|+'
800 % is used as an escape character. |\SpecialEscapechar| only
801 % changes the behavior of the next \env{macrocode} or
802 % \env{macrocode$*$} environment.
803 %
804 % The actual index entries created will all be printed with |\|
805 % rather than \verb+|+, but this probably reflects their usage, if not
806 % their definition, and anyway must be preferable to not having any
807 % entry at all. The entries {\em could\/} be formatted appropriately,
808 % but the effort is hardly worth it, and the resulting index might be
809 % more confusing (it would certainly be longer!).
810 %
811 %
812 % \subsection{Cross-referencing all macros used}
813 %
814 % \DescribeInterfaceMacro\DisableCrossrefs \DescribeInterfaceMacro\EnableCrossrefs As
815 % already mentioned, every macro name used within a
816 % \env{macrocode} or \env{macrocode$*$} environment will produce an
817 % index entry. In this way one can easily find out where a specific
818 % macro is used. Since \TeX{} is considerably slower\footnote{This
819 % comment was written about 30 years ago. \TeX{} is still considerably
820 % slower but while it took minutes to process a large document (such
821 % as the \LaTeX{} kernel documentation) it takes seconds or less these
822 % days. Thus \cs{DisableCrossrefs} isn't really that necessary these
823 % days.} when it has to produce such a bulk of index entries one can
824 % turn off this feature by using |\DisableCrossrefs| in the driver
825 % file. To turn it on again just use
826 % |\EnableCrossrefs|.\footnote{Actually, \cs{EnableCrossrefs} changes
827 % things more drastically; any following call to \cs{DisableCrossrefs}
828 % which might be present in the source will be ignored.}
829 %
830 %
831 % \DescribeInterfaceMacro\DoNotIndex
832 % But also finer control is provided. The |\DoNotIndex| macro
833 % takes a list of macro names separated by commas. Those names won't
834 % show up in the index. You might use several |\DoNotIndex|
835 % commands: their lists will be concatenated. In this article I used
836 % |\DoNotIndex| for
837 % all macros which are already defined in \LaTeX.
838 %
839 % All three above declarations are local to the current group.
840 %
841 % Production (or not) of the index (via the |\makeindex| command) is
842 % controlled by using or omitting the following declarations in the
843 % driver file preamble; if neither is used, no index is produced.
844 % \DescribeInterfaceMacro\PageIndex Using |\PageIndex| makes all index
845 % entries refer to their page number; with
846 % \DescribeInterfaceMacro\CodelineIndex |\CodelineIndex|, index entries
847 % produced by |\DescribeMacro| and |\DescribeEnv| and possibly further
848 % |\Describe...| commands refer to a page number
849 % but those produced by the \env{macro} environment (or other \DOC
850 % element environments) refer to the
851 % code lines, which will be numbered automatically.\footnote{The line
852 % number is actually that of the first line of the first
853 % \env{macrocode} environment in the \env{macro} environment.}
854 % \DescribeInterfaceMacro\theCodelineNo
855 % The style of this numbering can be controlled by defining the macro
856 % |\theCodelineNo|. Its default definition is to use scriptsize
857 % arabic numerals; a user-supplied definition won't be overwritten.
858 %
859 % \DescribeInterfaceMacro\CodelineNumbered
860 % When you don't wish to get an index but want your code lines
861 % numbered use |\CodelineNumbered| instead of |\CodelineIndex|. This
862 % prevents the generation of an unnecessary |.idx| file.
863 %
864 %
865 % \subsection{Producing the actual index entries}
866 %
867 % Several of the aforementioned macros will produce some sort of index
868 % entries. These entries have to be sorted by an external
869 % program---the current implementation assumes that the
870 % \prg{makeindex} program by Chen~\cite{art:Chen} is used.
871 %
872 % But this isn't built in: one has only to redefine some of the
873 % following macros to be able to use any other index program. All
874 % macros which are installation
875 % dependent are defined in such a way that they won't overwrite a
876 % previous definition. Therefore it is safe to put the changed
877 % versions in a package file which might be read in before the doc
878 % package.
879 %
880 % To allow the user to change the specific characters recognized by
881 % his or her index program all characters which have special meaning
882 % in the \prg{makeindex} program are given symbolic
883 % names.\footnote{I don't know if there exists a program which needs
884 % more command characters, but I hope not.}
885 % However, all characters used should be of |\catcode| other than
886 % `letter' (11).
887 %
888 % \DescribeInterfaceMacro{\actualchar}
889 % The |\actualchar| is used to separate the `key' and the actual
890 % index entry.
891 % \DescribeInterfaceMacro{\quotechar}
892 % The |\quotechar| is used before a special index program
893 % character to suppress its special meaning.
894 % \DescribeInterfaceMacro{\encapchar}
895 % The |\encapchar| separates the indexing information from a
896 % letter string which \prg{makeindex} uses as a \TeX{} command to
897 % format the page number associated with a special entry. It is used
898 % in this package to apply the |\main| and the |\usage|
899 % commands.
900 % \DescribeInterfaceMacro{\levelchar}
901 % Additionally |\levelchar| is used to separate `item',
902 % `subitem' and `subsubitem' entries.
903 %
904 % It is a good idea to stick to these symbolic names even if you know
905 % which index program is used. In this way your files will be
906 % portable.
907 %
908 % \fmi{describe old \cs{SpecialMainIndex} and \cs{SpecialUsageIndex}}
909 %
910 % \DescribeInterfaceMacro\SpecialMainMacroIndex
911 % \DescribeInterfaceMacro\SpecialMainEnvIndex
912 % To produce a main index entry for a macro the
913 % |\SpecialMainMacroIndex| macro\footnote{This macro is called by the
914 % \env{macro} environment.} may be used. It is called `special'
915 % because it has to print its argument verbatim.
916 % A similar macro, called |\SpecialMainEnvIndex| is used for indexing
917 % the main definition point of an
918 % environment.\footnote{This macro is called by the
919 % \env{environment} environment.}
920 %
921 % \DescribeInterfaceMacro\SpecialMacroIndex
922 % \DescribeInterfaceMacro\SpecialEnvIndex
923 % To index the usage of a macro or an environment
924 % |\SpecialMacroIndex| and |\SpecialEnvIndex| may be used.
925 %
926 % All these macros are normally used by other macros; you will need
927 % them only in an emergency.
928 %
929 % \NewIn{v3}
930 % If further code elements are declared with
931 % |\NewDocElement|\marg{name}\texttt{...} then this sets up
932 % additional indexing commands, e.g.,
933 % \cs{SpecialMain\meta{name}Index}.
934 %
935 % \DescribeInterfaceMacro\SpecialIndex
936 % The \env{macrocode} environment is automatically indexing macros
937 % (normally by code line number). You can (with care) also do this
938 % manually by
939 % |\SpecialIndex|. However, note that if |\CodelineIndex| is used
940 % this will generate an entry referring to the last code line which is
941 % usually not what you want. It does, however, make some sense if you
942 % always refer to pages only, i.e., if you use |\PageIndex|.
943 %
944 % \DescribeInterfaceMacro\SpecialShortIndex
945 % \NewIn{v3}
946 % For single character macros, e.g., |\{|, doesn't always work
947 % correctly.
948 % For this reason there is now also
949 % a special variant the can produce correct index entries for them.
950 %
951 % \DescribeInterfaceMacro\SortIndex
952 % Additionally a |\SortIndex| command is provided. It takes two
953 % arguments---the sort key and the actual index entry.
954 %
955 % \DescribeInterfaceMacro\verbatimchar
956 % But there is one characteristic worth mentioning: all macro names in
957 % the index are typeset with the |\verb*| command. Therefore one
958 % special character is needed to act as a delimiter for this command.
959 % To allow a change in this respect, again this character is
960 % referenced indirectly, by the macro |\verbatimchar|. It expands
961 % by default to \verb?+? but if your code lines contain macros with
962 % `\texttt{+}' characters in their names (e.g.\ when you use \verb?\+?)
963 % then that caused a problem because you ended up with an
964 % index entry containing \verb?\verb+\++?
965 % which will be typeset as `\verb+\++' and not as `\verb?\+?'.
966 % \NewIn{v3}
967 % In version 3 this is now automatically taken care of (with the help
968 % of the |\SpecialShortIndex| command).
969 %
970 % \DescribeInterfaceMacro\*
971 % We also provide a |\*| macro. This is intended to be used for
972 % index entries like
973 % \begin{quote}
974 % index entries \\
975 % \hspace*{30pt} Special macros for \*
976 % \end{quote}
977 % Such an entry might be produced with the line
978 %\begin{verbatim}
979 % \index{index entries>Special macros for \*}
980 %\end{verbatim}
981 % assuming that \verb=>= is the \cs{levelchar} used by the index
982 % processor.
983
984 % You can't use \cs{levelchar} in this situation because if \cs{index}
985 % is directly used in the document then it's argument is written out
986 % fully verbatim. However, if you define your own index commands,
987 % expansion will happen on the way to the \texttt{.idx} file; and in
988 % that case you can use \cs{levelchar}---this is what the \pkg{doc}
989 % macros do. This then allows to change the indexing syntax easily, e.g.,
990 %\begin{verbatim}
991 % \newcommand\ltxconcept[2]{\index{#1\levelchar#2}}
992 % ...
993 % \ltxconcept{index entries}{Special macros for \*}
994 %\end{verbatim}
995 %
996 %
997 % \subsection{Setting the index entries}
998 %
999 % \changes{v1.7a}{1992/03/11}{Usage note on gind.ist.} After the first
1000 % formatting pass through the \texttt{.dtx} file you need to sort the
1001 % index entries written to the \texttt{.idx} file using
1002 % \prg{makeindex} or your favorite alternative. You need a
1003 % suitable style file for \prg{makeindex} (specified by the
1004 % \texttt{-s} switch). A suitable one is supplied with \DOC{},
1005 % called \texttt{gind.ist}.
1006 %
1007 % \DescribeInterfaceMacro\PrintIndex
1008 % To read in and print the sorted index, just put the
1009 % |\PrintIndex| command as the last (commented-out, and thus
1010 % executed during the documentation pass through the file) command
1011 % in your package file. Precede it by any bibliography commands
1012 % necessary for your citations.
1013 % Alternatively, it may be more convenient to put all such calls
1014 % amongst the arguments of the |\MaybeStop| macro, in
1015 % which case a |\Finale| command should appear at the end of
1016 % your file.
1017 %
1018 % \DescribeEnv{theindex}
1019 % Contrary to standard \LaTeX, the index is typeset in three columns
1020 % by default.
1021 % \DescribeLaTeXCounter{IndexColumns}
1022 % This is controlled by the \LaTeX{} counter
1023 % `\textsf{IndexColumns}' and can therefore be changed with a
1024 % |\setcounter| declaration. Additionally one doesn't want to
1025 % start a new page unnecessarily. Therefore the \env{theindex}
1026 % environment is redefined.
1027 % \DescribeLaTeXDimen\IndexMin
1028 % When the \env{theindex} environment starts it will measure how much
1029 % space is left on the current page. If this is more than
1030 % |\IndexMin| then the index will start on this page. Otherwise
1031 % |\newpage| is called.
1032 %
1033 % Then a short introduction about the meaning of several index entries
1034 % is typeset (still in onecolumn mode). Afterwards the actual index
1035 % entries follow in multi-column mode.
1036 % \DescribeInterfaceMacro\IndexPrologue
1037 % You can change this prologue with the help of the
1038 % |\IndexPrologue| macro. Actually the section heading is also
1039 % produced in this way, so you'd better write something like:
1040 % \begin{verbatim}
1041 % \IndexPrologue{\section*{Index} The index entries underlined ...}
1042 %\end{verbatim}
1043 % When the \env{theindex} environment is finished the last page will
1044 % be reformatted to produce balanced columns. This improves the layout
1045 % and allows the next article to start on the same page.
1046 % \DescribeInterfaceMacro\IndexParms
1047 % Formatting of the index columns (values for |\columnssep|
1048 % etc.)\ is controlled by the |\IndexParms| macro. It assigns the
1049 % following values:
1050 % \SpecialLaTeXDimenIndex{\parindent}\SpecialLaTeXDimenIndex{\columnsep}^^A
1051 % \SpecialLaTeXSkipIndex{\parskip}\SpecialLaTeXSkipIndex{\rightskip}^^A
1052 % \SpecialLaTeXDimenIndex{\mathsurround}\SpecialLaTeXSkipIndex{\parfillskip}
1053 % \begin{center}
1054 % \begin{tabular}{l@{\,=\,}ll@{\,=\,}l}
1055 % |\parindent| & \IndexParms \the\parindent &
1056 % |\columnsep| & \IndexParms \the\columnsep \\
1057 % |\parskip| & \IndexParms \the\parskip &
1058 % |\rightskip| & \IndexParms
1059 % \expandafter\dimenvalue\the\rightskip \\
1060 % |\mathsurround| & \IndexParms \the\mathsurround &
1061 % |\parfillskip| & \IndexParms
1062 % \expandafter\dimenvalue\the\parfillskip
1063 % \end{tabular}
1064 % \end{center}
1065 % \DescribeInterfaceMacro{\@idxitem}
1066 % Additionally it defines |\@idxitem| (which will be used when an
1067 % |\item| command is encountered) and selects |\small| size.
1068 % If you want to change any of these values you have to define them
1069 % all.
1070 %
1071 % \DescribeInterfaceMacro\main
1072 % \DescribeInterfaceMacro\usage
1073 % \DescribeInterfaceMacro\code
1074 % The page numbers for main index entries are encapsulated by the
1075 % |\main| macro (underlining its argument) and the numbers
1076 % denoting the description are encapsulated by the |\usage| macro
1077 % (which produces \textit{italics}). |\code| encapsulates page or code
1078 % line numbers in entries generated by parsing the code inside
1079 % \env{macrocode} environments. As usual these commands are user
1080 % definable.
1081 %
1082 %
1083 % \subsection{Changing the default values of style parameters}
1084 %
1085 % \DescribeInterfaceMacro\DocstyleParms If you want to overwrite some default
1086 % settings made by the \DOC{} package, you can either put your
1087 % declarations in the driver file (that is after \texttt{doc.sty} is
1088 % read in) or use a separate package file for doing this work. In the
1089 % latter case you can define the macro |\DocstyleParms| to contain all
1090 % assignments. This indirect approach is necessary if your package file
1091 % might be read before the \texttt{doc.sty}, when some of the
1092 % registers are not allocated. Its default definition is null.
1093 %
1094 % The doc package currently assigns values to the following
1095 % registers:
1096 % \SpecialLaTeXDimenIndex{\IndexMin}^^A
1097 % \SpecialLaTeXSkipIndex{\MacrocodeTopsep}^^A
1098 % \SpecialLaTeXSkipIndex{\MacroTopsep}^^A
1099 % \SpecialLaTeXDimenIndex{\MacroIndent}^^A
1100 % \SpecialLaTeXDimenIndex{\marginparpush}^^A
1101 % \SpecialLaTeXDimenIndex{\marginparwidth}^^A
1102 % \SpecialTeXCounterIndex{\tolerance}
1103 % \begin{center}
1104 % \begin{tabular}{l@{\,=\,}ll@{\,=\,}l}
1105 % |\IndexMin| & \the\IndexMin &
1106 % |\MacroTopsep| & \the\MacroTopsep \\
1107 % |\marginparwidth|& \the\marginparwidth &
1108 % |\MacroIndent| & \the\MacroIndent \\
1109 % |\marginparpush| & \the\marginparpush &
1110 % |\MacrocodeTopsep| & \the\MacrocodeTopsep \\
1111 % |\tolerance| & \the\tolerance
1112 % \end{tabular}
1113 % \end{center}
1114 %
1115 %
1116 % \subsection{Short input of verbatim text pieces}
1117 %
1118 % \DescribeInterfaceMacro\MakeShortVerb
1119 % \DescribeInterfaceMacro{\MakeShortVerb*} \DescribeInterfaceMacro\DeleteShortVerb It is
1120 % awkward to have to type, say, \verb"\verb|"\ldots\verb"|" continually when
1121 % quoting
1122 % verbatim bits (like macro names) in the text, so an abbreviation
1123 % mechanism is provided. Pick a character \meta{c}---one which
1124 % normally has catcode `other' unless you have very good reason not
1125 % to---which you don't envisage using in the text, or not using often.
1126 % (I like |"|, but you may prefer \verb"|" if you have |"| active to do
1127 % umlauts, for instance.) Then if you say
1128 % |\MakeShortVerb{\|\meta{c}|}| you can subsequently use
1129 % \meta{c}\meta{text}\meta{c} as the equivalent of
1130 % |\verb|\meta{c}\meta{text}\meta{c}; analogously, the |*|-form
1131 % |\MakeShortVerb*{\|\meta{c}|}| gives you the equivalent of
1132 % |\verb*|\meta{c}\meta{text}\meta{c}. Use
1133 % |\DeleteShortVerb{\|\meta{c}|}| if you subsequently want \meta{c} to
1134 % revert to its previous meaning---you can always turn it on again
1135 % after the unusual section. The `short verb' commands make global
1136 % changes. The abbreviated |\verb| may not appear in the argument of
1137 % another command just like |\verb|. However the `short verb'
1138 % character may be used freely in the \env{verbatim} and
1139 % \env{macrocode} environments without ill effect.
1140 % |\DeleteShortVerb| is silently ignored if its argument does not
1141 % currently represent a short verb character. Both commands type a
1142 % message to tell you the meaning of the character is being changed.
1143 %
1144 % Please remember that the command |\verb| cannot be used in arguments
1145 % of other commands. Therefore abbreviation characters for |\verb|
1146 % cannot be used there either.
1147 %
1148 % This feature is also available as a sole package, \texttt{shortvrb}.
1149 %
1150 %
1151 % \subsection{Additional bells and whistles}
1152 %
1153 % We provide macros for logos such as \Web, \AmSTeX, \BibTeX,
1154 % \SliTeX{} and \PlainTeX. Just type |\Web|, |\AmSTeX|,
1155 % |\BibTeX|, |\SliTeX| or |\PlainTeX|, respectively.
1156 % \LaTeX{} and \TeX{} are already defined in \texttt{latex.tex}.
1157 %
1158 % \DescribeInterfaceMacro\meta
1159 % Another useful macro is |\meta| which has one argument and
1160 % produces something like \meta{dimen parameter}.
1161 %
1162 % \DescribeInterfaceMacro\OnlyDescription
1163 % \DescribeInterfaceMacro\MaybeStop
1164 % \DescribeObsoleteInterfaceMacro\StopEventually
1165 % You can use the |\OnlyDescription| declaration in the driver
1166 % file to suppress the last part of your document (which presumably
1167 % exhibits the code). To make this work
1168 % \NewIn{v3}
1169 % you have to place the command |\MaybeStop| at a suitable
1170 % point in your file. This macro\footnote{For about 30 years this
1171 % macro was called \cs{StopEventually} which was due to a ``false
1172 % friend'' misunderstanding. In the German language the word
1173 % ``eventuell'' mean roughly ``perhaps'' which isn't quite the same
1174 % as ``eventually''. But given that this is now used for so long
1175 % and all over the place we can't drop the old name. So it is still
1176 % there to allow processing all the existing documentation.}
1177 % has one argument in which you put
1178 % all information you want to see printed if your document ends at
1179 % this point (for example a bibliography which is normally printed at
1180 % the very end). When the |\OnlyDescription| declaration is
1181 % missing the |\MaybeStop|
1182 % \DescribeInterfaceMacro\Finale
1183 % macro saves its argument in a macro called |\Finale| which can
1184 % afterwards be used to get things back (usually at the very end).
1185 % Such a scheme makes changes in two places unnecessary.
1186 %
1187 % Thus you can use this feature to produce a local guide for the
1188 % \TeX{} users which describes only the usage of macros (most of them
1189 % won't be interested in your definitions anyway). For the same
1190 % reason the |\maketitle| \DescribeInterfaceMacro\maketitle command is slightly
1191 % changed to allow multiple titles in one document. So you can make
1192 % one driver file reading in several articles at once.
1193 % \DescribeInterfaceMacro{\ps@titlepage} To avoid an unwanted
1194 % \textsf{pagestyle} on the title page the |\maketitle| command issues
1195 % a |\thispagestyle{titlepage}| declaration which produces a
1196 % \textsf{plain} page if the \textsf{titlepage} page style is
1197 % undefined. This allows class files like \cls{ltugboat.cls} to
1198 % define their own page styles for title pages.
1199 %
1200 % \DescribeInterfaceMacro\AlsoImplementation
1201 % Typesetting the whole document is the default. However, this default
1202 % can also be explicitly selected using the declaration
1203 % |\AlsoImplementation|. This overwrites any previous
1204 % |\OnlyDescription| declaration. The \LaTeXe{} distribution, for
1205 % example, is documented using the \texttt{ltxdoc} class which allows
1206 % for a configuration file \texttt{ltxdoc.cfg}. In such a file one
1207 % could then add the statement
1208 % \begin{quote}
1209 % |\AtBeginDocument{\AlsoImplementation}|
1210 % \end{quote}
1211 % to make sure that all documents will show the code part.
1212 %
1213 % \DescribeInterfaceMacro\IndexInput \label{..Input} Last but not least I
1214 % defined an |\IndexInput| macro which takes a file name as an
1215 % argument and produces a verbatim listing of the file, indexing every
1216 % command as it goes along. This might be handy, if you want to learn
1217 % something about macros without enough documentation. I used this
1218 % feature to cross-reference \texttt{latex.tex} getting a verbatim
1219 % copy with about 15 pages index.\footnote{It took quite a long time
1220 % and the resulting \texttt{.idx} file was longer than the
1221 % \texttt{.dvi} file. Actually too long to be handled by the
1222 % \prg{makeindex} program directly (on our MicroVAX) but the final
1223 % result was worth the trouble.}
1224 %
1225 % \changes{v2.1d}{2006/02/02}{Corrected description of \cs{changes}
1226 % macro.}
1227 % \DescribeInterfaceMacro\changes
1228 % To maintain a change history within the file, the |\changes|
1229 % command may be placed amongst the description part of the changed
1230 % code. It takes three arguments, thus:
1231 % \begin{quote}
1232 % |\changes{|\meta{version}|}{|\meta{date}|}{|^^A
1233 % \meta{text}|}|
1234 % \end{quote}
1235 % The changes may be used to produce an auxiliary file (\LaTeX's
1236 % |\glossary| mechanism is used for this) which may be printed
1237 % after suitable formatting. The |\changes| macro generates the
1238 % printed entry in such a change history; because old
1239 % versions\footnote{Before 2.6.} of the \prg{makeindex}
1240 % program limit such fields to 64 characters, care should be taken
1241 % not to exceed this limit when describing the change. The actual
1242 % entry consists of the \meta{version}, the |\actualchar|, the current
1243 % macro name, a colon, the |\levelchar|, and, finally, the \meta{text}.
1244 % The result is a glossary entry for the \meta{version}, with the name of
1245 % the current macro as subitem. Outside the |macro| environment, the
1246 % text |\generalname| is used instead of the macro name. When
1247 % referring to macros in change descriptions it is conventional to use
1248 % |\cs{|\meta{macroname}|}| rather than attempting to format it properly
1249 % and using up valuable characters in the entry with old \prg{makeindex}
1250 % versions.
1251 %
1252 % Note that in the history listing, the entry is shown with the page number
1253 % that corresponds to its place in the source, e.g., general changes put at the
1254 % very beginning of the file will show up with page number ``1'', change entries
1255 % placed elsewhere might have different numbers (not necessarily always
1256 % very useful unless you are careful).
1257 %
1258 %
1259 % \changes{v1.7a}{1992/02/26}{Description of \cs{RecordChanges} etc.
1260 % added
1261 % to interface section.} \DescribeInterfaceMacro\RecordChanges To cause the
1262 % change information to be written out, include |\RecordChanges| in
1263 % the driver file. \DescribeInterfaceMacro\PrintChanges To read in and print
1264 % the sorted change history (in two columns), just put the
1265 % |\PrintChanges| command as the last (commented-out, and thus
1266 % executed during the documentation pass through the file) command in
1267 % your package file. Alternatively, this command may form one of the
1268 % arguments of the |\MaybeStop| command, although a change
1269 % history is probably {\em not\/} required if only the description is
1270 % being printed. The command assumes that \prg{makeindex} or some
1271 % other program has processed the \texttt{.glo} file to generate a
1272 % sorted \texttt{.gls} file. You need a special \prg{makeindex}
1273 % style file; a suitable one is supplied with \DOC{}, called
1274 % \texttt{gglo.ist}.
1275 %
1276 % \DescribeLaTeXDimen\GlossaryMin
1277 % \DescribeInterfaceMacro\GlossaryPrologue
1278 % \DescribeInterfaceMacro\GlossaryParms
1279 % \DescribeLaTeXCounter{GlossaryColumns}
1280 % The
1281 % |\GlossaryMin|, |\GlossaryPrologue| and |\GlossaryParms| macros and
1282 % the counter \texttt{GlossaryColumns} are
1283 % analogous to the |\Index|\ldots\ versions. (The \LaTeX{} `glossary'
1284 % mechanism is used for the change entries.)
1285 %
1286 %
1287 % \DescribeInterfaceMacro\bslash
1288 % From time to time, it is necessary to print a |\| without
1289 % being able to use the |\verb| command because the
1290 % |\catcode|$\,$s of the symbols are already firmly
1291 % established. In this instance we can use the command
1292 % |\bslash| presupposing, of course, that the actual font in
1293 % use at this point contains a `backslash' as a symbol. Note that
1294 % this definition of |\bslash| is expandable; it inserts a
1295 % $|\|_{12}$. This means that you have to |\protect|
1296 % it if it is used in `moving arguments'.
1297 %
1298 % \DescribeInterfaceMacro\MakePrivateLetters
1299 % \changes{v1.7a}{1992/02/26}{Documented \cs{MakePrivateLetters} in
1300 % interface section}^^A
1301 % If your macros |\catcode| anything other than |@| to `letter', you
1302 % should redefine |\MakePrivateLetters| so that it also makes the
1303 % relevant characters `letters' for the benefit of the indexing. The
1304 % default definition is just |\makeatletter|.
1305 %
1306 % \DescribeInterfaceMacro\DontCheckModules \DescribeInterfaceMacro\CheckModules
1307 % \DescribeInterfaceMacro\Module \DescribeInterfaceMacro\AltMacroFont The `module'
1308 % directives of the \prg{docstrip} system \cite{art:docstrip} are
1309 % normally recognized and invoke special formatting. This can be
1310 % turned on and off in the \texttt{.dtx} file or the driver file using
1311 % |\CheckModules| and |\DontCheckModules|. If checking for module
1312 % directives is on (the default) then code in the scope of the
1313 % directives is set as determined by the hook |\AltMacroFont|, which
1314 % gives {\small\ttfamily\itshape small italic type\-writer\/} by
1315 % default in the New Font Selection Scheme but just ordinary
1316 % {\small\ttfamily small type\-writer} in the old one, where a font
1317 % such as italic typewriter can't be used portably (plug for NFSS);
1318 % you will need to override this if you don't have the italic
1319 % typewriter font available. Code is in such a scope if it's on a
1320 % line beginning with |%<| or is between lines starting with
1321 % |%<*|\meta{name list}|>| and |%</|\meta{name list}|>|. The
1322 % directive is formatted by the macro |\Module| whose single argument
1323 % is the text of the directive between, but not including, the angle
1324 % brackets; this macro may be re-defined in the driver or package file
1325 % and by default produces results like \Module{+foo\string|bar} with no
1326 % following space.
1327 %
1328 % \DescribeLaTeXCounter{StandardModuleDepth} Sometimes (as in this file) the
1329 % whole code is surrounded by modules to produce several files from a
1330 % single source. In this case it is clearly not appropriate to format
1331 % all code lines in a special |\AltMacroFont|. For this reason a
1332 % counter |StandardModuleDepth| is provided which defines the level of
1333 % module nesting which is still supposed to be formatted in
1334 % |\MacroFont| rather then |\AltMacroFont|. The default setting is
1335 % |0|, for this documentation it was set to
1336 %\begin{verbatim}
1337 % \setcounter{StandardModuleDepth}{1}
1338 %\end{verbatim}
1339 % at the beginning of the file.
1340 %
1341 %
1342 % \section{Examples and basic usage summary}
1343 %
1344 % \subsection{Basic usage summary}
1345 % \changes{v1.7a}{1992/03/11}{Added basic usage summary to spell
1346 % it out.}
1347 %
1348 % To sum up, the basic structure of a \texttt{.dtx} file without any
1349 % refinements is like this:
1350 % \begin{verse}\small
1351 % |% |\meta{waffle}\ldots\\
1352 % \quad\ldots \\
1353 % |% \DescribeMacro{\fred}|\\
1354 % |% |\meta{description of fred's use}\\
1355 % \quad\ldots\\
1356 % |% \MaybeStop{|\meta{finale code}|}|\\
1357 % \quad\ldots\\
1358 % |% \begin{macro}{\fred}|\\
1359 % |% |\meta{commentary on macro fred}\\
1360 % \verb*+% \begin{macrocode}+\\
1361 % \meta{code for macro fred}\\
1362 % \verb*+% \end{macrocode}+\\
1363 % |% \end{macro}|\\
1364 % \quad\ldots\\
1365 % |% \Finale \PrintIndex \PrintChanges|
1366 % \end{verse}
1367 % For further examples of the use of most---if not all---of the features
1368 % described above, consult the \texttt{doc.dtx} source itself.
1369 %
1370 %
1371 %
1372 % \subsection{Examples}
1373 %
1374 % The default setup includes definitions for the \DOC elements
1375 % ``macro'' and ``environment''. They correspond to the following
1376 % declarations:
1377 %\begin{verbatim}
1378 % \NewDocElement[macrolike = true ,
1379 % idxtype = ,
1380 % idxgroup = ,
1381 % printtype =
1382 % ]{Macro}{macro}
1383 %
1384 % \NewDocElement[macrolike = false ,
1385 % idxtype = env. ,
1386 % idxgroup = environments ,
1387 % printtype = \textit{env.}
1388 % ]{Env}{environment}
1389 %\end{verbatim}
1390 %
1391 % To showcase the new features of \DOC version 3 to some extend, the
1392 % current documentation is done by redefining these declarations and
1393 % also adding a few additional declarations on top.
1394 %
1395 % For any internal command we document we use \texttt{Macro} and put
1396 % all of them under the heading ``\LaTeX{} commands'' (note the use of \cs{actualchar}):
1397 %\begin{verbatim}
1398 %\RenewDocElement[macrolike = true ,
1399 % toplevel = false,
1400 % idxtype = ,
1401 % idxgroup = LaTeX commands\actualchar\LaTeX{} commands ,
1402 % printtype =
1403 % ]{Macro}{macro}
1404 %\end{verbatim}
1405 %
1406 % We only have package environments so we use \texttt{Env} for those
1407 % and group them as well:
1408 %\begin{verbatim}
1409 %\RenewDocElement[macrolike = false ,
1410 % toplevel = false,
1411 % idxtype = env. ,
1412 % idxgroup = Package environments,
1413 % printtype = \textit{env.}
1414 % ]{Env}{environment}
1415 %\end{verbatim}
1416 %
1417 %
1418 % All the interface commands are also grouped together under the label
1419 % ``Package commands'', we use \texttt{InterfaceMacro} for them:
1420 %\begin{verbatim}
1421 %\NewDocElement[macrolike = true ,
1422 % toplevel = false,
1423 % idxtype = ,
1424 % idxgroup = Package commands,
1425 % printtype =
1426 % ]{InterfaceMacro}{imacro}
1427 %\end{verbatim}
1428 %
1429 % And since we also have a few obsolete interfaces we add yet another category:
1430 %\begin{verbatim}
1431 %\NewDocElement[macrolike = true ,
1432 % toplevel = false,
1433 % idxtype = ,
1434 % idxgroup = Package commands (obsolete),
1435 % printtype =
1436 % ]{ObsoleteInterfaceMacro}{omacro}
1437 %\end{verbatim}
1438 %
1439 % Another type of category are the package keys:
1440 %\begin{verbatim}
1441 %\NewDocElement[macrolike = false ,
1442 % toplevel = false,
1443 % idxtype = key ,
1444 % idxgroup = Package keys ,
1445 % printtype = \textit{key}
1446 % ]{Key}{key}
1447 %\end{verbatim}
1448 %
1449 % Finally we have \TeX{} counters (with a backslash in front) and
1450 % \LaTeX{} counters (no backslash) and the two types of \LaTeX{}
1451 % length registers:
1452 %\begin{verbatim}
1453 %\NewDocElement[macrolike = true ,
1454 % toplevel = false,
1455 % idxtype = counter ,
1456 % idxgroup = TeX counters\actualchar \protect\TeX{} counters ,
1457 % printtype = \textit{counter}
1458 % ]{TeXCounter}{tcounter}
1459 %
1460 %\NewDocElement[macrolike = false ,
1461 % toplevel = false,
1462 % idxtype = counter ,
1463 % idxgroup = LaTeX counters\actualchar \LaTeX{} counters ,
1464 % printtype = \textit{counter}
1465 % ]{LaTeXCounter}{lcounter}
1466 %
1467 %\NewDocElement[macrolike = true ,
1468 % toplevel = false,
1469 % idxtype = skip ,
1470 % idxgroup = LaTeX length\actualchar \LaTeX{} length (skip) ,
1471 % printtype = \textit{skip}
1472 % ]{LaTeXSkip}{lskip}
1473 %
1474 %\NewDocElement[macrolike = true ,
1475 % toplevel = false,
1476 % idxtype = dimen ,
1477 % idxgroup = LaTeX length\actualchar \LaTeX{} length (dimen) ,
1478 % printtype = \textit{dimen}
1479 % ]{LaTeXDimen}{ldimen}
1480 %
1481 %\end{verbatim}
1482 %
1483 % And we modify the appearance of the index: just 2 columns not 3 and
1484 % all the code-line entries get prefixed with an ``$\ell$'' (for line)
1485 % so that they can easily be distinguished from page index entries.
1486 %\begin{verbatim}
1487 % \renewcommand\code[1]{\mbox{$\ell$-#1}}
1488 % \renewcommand\main[1]{\underline{\mbox{$\ell$-#1}}}
1489 % \setcounter{IndexColumns}{2}
1490 %\end{verbatim}
1491 %
1492 %
1493 %
1494 % \section{Incompatibilities between version 2 and 3}
1495 %
1496 % The basic approach when developing version~3 was to provide a very
1497 % high level of compatibility with version~2 so that nearly all
1498 % older documents should work out of the box without the need for
1499 % any adjustments.
1500 %
1501 % But as with any change there are situations where that change can
1502 % result in some sort of incompatibility, e.g., if a newly introduce
1503 % command name was already been defined in the user document then
1504 % there will be a conflict that is nearly impossible to avoid
1505 % 100\%.
1506 %
1507 % As mentioned earlier, \DOC now supports options on several commands
1508 % and environments and as a result it is necessary to use braces
1509 % around the argument for \cs{DescribeMaro} if the ``macro to be
1510 % described'' uses private letters such as |@| or |_| as part of its
1511 % name. That was always the official syntax but in the past you could
1512 % get away with leaving out the braces more often than you can now.
1513 %
1514 % The old \DOC documentation also claimed that redefinitions of things
1515 % like \cs{PrintDescribeMacro} could be done before loading the
1516 % package (and not only afterwards) and \DOC would in that case not
1517 % change those commands. As the setup mechanisms are now much more
1518 % powerful and general such an approach is not really good. So with
1519 % \DOC version~3 modifications have to be done after the \DOC package
1520 % got loaded and the last modification will always win.
1521 %
1522 % I'm temped to drop compatibility with \LaTeX~2.09 (but so far I
1523 % have left it in).
1524 %
1525 % In the past it was possible to use macros declared with \cs{outer}
1526 % in the argument of \verb=\begin{macro}= or \cs{DoNotIndex} even
1527 % though \cs{outer} is not a concept supported in \LaTeX{}. This is no
1528 % longer possible. More exactly, it is no longer possible to prevent
1529 % them from being indexed (as \cs{DoNotIndex} can't be used), but you
1530 % can pass them to the \env{macro} environment as follows:
1531 %\begin{verbatim}
1532 % \begin{macro}[outer]{\foo}
1533 %\end{verbatim}
1534 % if \cs{foo} is a macro declared with \cs{outer}. The technical
1535 % reason for this change is that in the past various other commands,
1536 % such as |\{| or |\}| did not work properly in these arguments when
1537 % they where passed as ``strings'' and not as single macro tokens. But
1538 % by switching to macro tokens we can't have \cs{outer} macros because
1539 % their feature is to be not allowed in arguments. So what happens
1540 % above when you use \texttt{[outer]} is that the argument is read as
1541 % a string with four character tokens so that it is not recognized as
1542 % being \cs{outer}.
1543 %
1544 %
1545 % \section{Old interfaces no longer really needed}
1546 %
1547 % Thirty years is a long time in the life of computer programs, so
1548 % there are a good number of interfaces within \DOC that are really
1549 % only of historical interest (or when processing equally old sources).
1550 % We list them here, but in general we suggest that for new
1551 % documentation they should not be used.
1552 %
1553 %
1554 % \subsection{\prg{makeindex} bugs}
1555 %
1556 % \DescribeObsoleteInterfaceMacro\OldMakeindex
1557 % Versions of \prg{makeindex} prior to 2.9 had some bugs affecting
1558 % \DOC{}. One of these,
1559 % pertaining to the |%| character doesn't have a work-around
1560 % appropriate for versions with and without the
1561 % bug.\label{makeindex:version} If
1562 % you really still have an old version, invoke |\OldMakeindex| in a
1563 % package file or the driver file to prevent problems with index entries
1564 % such as |\%|, although you'll probably normally want to turn off
1565 % indexing of |\%| anyway. Try to get an up-to-date \prg{makeindex}
1566 % from one of the \TeX{} repositories.
1567 %
1568 % \subsection{File transmission issues}
1569 %
1570 % In the early days of the Internet file transmission issues have been
1571 % a serious problem. There was a famous gateway in Rochester, UK that
1572 % handled the traffic from the European continent to the UK and that
1573 % consisted of two IBM machines running with different codepages (that
1574 % had non-reversible differences). As a result ``strange'' \TeX{}
1575 % characters got replaced with something else with the result that the
1576 % files became unusable.
1577 %
1578 % To guard against this problem (or rather to detect it if something
1579 % got broken in transfer I added code to \DOC to check a static
1580 % character table and also to have a very simple checksum feature
1581 % (counting backslashes).
1582 %
1583 % These days the \cs{CheckSum} is of little value (and a lot of pain
1584 % for the developer) and character scrambling doesn't happen any more
1585 % so the \cs{CharacterTable} is essentially useless. Thus neither
1586 % should be used in new developments.
1587 %
1588 % \label{sec:checksum}
1589 % \DescribeObsoleteInterfaceMacro\CharacterTable
1590 % \DescribeObsoleteInterfaceMacro\CheckSum
1591 % To overcome some of the problems of sending files over the networks
1592 % we developed two macros which should detect corrupted files. If one
1593 % places the lines
1594 % \begin{flushleft}
1595 % \small\ttfamily ^^A \ttfamily to get the blanks between "..."s
1596 % ^^A right
1597 %|%%\CharacterTable|\\
1598 %|%% {Upper-case |
1599 %|\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z|\\
1600 %|%% Lower-case |
1601 %|\a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z|\\
1602 %|%% Digits \0\1\2\3\4\5\6\7\8\9|\\
1603 %|%% Exclamation \! Double quote "|
1604 %| Hash (number) \#|\\
1605 %|%% Dollar \$ Percent \% Ampersand \&|\\
1606 %|%% Acute accent \' Left paren \( Right paren \)|\\
1607 %|%% Asterisk \* Plus \+ Comma \,|\\
1608 %|%% Minus \- Point \. Solidus \/|\\
1609 %|%% Colon \: Semicolon \; Less than \<|\\
1610 %|%% Equals \= Greater than \> Question mark \?|\\
1611 %|%% Commercial at \@ Left bracket \[ Backslash \\|\\
1612 %|%% Right bracket \] Circumflex \^ Underscore \_|\\
1613 %|%% Grave accent \` Left brace \{ Vertical bar |\verb=|=\\
1614 %|%% Right brace \} Tilde \~}|\\
1615 %|%%|
1616 %\end{flushleft}
1617 % at the beginning of the file then character translation failures
1618 % will be detected, provided of course, that the used \DOC{}
1619 % package has a correct default table. The percent
1620 % signs\footnote{There are two percent signs in each line. This has
1621 % the effect that these lines are not removed by the
1622 % \texttt{docstrip.tex} program.} at the beginning of the lines should
1623 % be typed in, since only the \DOC{} package should look at this
1624 % command.
1625 %
1626 %
1627 % Another problem of mailing files is possible truncation. To detect
1628 % these sort of errors we provide a |\CheckSum| macro. The check-sum
1629 % of a file is simply the number of backslashes in the code, i.e.\ all
1630 % lines between the \env{macrocode} environments. But don't be
1631 % afraid: you don't have count the code-lines yourself; this is done
1632 % by the \DOC{} package for you. You simply have add
1633 % \begin{quote}
1634 % |% \CheckSum{0}|
1635 % \end{quote}
1636 % near the beginning of the file and use the |\MaybeStop| (which
1637 % starts looking for backslashes) and the |\Finale| command. The
1638 % latter will inform you either that your file has no check-sum
1639 % (telling you the right number) or that your number is incorrect if
1640 % you put in anything other than zero but guessed wrong (this time
1641 % telling you both the correct and the incorrect one). Then you go to
1642 % the top of your file again and change the line to the right number,
1643 % i.e., line
1644 % \begin{quote}
1645 % |% \CheckSum{|\meta{number}|}|
1646 % \end{quote}
1647 % and that's all.
1648 %
1649 % While |\CharacterTable| and |\CheckSum| have been important features
1650 % in the early days of the public internet when \DOC{} was written as
1651 % the mail gateways back then were rather unreliable and often mangled
1652 % files they are these days more a nuisance than any help. They are
1653 % therefore now fully optional and no longer recommended for use with
1654 % new files.
1655 %
1656 %
1657
1658
1659
1660 % ^^A =============================================================
1661
1662
1663
1664 % \begin{multicols}{2}[\medskip \noindent\rule{\textwidth}{.3pt}
1665 % \section{Introduction to previous releases}]
1666 %
1667 % \begin{quote}
1668 % \textbf{Original abstract:}
1669 % This package contains the definitions that are necessary to
1670 % format the documentation of package files. The package was
1671 % developed in Mainz in cooperation with the Royal Military College
1672 % of Science. This is an update which documents various changes
1673 % and new features in \DOC{} and integrates the features of
1674 % \env{newdoc}.
1675 % \end{quote}
1676 %
1677 % The \TeX{} macros which are described here allow definitions and
1678 % documentation to be held in one and the same file. This has the
1679 % advantage that normally very complicated instructions are made
1680 % simpler to understand by comments inside the definition. In addition
1681 % to this, updates are easier and only one source file needs to be
1682 % changed. On the other hand, because of this, the package files are
1683 % considerably longer: thus \TeX{} takes longer to load them. If this
1684 % is a problem, there is an easy remedy: one needs only to run the
1685 % \texttt{docstrip.tex} program that removes nearly all lines that begin
1686 % with a
1687 % percent sign.
1688 %
1689 % The idea of integrated documentation was born with the development
1690 % of the \TeX{} program; it was crystallized in Pascal with the \Web{}
1691 % system. The advantages of this method are plain to see (it's easy
1692 % to make comparisons \cite{art:Knuthliterat}). Since this
1693 % development, systems similar to \Web{} have been developed for other
1694 % programming languages. But for one of the most complicated
1695 % programming languages (\TeX) the documentation has however been
1696 % neglected. The \TeX{} world seems to be divided between:---
1697 % \begin{itemize} \item a couple of ``wizards'', who produce many
1698 % lines of completely unreadable code ``off the cuff'', and \item many
1699 % users who are amazed that it works just how they want it to do. Or
1700 % rather, who despair that certain macros refuse to do what is
1701 % expected of them.\end{itemize}
1702 %
1703 % I do not think that the \Web{} system is {\em the\/} reference work;
1704 % on the contrary, it is a prototype which suffices for the
1705 % development of programs within the \TeX{} world. It is sufficient,
1706 % but not totally sufficient.\footnote{I know that this will be seen
1707 % differently by a few people, but this product should not be seen as
1708 % the finished product, at least as far as applications concerning
1709 % \TeX{} are concerned. The long-standing debate over `multiple
1710 % change files' shows this well.} As a result of \Web, new programming
1711 % perspectives have been demonstrated; unfortunately, though, they
1712 % haven't been developed further for other programming languages.
1713 %
1714 % The method of documentation of \TeX{} macros which I have introduced
1715 % here should also only be taken as a first sketch. It is designed
1716 % explicitly to run under \LaTeX{} alone. Not because I was of the
1717 % opinion that this was the best starting point, but because from this
1718 % starting point it was the quickest to develop.\footnote{This
1719 % argument is a bad one, however, it is all too often trotted out.} As
1720 % a result of this design decision, I had to move away from the
1721 % concept of modularization; this was certainly a step backward.
1722 %
1723 % I would be happy if this article could spark off discussion over
1724 % \TeX\ documentation. I can only advise anyone who thinks that they
1725 % can cope without documentation to ``Stop Time'' until he or she
1726 % completely understands the \AmSTeX{} source code.
1727 %
1728 % \subsection*{Using the \DOC{} package}
1729 %
1730 % Just like any other package, invoke it by requesting it with a
1731 % |\usepackage| command in the preamble. \DOC's use of
1732 % |\reversemarginpars| may make it incompatible with some classes.
1733 % \changes{v1.7a}{1992/02/25}{Altered usage info}
1734 %
1735 %
1736 % \end{multicols}
1737 %
1738 %
1739 %
1740 %
1741 % \begin{multicols}{2}[\subsection*{Preface to version 1.7 (from
1742 % around 1992)}]
1743 %
1744 % This version of \texttt{doc.dtx} documents changes which have occurred
1745 % since the last published version \cite{art:doc} but which have been
1746 % present in distributed versions of \texttt{doc.sty} for some time. It
1747 % also integrates the (undocumented) features of the distributed
1748 % \texttt{newdoc.sty}.
1749 %
1750 % The following changes and additions have been made to the user
1751 % interface since the published version~\cite{art:doc}. See
1752 % \S\ref{sec:interface} for more details.
1753 % \begin{description}
1754 % \item[Driver mechanism] |\DocInput| is now used in the driver file
1755 % to input possibly multiple independent \DOC{} files and \DOC{} no
1756 % longer has to be the last package. |\IndexListing| is replaced
1757 % by |\IndexInput|;
1758 % \item[Indexing] is controlled by |\PageIndex| and |\CodelineIndex|,
1759 % one of which must be specified to produce an index---there is no
1760 % longer a |\makeindex| in the default |\DocstyleParms|;
1761 % \item[The \texttt{macro} environment] now takes as argument the
1762 % macro name {\em with\/} the backslash;
1763 % \item[Verbatim text] Newlines are now forbidden inside |\verb| and
1764 % commands |\MakeShortVerb| and |\DeleteShortVerb| are provided for
1765 % verbatim shorthand;
1766 % \item[\texttt{\bslash par}] can now be used in |\DoNotIndex|;
1767 % \item[Checksum/character table support] for ensuring the integrity
1768 % of distributions is added;
1769 % \item[\texttt{\bslash printindex}] becomes |\PrintIndex|;
1770 % \item[\texttt{multicol.sty}] is no longer necessary to use \DOC{} or
1771 % print the documentation (although it is recommended);
1772 % \item[`Docstrip' modules] are recognized and formatted specially.
1773 % \end{description}
1774 %
1775 % As well as adding some completely new stuff,
1776 % the opportunity has been taken to add some commentary to the code
1777 % formerly in \pkg{newdoc} and that added after version 1.5k of
1778 % \DOC. Since (as noted in the sections concerned) this
1779 % commentary wasn't written by Frank Mittelbach but the code was, it is
1780 % probably {\em not\/} true in this case that ``if the code and
1781 % comments disagree both are probably wrong''!
1782 %
1783 % \subsubsection*{Bugs}
1784 %
1785 % There are some known bugs in this version:
1786 % \begin{itemize}
1787 % \item The |\DoNotIndex| command doesn't work for some single
1788 % character commands most noticeable |\%|.
1789 % \item The `General changes' glossary entry would come out after
1790 % macro names with a leading |!| and possibly a leading |"|;
1791 % \item If you have an old version of \prg{makeindex} long |\changes|
1792 % entries will come out strangely and you may find the section
1793 % header amalgamated with the first changes entry. Try to get an
1794 % up-to-date one (see p.~\pageref{makeindex:version});
1795 % \item Because the accompanying \prg{makeindex} style files support
1796 % the inconsistent attribute specifications of older and newer
1797 % versions \prg{makeindex} always complains about three `unknown
1798 % specifier's when sorting the index and changes entries.
1799 % \item If |\MakeShortVerb| and |\DeleteShortVerb| are used with
1800 % single character arguments, e.g., \verb"{|}" instead of \verb"{\|}" chaos
1801 % may happen.
1802 % \end{itemize}
1803 % (Some `features' are documented below.)
1804 %
1805 % \subsubsection*{Wish list}
1806 %
1807 % \begin{itemize}
1808 % \item Hooks to allow |\DescribeMacro| and |\DescribeEnv| to write
1809 % out to a special file information about the package's `exported'
1810 % definitions which they describe. This could subsequently be
1811 % included in the \texttt{docstrip}ped \texttt{.sty} file in a
1812 % suitable form for use by smart editors in command completion,
1813 % spelling checking etc., based on the packages used in a document.
1814 % This would need agreement on a `suitable form'. \item Indexing of
1815 % the modules used in \texttt{docstrip}'s |%<| directives. I'm not
1816 % sure how to index directives containing module combinations; \item
1817 % Writing out bibliographic information about the package; \item Allow
1818 % turning off use of the special font for, say, the next guarded
1819 % block.
1820 % \end{itemize}
1821 %
1822 %
1823 % \end{multicols}
1824
1825
1826 % \subsection*{Acknowledgements}
1827 %
1828 % I would like to thank all folks at Mainz and at the Royal Military
1829 % College of Science for their help in this project. Especially Brian
1830 % and Rainer who pushed everything with their suggestions, bug fixes,
1831 % etc.
1832 %
1833 % A big thank you to David Love who brought the documentation
1834 % up-to-date again, after I neglected this file for more than two
1835 % years. This was most certainly a tough job as many features added to
1836 % \texttt{doc.dtx} after its publication in \textsl{TUGboat\/} have
1837 % been never properly described. Beside this splendid work he kindly
1838 % provided additional code (like ``docstrip'' module formatting) which
1839 % I think every \DOC user will be grateful for.
1840 %
1841 %
1842 % \MaybeStop{
1843 % \begin{thebibliography}{1}
1844 % \bibitem{book:Buerger} \textsc{G. A. B\"urger}.
1845 % \newblock Wunderbare Reisen zu Wasser und zu Lande, Feldzüge
1846 % und lustige Abenteuer des Freyherrn v.\ Münchhausen.
1847 % \newblock London, 1786 \& 1788.
1848 % \bibitem{art:Knuthliterat} \textsc{D. E. Knuth}.
1849 % \newblock Literate Programming.
1850 % \newblock Computer Journal, Vol.~27, \textit{pp}.~97--111,
1851 % May 1984.
1852 % \bibitem{book:KnuthA} \textsc{D. E. Knuth}.
1853 % \newblock Computers \& Typesetting (The \TeX book).
1854 % \newblock Addison-Wesley, Vol. A, 1986.
1855 % \bibitem{art:Chen} \textsc{L. Lamport}.
1856 % \newblock MakeIndex: An Index Processor for \LaTeX.
1857 % \newblock 17 February 1987.
1858 % \newblock (Taken from the file \texttt{makeindex.tex} provided
1859 % with
1860 % the program source code.)
1861 % \bibitem{art:doc} \textsc{Frank Mittelbach}.
1862 % \newblock The \DOC{}-option.
1863 % \newblock \textsl{TUGboat}, Vol.~10(2), \textit{pp}.~245--273,
1864 % July 1989.
1865 % \bibitem{art:docstrip} \textsc{Frank Mittelbach, Denys Duchier and
1866 % Johannes Braams}.
1867 % \newblock \texttt{docstrip.dtx}.
1868 % \newblock The file is part of core \LaTeX{}.
1869 % \bibitem{book:Raspe} \textsc{R. E. Raspe} (*1737, \dag 1797).
1870 % \newblock Baron Münchhausens narrative of his marvelous
1871 % travels and campaigns in Russia.
1872 % \newblock Oxford, 1785.
1873 % \bibitem{art:verbatim} \textsc{Rainer Schöpf}.
1874 % \newblock A New Implementation of \LaTeX's \texttt{verbatim} and
1875 % \texttt{verbatim*} Environments.
1876 % \newblock File \texttt{verbatim.doc}, version 1.4i.
1877 % \end{thebibliography}
1878 %
1879 % \addtocontents{toc}{\protect\end{multicols}}
1880 %
1881 % \PrintIndex
1882 %
1883 % } ^^A end \MaybeStop
1884 %
1885 %
1886 % \section{The Description of Macros}
1887 %
1888 % Most of the following code is destined for \texttt{doc.sty} after
1889 % processing with \texttt{docstrip} to include the module
1890 % \textbf{style} indicated here. (All code in this file not
1891 % appropriate to \texttt{doc.sty} has to be included explicitly by
1892 % docstrip so that this \texttt{.dtx} file can be used as directly as
1893 % a package file rather than the stripped version.) The usual font
1894 % change for the conditionally-included lines between the
1895 % \Module{*style} and \Module{/style} directives is suppressed since
1896 % only the lines with an explicit directive are special in this file.
1897 % \begin{macrocode}
1898 %<*package>
1899 % \end{macrocode}
1900 % Under \LaTeXe{} the test to avoid reading
1901 % \DOC{} in twice is normally unnecessary. It was kept to only to
1902 % stay compatible with \LaTeX209 styles that |\input| \DOC{}
1903 % directly.
1904 % \changes{v1.5i}{1989/06/07}{Avoid reading the file twice.}
1905 % \begin{macrocode}
1906 \@ifundefined{macro@cnt}{}{\endinput}
1907 % \end{macrocode}
1908 %
1909 % \DescribeObsoleteInterfaceMacro\fileversion
1910 % \DescribeObsoleteInterfaceMacro\filedate
1911 % \DescribeObsoleteInterfaceMacro\docdate
1912 % As you can see I used macros like |\fileversion| to denote the
1913 % version number and the date. They are defined at the very beginning
1914 % of the package file (without a surrounding \env{macrocode}
1915 % environment), so I don't have to search for this place here when I
1916 % change the version number. You can see their actual outcome in a
1917 % footnote to the title.
1918 %
1919 %
1920 % The first thing that we do next is to get ourselves two alternative comment
1921 % signs. Because all sensible signs are already occupied, we will
1922 % choose some that can only be entered indirectly:
1923 % {\DoNotIndex{\^}^^A avoid misinterpretation !!!!! VERIFY
1924 % \begin{macrocode}
1925 \catcode`\^^A=14
1926 \catcode`\^^X=14
1927 % \end{macrocode}
1928 % We repeat this statement at the beginning of the document in case
1929 % the \texttt{inputenc} package is used disabling it again.
1930 % \changes{v2.0b}{1998/05/19}{Init docs private comment char at begin
1931 % of document again (pr2581)}
1932 % \begin{macrocode}
1933 \AtBeginDocument{\catcode`\^^A=14\relax\catcode`\^^X=14\relax}
1934 % \end{macrocode}
1935 % \SortIndex{\string^\string^A}{\string\verb\verbatimchar
1936 % \string^\string^A\verbatimchar
1937 % \encapchar main}^^A
1938 % \SortIndex{\string^\string^X}{\string\verb\verbatimchar
1939 % \string^\string^X\verbatimchar
1940 % \encapchar main}
1941 % }
1942 %
1943 %
1944 % \subsection{Keys supported by \DOC{}}
1945 %
1946 % In the past this used \pkg{kvoptions} but this will be
1947 % replaced by using \texttt{l3keys} at some point in the future.
1948 % Right now this is only a lightweight shift---the code could and
1949 % should be altered further.
1950 % \fmi{cleanup replacement of kvoptions}
1951 %
1952 % Some keys are available as options for use in \cs{usepackage} some are
1953 % for the generated item \api's:
1954 % \changes{v3.0k}{2022/06/22}{Use \cs{DeclareKeys}}
1955 % \changes{v3.0h}{2022/06/01}{fix choice key name (gh/750)}
1956 % \changes{v3.0h}{2022/06/01}{fix default key name (gh/750)}
1957 % \begin{macrocode}
1958 \DeclareKeys
1959 {
1960 noprint .if = {doc@noprint},
1961 noindex .if = {doc@noindex},
1962 hyperref .if = {doc@hyperref},
1963 nohyperref .ifnot = {doc@hyperref},
1964 multicol .if = {doc@multicol},
1965 nomulticol .ifnot = {doc@multicol},
1966 debugshow .if = {doc@debugshow},
1967 reportchangedates .if = {doc@reportchangedates},
1968 toplevel .if = {doc@toplevel},
1969 notoplevel .ifnot = {doc@toplevel},
1970 macrolike .if = {doc@macrolike},
1971 envlike .ifnot = {doc@macrolike},
1972 idxtype .store = \doc@idxtype,
1973 idxgroup .store = \doc@idxgroup,
1974 printtype .store = \doc@printtype,
1975 outer .if = {doc@outer},
1976 }
1977 % \end{macrocode}
1978 %
1979 % Setting these options to true initially.
1980 % \begin{macrocode}
1981 \doc@hyperreftrue
1982 \doc@multicoltrue
1983 \doc@topleveltrue
1984 % \end{macrocode}
1985 %
1986 % \subsection{Processing the package keys}
1987 %
1988 % \begin{macrocode}
1989 \ProcessKeyOptions
1990 % \end{macrocode}
1991 %
1992 %
1993 % \begin{macro}{\ifscan@allowed}
1994 % \begin{macro}{\scan@allowedtrue}
1995 % \begin{macro}{\scan@allowedfalse}
1996 % |\ifscan@allowed| is the switch used to determine if
1997 % the |\active@escape@char|\SpecialIndex{\active@escape@char}
1998 % should start the macro scanning mechanism.
1999 % \begin{macrocode}
2000 \newif\ifscan@allowed \scan@allowedtrue
2001 % \end{macrocode}
2002 % \end{macro}
2003 % \end{macro}
2004 % \end{macro}
2005 %
2006 % \begin{imacro}{\SetupDoc}
2007 %
2008 % We need to save the default value for some options because \DOC elements
2009 % can locally set them.
2010 % \fmi{Use 2e interface for \cs{keys\_set:nn} when available}
2011 % \begin{macrocode}
2012 \def\SetupDoc#1{%
2013 \csname keys_set:nn\endcsname{doc}{#1}%
2014 \edef\doc@noprintdefault{\ifdoc@noprint true\else false\fi}%
2015 \ifdoc@noindex
2016 % \end{macrocode}
2017 % If we do not index by default then we should also turn off
2018 % \cs{scan@allowed}.
2019 % \begin{macrocode}
2020 \def\doc@noindexdefault{true}%
2021 \scan@allowedfalse
2022 \else
2023 \def\doc@noindexdefault{false}%
2024 \fi
2025 }
2026 % \end{macrocode}
2027 % \end{imacro}
2028 %
2029 % \begin{macrocode}
2030 \SetupDoc{} % just save the default values
2031 % \end{macrocode}
2032 %
2033 %
2034 %
2035 % \subsection{Macros surrounding the `definition parts'}
2036 %
2037 % \begin{environment}{macrocode}
2038 % Parts of the macro definition will be surrounded by the
2039 % environment \env{macrocode}. Put more precisely, they will be
2040 % enclosed by a macro whose argument (the text to be set
2041 % `verbatim') is terminated by the string
2042 % \verb*+% \end{macrocode}+. Carefully note the number of spaces.
2043 % |\macrocode| is defined completely analogously to
2044 % |\verbatim|, but because a few small changes were carried
2045 % out, almost all internal macros have got new names. We start by
2046 % calling the macro |\macro@code|, the macro which bears the
2047 % brunt of most of the work, such as |\catcode| reassignments,
2048 % etc.
2049 % \changes{v1.5r}{1989/11/04}{Support for code line no. (Undoc)}
2050 % \begin{macrocode}
2051 \def\macrocode{\macro@code
2052 % \end{macrocode}
2053 % Then we take care that all spaces have the same width, and that
2054 % they are not discarded.
2055 % \begin{macrocode}
2056 \frenchspacing \@vobeyspaces
2057 % \end{macrocode}
2058 % Before closing, we need to call |\xmacro@code|. It is this
2059 % macro that expects an argument which is terminated by the above
2060 % string. This way it is possible to keep the |\catcode|
2061 % changes local.
2062 % \changes{v1.5r}{1989/11/04}{Support for code line no. (Undoc)}
2063 % \changes{v1.5t}{1989/11/07}{Common code moved to \cs{macro@code}.}
2064 % \begin{macrocode}
2065 \xmacro@code}
2066 % \end{macrocode}
2067 % \end{environment}
2068 %
2069 %
2070 % \begin{macro}{\macro@code}
2071 % We will now begin with the macro that does the actual work:
2072 % \begin{macrocode}
2073 \def\macro@code{%
2074 % \end{macrocode}
2075 % In theory it should consist of a \env{trivlist} environment, but
2076 % the empty space before and after the environment should not be
2077 % too large.
2078 % \begin{macrocode}
2079 \topsep \MacrocodeTopsep
2080 % \end{macrocode}
2081 % The next parameter we set is |\@beginparpenalty|, in order
2082 % to prevent a page break before such an environment.
2083 % \begin{macrocode}
2084 \@beginparpenalty \predisplaypenalty
2085 % \end{macrocode}
2086 % We then start a |\trivlist|, set |\parskip| back to
2087 % zero and start an empty |\item|.
2088 % \changes{v1.9b}{1993/12/03}{Forcing any label from macro env.}
2089 % \begin{macrocode}
2090 \if@inlabel\leavevmode\fi
2091 \trivlist \parskip \z@ \item[]%
2092 % \end{macrocode}
2093 % The \cs{item} command sets the \cs{@labels} box but that box is
2094 % never typeset (as \cs{everypar} that normally does this gets
2095 % redefined later). That is normally not an issue, but produces a
2096 % problem when typesetting in mixed directions, (e.g., in
2097 % Japanese), so we explicitly clear it for that use case.
2098 % \changes{v2.1m}{2020/06/15}{Void \cs{@labels} for vertical
2099 % typesetting (gh/344)}
2100 % \begin{macrocode}
2101 \global\setbox\@labels\box\voidb@x
2102 % \end{macrocode}
2103 % Additionally, everything should be set in \texttt{typewriter} font.
2104 % Some people might prefer it somewhat differently; because of this
2105 % the font choice is
2106 % macro-driven.\footnote{The font change has to be placed
2107 % {\em after\/}
2108 % the \texttt{\bslash item}. Otherwise a change to
2109 % \texttt{\bslash baselineskip} will affect the
2110 % paragraph above.}
2111 % \begin{macrocode}
2112 \macro@font
2113 % \end{macrocode}
2114 % Because |\item| sets various parameters, we have found it
2115 % necessary to alter some of these retrospectively.
2116 % \begin{macrocode}
2117 \leftskip\@totalleftmargin \advance\leftskip\MacroIndent
2118 \rightskip\z@ \parindent\z@ \parfillskip\@flushglue
2119 % \end{macrocode}
2120 % The next line consists of the \LaTeX{} definition of |\par|
2121 % used in |\verbatim| and should result in blank lines being
2122 % shown as blank lines.
2123 % \changes{v1.5l}{1989/09/10}{Code line numbers supported.}
2124 % \changes{v1.5t}{1989/11/07}{Call \cs{leavevmode} to get \cs{everypar}
2125 % on blank lines.}
2126 % \changes{v1.7c}{1992/03/24}{Added \cs{interlinepenalty} to
2127 % \cs{par} from
2128 % verbatim.sty}
2129 % \begin{macrocode}
2130 \blank@linefalse \def\par{\ifblank@line
2131 \leavevmode\fi
2132 \blank@linetrue\@@par
2133 \penalty\interlinepenalty}
2134 % \end{macrocode}
2135 % What use is this definition of |\par|\,? We use the macro
2136 % |\obeylines| of \cite{book:KnuthA} which changes all |^^M|
2137 % to |\par| so that each can control its own indentation.
2138 % Next we must also ensure that all special signs are normalized;
2139 % that is, they must be given |\catcode| $12$.
2140 % \changes{v1.8b}{1993/09/21}{Changed to conform to new LaTeX verbatim,
2141 % which handles more ligatures.}
2142 % \changes{v3.0o}{2023/12/30}{Use \cs{@noligs} from the \LaTeX\
2143 % kernel, so that the \texttt{upquote} package can
2144 % add its patch (gh/1230)}
2145 % \begin{macrocode}
2146 \obeylines
2147 \@noligs
2148 \let\do\@makeother \dospecials
2149 % \end{macrocode}
2150 % \changes{v1.5t}{1989/11/07}{Common code added.}
2151 % \changes{v1.5w}{1990/02/05}{Skip of \cs{@totalleftmargin} added.} If
2152 % indexing by code lines is switched on the line number is incremented
2153 % and set appropriately. We also check whether the start of the next
2154 % line indicates a \texttt{docstrip} module directive and process it
2155 % appropriately if so using |\check@module|.
2156 % \begin{macrocode}
2157 \global\@newlistfalse
2158 \global\@minipagefalse
2159 \ifcodeline@index
2160 \everypar{\global\advance\c@CodelineNo\@ne
2161 \llap{\theCodelineNo\ \hskip\@totalleftmargin}%
2162 \check@module}%
2163 \else \everypar{\check@module}%
2164 \fi
2165 % \end{macrocode}
2166 % We also initialize the cross-referencing feature by calling
2167 % |\init@crossref|. This will start the scanning mechanism
2168 % when encountering an escape character.
2169 % \begin{macrocode}
2170 \init@crossref}
2171 % \end{macrocode}
2172 % \end{macro}
2173 %
2174 %
2175 % \begin{macro}{\ifblank@line}
2176 % \begin{macro}{\blank@linetrue}
2177 % \begin{macro}{\blank@linefalse}
2178 % |\ifblank@line| is the switch used in the definition above.
2179 % In the original \env{verbatim} environment the |\if@tempswa|
2180 % switch is used. This is dangerous because its value may change
2181 % while processing lines in the \env{macrocode} environment.
2182 % \begin{macrocode}
2183 \newif\ifblank@line
2184 % \end{macrocode}
2185 % \end{macro}
2186 % \end{macro}
2187 % \end{macro}
2188 %
2189 % \begin{macro}{\endmacrocode}
2190 % Because we have begun a \env{trivlist} environment in the
2191 % \env{macrocode} environment, we must also end it. We must
2192 % also act on the value of the |pm@module| flag (see below) and
2193 % empty |\everypar|.
2194 % \changes{v1.5r}{1989/11/04}{Support for code line no. (Undoc)}
2195 % \begin{macrocode}
2196 \def\endmacrocode{%
2197 \ifpm@module \endgroup \pm@modulefalse \fi
2198 \everypar{}%
2199 \global\@inlabelfalse
2200 \endtrivlist
2201 % \end{macrocode}
2202 % Additionally |\close@crossref| is used to do anything needed
2203 % to end the cross-referencing mechanism.
2204 % \begin{macrocode}
2205 \close@crossref}
2206 % \end{macrocode}
2207 % \end{macro}
2208 %
2209 %
2210 % \begin{imacro}{\MacroFont}
2211 % Here is the default definition for the |\MacroFont| macro.
2212 % With the new math font handling in NFSS2 it isn't any longer
2213 % correct to suppress the math font setup since this is now handled
2214 % differently. But to keep the font change fast we use only a
2215 % single |\selectfont| (in |\small|) and do the rest by hand.
2216 % \changes{v1.5x}{1990/02/17}{\cs{math@fontsfalse} added for NFSS.}
2217 % \changes{v1.7a}{1992/03/13}{Added \cs{reset@font} for NFSS.}
2218 % \changes{v1.8c}{1993/10/25}{NFSS standard}
2219 % \changes{v1.9t}{1995/05/26}{Removed \cs{math@fontsfalse} (different
2220 % math setup /pr1622)}
2221 % \begin{macrocode}
2222 \@ifundefined{MacroFont}{%
2223 \if@compatibility
2224 % \end{macrocode}
2225 % Despite the above statement we will call |\small| first if
2226 % somebody is using a \LaTeX2.09 document with doc. I wouldn't have
2227 % bothered since doc-sources should be up-to-date but since the
2228 % request came from someone called David Carlisle \ldots :-)
2229 % \changes{v1.9y}{1996/01/26}{Support compat mode}
2230 % \changes{v2.1l}{2019/12/16}{Use \cs{shapedefault} not
2231 % \cs{updefault} for extended NFSS}
2232 % \begin{macrocode}
2233 \def\MacroFont{\small
2234 \usefont\encodingdefault
2235 \ttdefault
2236 \mddefault
2237 \shapedefault
2238 }%
2239 \else
2240 \def\MacroFont{\fontencoding\encodingdefault
2241 \fontfamily\ttdefault
2242 \fontseries\mddefault
2243 \fontshape\shapedefault
2244 \small}%
2245 \fi
2246 }{}
2247 % \end{macrocode}
2248 % \end{imacro}
2249 %
2250 % \begin{imacro}{\AltMacroFont}
2251 % \begin{macro}{\macro@font}
2252 % \changes{v1.7a}{1992/03/12}{Added to support distinction of modules.}
2253 % \changes{v1.7c}{1992/03/26}{Altered font change for OFSS.}
2254 % \changes{v1.7m}{1992/10/11}{Use sltt as default.}
2255 % \changes{v1.8c}{1993/10/25}{NFSS standard}
2256 % \changes{v1.9t}{1995/05/26}{Removed \cs{math@fontsfalse} (different
2257 % math setup /pr1622)}
2258 % Although most of the macro code is set in |\MacroFont| we want to be
2259 % able to switch to indicate module code set in |\AltMacroFont|.
2260 % |\macro@font| keeps track of which one we're using. We can't do the
2261 % same thing sensibly in OFSS as in NFSS.
2262 % \begin{macrocode}
2263 \@ifundefined{AltMacroFont}{%
2264 \if@compatibility
2265 % \end{macrocode}
2266 % Again have |\small| first if we are in compat mode.
2267 % \changes{v1.9y}{1996/01/26}{Support compat mode}
2268 % \begin{macrocode}
2269 \def\AltMacroFont{\small
2270 \usefont\encodingdefault
2271 \ttdefault
2272 \mddefault
2273 \sldefault
2274 }%
2275 \else
2276 \def\AltMacroFont{\fontencoding\encodingdefault
2277 \fontfamily\ttdefault
2278 \fontseries\mddefault
2279 \fontshape\sldefault
2280 \small
2281 }%
2282 \fi
2283 }{}
2284 % \end{macrocode}
2285 % To allow changing the |\MacroFont| in the preamble we defer
2286 % defining the internally used |\macro@font| until after the
2287 % preamble.
2288 % \changes{v2.0a}{1998/05/16}{Support changing \cs{MacroFont} in
2289 % preamble}
2290 % \begin{macrocode}
2291 \AtBeginDocument{\let\macro@font\MacroFont}
2292 % \end{macrocode}
2293 % \end{macro}
2294 % \end{imacro}
2295 %
2296 % \begin{macro}{\check@module}
2297 % \begin{macro}{\ifpm@module}
2298 % \changes{v1.7a}{1992/03/12}{Added.}
2299 % This is inserted by |\everypar| at the start of each macrocode line to
2300 % check whether it starts with module information. (Such information is
2301 % of the form |%<|\meta{switch}|>|, where the |%| must be at the
2302 % start of the line and \meta{switch} comprises names with various
2303 % possible separators and a possible leading |+|, |-|, |*| or |/|
2304 % \cite{art:docstrip}. All that concerns us here is what the first
2305 % character of \meta{switch} is.) First it checks the |pm@module|
2306 % flag in case the previous line had a non-block module
2307 % directive i.e., not |%<*| or |%</|; if it did we need to close the
2308 % group it started and unset the flag. |\check@module| looks ahead at
2309 % the next token and then calls |\ch@percent| to take action depending
2310 % on whether or not it's a |%|; we don't want to expand the token at
2311 % this stage. This is all done conditionally so it can be turned off
2312 % if it causes problems with code that wasn't designed to be
2313 % \texttt{docstrip}ped.
2314 % \begin{macrocode}
2315 \def\check@module{%
2316 \ifcheck@modules
2317 \ifpm@module \endgroup \pm@modulefalse \fi
2318 \expandafter\futurelet\expandafter\next\expandafter\ch@percent
2319 \fi}
2320 \newif\ifpm@module
2321 % \end{macrocode}
2322 % \end{macro}
2323 % \end{macro}
2324 % \begin{imacro}{\DontCheckModules}
2325 % \begin{imacro}{\CheckModules}
2326 % \changes{v1.7a}{1992/03/12}{Added.}
2327 % \begin{macro}{\ifcheck@modules}
2328 % Here are two driver-file interface macros for turning the module
2329 % checking on and off using the |check@modules| switch.
2330 % \begin{macrocode}
2331 \def\DontCheckModules{\check@modulesfalse}
2332 \def\CheckModules{\check@modulestrue}
2333 \newif\ifcheck@modules \check@modulestrue
2334 % \end{macrocode}
2335 % \end{macro}
2336 % \end{imacro}
2337 % \end{imacro}
2338 %
2339 %
2340 % \begin{macro}{\ch@percent}
2341 % \changes{v1.7a}{1992/03/12}{Added.}
2342 % If the lookahead token in |\next| is $|%|_{12}$ we go on to check
2343 % whether the following one is |<| and otherwise do nothing. Note the
2344 % |\expandafter| to get past the |\fi|.
2345 % \begin{macrocode}
2346 \def\ch@percent{%
2347 \if \percentchar\next
2348 \expandafter\check@angle
2349 \fi}
2350 % \end{macrocode}
2351 % \end{macro}
2352 %
2353 % \begin{macro}{\check@angle}
2354 % \changes{v1.7a}{1992/03/12}{Added.}
2355 % Before looking ahead for the |<| the |%| is gobbled by the
2356 % argument here.
2357 % \begin{macrocode}
2358 \def\check@angle#1{\futurelet\next\ch@angle}
2359 % \end{macrocode}
2360 % \end{macro}
2361 % \begin{macro}{\ch@angle}
2362 % \changes{v1.7a}{1992/03/12}{Added.}
2363 % \changes{v1.9k}{1994/02/22}{Have \texttt{<} active}
2364 % If the current lookahead token is |<| we are defined to be
2365 % processing a module directive can go on to look for |+| etc.;
2366 % otherwise we must put back the gobbled |%|. With \LaTeXe{}
2367 % \texttt{<} is active so we have to be a bit careful.
2368 % \begin{macrocode}
2369 \begingroup
2370 \catcode`\<\active
2371 \gdef\ch@angle{\ifx<\next
2372 \expandafter\ch@plus@etc
2373 \else \percentchar \fi}
2374 % \end{macrocode}
2375 % \end{macro}
2376 %
2377 % \begin{macro}{\ch@plus@etc}
2378 % \begin{macro}{\check@plus@etc}
2379 % \changes{v1.7a}{1992/03/12}{Added.}
2380 % We now have to decide what sort of a directive we're dealing with
2381 % and do the right thing with it.
2382 % \begin{macrocode}
2383 \gdef\ch@plus@etc<{\futurelet\next\check@plus@etc}
2384 \gdef\check@plus@etc{%
2385 \if +\next
2386 \let\next\pm@module
2387 \else\if -\next
2388 \let\next\pm@module
2389 \else\if *\next
2390 \let\next\star@module
2391 \else\if /\next
2392 \let\next\slash@module
2393 % \end{macrocode}
2394 % At some point in the past the \texttt{docstrip} program was
2395 % partly rewritten and at that time it also got support for a very
2396 % special directive of the form |%<<| followed by an arbitrary
2397 % string. This is used for ``verbatim'' inclusion in case of
2398 % certain problem. We do not really attempt to pretty print that
2399 % case but we need at least account for it since otherwise we get
2400 % an error message since this is the only case where we will not
2401 % have a closing |>|.
2402 % \changes{v2.0n}{2001/05/16}{Partly support docstrip's ``verbatim''
2403 % directive (pr/3331)}
2404 % \begin{macrocode}
2405 \else\ifx <\next
2406 \percentchar
2407 \else
2408 \let\next\pm@module
2409 \fi\fi\fi\fi\fi
2410 \next}
2411 \endgroup
2412 % \end{macrocode}
2413 % \end{macro}
2414 % \end{macro}
2415 % \begin{macro}{\pm@module}
2416 % If we're not dealing with a block
2417 % directive (|*| or |/|) i.e., it's a single special line, we set
2418 % everything up to the next |>| appropriately and then change to the
2419 % special macro font inside a group which will be ended at the start
2420 % of the next line. If the apparent module directive is missing the
2421 % terminating |>| this will lose, but then so will the \texttt{docstrip}
2422 % implementation. An alternative strategy would be to have
2423 % |\pm@module| make |>| active and clear a flag set here to indicate
2424 % processing the directive. Appropriate action could then be taken if
2425 % the flag was found still to be set when processing the next line.
2426 % \changes{v1.7a}{1992/03/12}{Added.}
2427 % \changes{v1.7i}{1992/07/11}{Support for fonts depending on nesting.}
2428 % \begin{macrocode}
2429 \begingroup
2430 \catcode`\~=\active
2431 \lccode`\~=`\>
2432 \lowercase{\gdef\pm@module#1~}{\pm@moduletrue
2433 \Module{#1}\begingroup
2434 % \end{macrocode}
2435 % We switch to a special font as soon the nesting is higher than
2436 % the current value of |\c@StandardModuleDepth|. We do a local
2437 % update to the |\guard@level| here which will be restored after
2438 % the current input line.
2439 % \begin{macrocode}
2440 \advance\guard@level\@ne
2441 \ifnum\guard@level>\c@StandardModuleDepth\AltMacroFont\fi
2442 }
2443 % \end{macrocode}
2444 % \end{macro}
2445 % \begin{macro}{\star@module}
2446 % \begin{macro}{\slash@module}
2447 % \changes{v1.7a}{1992/03/12}{Added.}
2448 % \changes{v1.7f}{1992/05/16}{Take account of nested guards.}
2449 % \changes{v1.7i}{1992/07/11}{Add counter to determine when to switch to
2450 % special font.}
2451 % If the start or end of a module {\em block\/} is indicated, after
2452 % setting the guard we have to check whether a change in the macrocode
2453 % font should be done. This will be the case if we are already inside
2454 % a block or are ending the outermost block. If so, we globally
2455 % toggle the font for subsequent macrocode sections between the normal
2456 % and special form, switching to the new one immediately.
2457 % \changes{v1.7i}{1992/07/17}{Support for fonts depending on module
2458 % nesting}
2459 % \begin{macrocode}
2460 \lowercase{\gdef\star@module#1~}{%
2461 \Module{#1}%
2462 \global \advance \guard@level\@ne
2463 \ifnum \guard@level>\c@StandardModuleDepth
2464 \global\let\macro@font=\AltMacroFont \macro@font
2465 \fi}
2466 \catcode`\>=\active
2467 \gdef\slash@module#1>{%
2468 \Module{#1}%
2469 \global \advance \guard@level\m@ne
2470 \ifnum \guard@level=\c@StandardModuleDepth
2471 \global\let\macro@font\MacroFont \macro@font
2472 \fi
2473 }
2474 \endgroup
2475 % \end{macrocode}
2476 % \end{macro}
2477 % \end{macro}
2478 %
2479 % \begin{lcounter}{StandardModuleDepth}
2480 % \changes{v1.7i}{1992/07/11}{Counter added.}
2481 % Counter defining up to which level modules are considered part of
2482 % the main code. If, for example, the whole code is surrounded by
2483 % a |%<*package>| module we better set this counter to |1| to avoid
2484 % getting the whole code be displayed in typewriter italic.
2485 % \begin{macrocode}
2486 \newcounter{StandardModuleDepth}
2487 % \end{macrocode}
2488 % \end{lcounter}
2489 %
2490 %
2491 % \begin{tcounter}{\guard@level}
2492 % \changes{v1.7f}{1992/05/16}{Added.}
2493 % We need a counter to keep track of the guard nesting.
2494 % \begin{macrocode}
2495 \newcount \guard@level
2496 % \end{macrocode}
2497 % \end{tcounter}
2498
2499 % \begin{macro}{\Module}
2500 % \changes{v1.7a}{1992/03/12}{Added.}
2501 % \changes{v1.7d}{1992/04/25}{Use sans font for modules.}
2502 % This provides a hook to determine the way the module directive is
2503 % set. It gets as argument everything between the angle brackets.
2504 % The default is to set the contents in sans serif text between
2505 % $\langle\,\rangle$ with the special characters suitably |\mathcode|d
2506 % by |\mod@math@codes|. (You can't just set it in a sans text font
2507 % because normally \verb"|" will print as an em-dash.) This is done
2508 % differently depending on whether we have the NFSS or the old one. In
2509 % the latter case we can easily change |\fam| appropriately.
2510 % \changes{v1.8c}{1993/10/25}{NFSS standard}
2511 % \begin{macrocode}
2512 \@ifundefined{Module}{%
2513 % \end{macrocode}
2514 % With NFSS what we probably {\em should\/} do is change to a new
2515 % |\mathversion| but I (Dave Love) haven't spotted an easy way to
2516 % do so correctly if the document uses a version other than
2517 % |normal|. (We need to know in what font to set the other
2518 % groups.) This uses a new math alphabet rather than version and
2519 % consequently has to worry about whether we're using
2520 % \env{oldlfnt} or not. I expect there's a better
2521 % way\ldots
2522 % \begin{macrocode}
2523 \def\Module#1{\mod@math@codes$\langle\mathsf{#1}\rangle$}
2524 }{}
2525 % \end{macrocode}
2526 % \end{macro}
2527 %
2528 % \begin{macro}{\mod@math@codes}
2529 % \changes{v1.7c}{1992/03/26}{Added.}
2530 % \changes{v2.1e}{2010/02/04}{Added mathcodes for +,-,:, and = (pr/4096)}
2531 % As well as `words', the module
2532 % directive text might contain any of the characters \verb"*/+-,&|!()"
2533 % for the current version of \prg{docstrip}. We only need
2534 % special action for two of them in the math code changing required
2535 % above: \verb"|" is changed to a |\mathop| (it's normally |"026A|) and
2536 % |&| is also made a |\mathop|, but in family 0. Remember that |&|
2537 % will not have a special catcode when it's encountered.
2538 % \begin{macrocode}
2539 \def\mod@math@codes{\mathcode`\|="226A \mathcode`\&="2026
2540 \mathcode`\-="702D \mathcode`\+="702B
2541 \mathcode`\:="703A \mathcode`\=="703D }
2542 % \end{macrocode}
2543 % \end{macro}
2544 %
2545 %
2546 % \begin{lskip}{\MacrocodeTopsep}
2547 % \begin{ldimen}{\MacroIndent}
2548 % In the code above, we have used two registers. Therefore we have
2549 % to allocate them. The default values might be overwritten with
2550 % the help of the |\DocstyleParms| macro.
2551 % \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
2552 % \changes{v1.5y}{1990/02/24}{Default changed.}
2553 % \changes{v1.6b}{1990/06/15}{\cs{rm} moved before \cs{scriptsize} to
2554 % avoid unnecessary fontwarning.}
2555 % \begin{macrocode}
2556 \newskip\MacrocodeTopsep \MacrocodeTopsep = 3pt plus 1.2pt minus 1pt
2557 \newdimen\MacroIndent
2558 \settowidth\MacroIndent{\rmfamily\scriptsize 00\ }
2559 % \end{macrocode}
2560 % \end{ldimen}
2561 % \end{lskip}
2562 %
2563 %
2564 %
2565 %
2566 % \begin{environment}{macrocode*}
2567 % \begin{macro}{\endmacrocode*}
2568 % Just as in the \env{verbatim} environment, there is also a
2569 % `star' variant of the \env{macrocode} environment in which a
2570 % space is shown by the symbol \verb*+ +. Until this moment, I
2571 % have not yet used it (it will be used in the description of the
2572 % definition of |\xmacro@code| below) but it's exactly on this one
2573 % occasion {\em here\/} that you can't use it (cf.\ Münchhausens
2574 % Marsh problem)\footnote{Karl Friedrich Hieronymus Frhr.\ v.\
2575 % Münchhausen (*1720, \dag1797). Several books were written
2576 % about fantastic adventures supposedly told by him (see
2577 % \cite{book:Raspe} or \cite{book:Buerger}). In one story he
2578 % escaped from the marsh by pulling himself out by his hair.}
2579 % directly. Because of this, on this one occasion we'll cheat
2580 % around the problem with an additional comment character. But now
2581 % back to |\macrocode*|. We start with the macro |\macro@code|
2582 % which prepares everything and then call the macro |\sxmacro@code|
2583 % whose argument is terminated by the string
2584 %\verb*+% \end{macrocode*}+.
2585 % \begin{macrocode}
2586 \@namedef{macrocode*}{\macro@code\sxmacro@code}
2587 % \end{macrocode}
2588 % As we know, |\sxmacro@code| and then |\end{macrocode*}|
2589 % (the macro, not the string), will be executed, so that for a
2590 % happy ending we still need to define the macro
2591 % |\endmacrocode*|.
2592 % \begin{macrocode}
2593 \expandafter\let\csname endmacrocode*\endcsname = \endmacrocode
2594 % \end{macrocode}
2595 % \end{macro}
2596 % \end{environment}
2597 %
2598 %
2599 %
2600 %
2601 %
2602 %
2603 %
2604 % \begin{macro}{\xmacro@code}
2605 \catcode`\!=\catcode`\% ^^A In this section there must not be
2606 ^^A any exclamation marks.
2607 ^^A
2608 % As already mentioned, the macro |\xmacro@code| expects an
2609 % argument delimited by the string \verb*+% \end{macrocode}+. At
2610 % the moment that this macro is called, the |\catcode| of
2611 % \TeX's special characters are 12 (`other') or 13 (`active').
2612 % Because of this we need to utilize a different escape character
2613 % during the definition. This happens locally.
2614 % \begin{macrocode*}
2615 \begingroup
2616 \catcode`\|=\z@ \catcode`\[=\@ne \catcode`\]=\tw@
2617 % \end{macrocode*}
2618 % Additionally, we need to ensure that the symbols in the above
2619 % string contain the |\catcode|$\,$s which are available
2620 % within the \env{macrocode} environment.
2621 % \begin{macrocode*}
2622 \catcode`\{=12 \catcode`\}=12
2623 \catcode`\%=12 \catcode`\ =\active \catcode`\\=\active
2624 !% \end{macrocode*}
2625 ! Next follows the actual definition of |\macro@code|;
2626 ! notice the
2627 ! use of the new escape character. We manage to get the argument
2628 ! surrounded by the string |\end{macrocode}|, but at the end
2629 ! however, in spite of the actual characters used during the
2630 ! definition of
2631 ! this macro, |\end| with the argument |{macrocode}|
2632 ! will be executed, to ensure a balanced environment.
2633 ! \begin{macrocode*}
2634 |gdef|xmacro@code#1% \end{macrocode}[#1|end[macrocode]]
2635 !% \end{macrocode*}
2636 ! \begin{macro}{\sxmacro@code}
2637 ! The definition of |\sxmacro@code| is completely analogous,
2638 ! only
2639 ! here a slightly different terminating string will be used.
2640 ! Note that the space is not active in this environment.
2641 ! \begin{macrocode}
2642 |catcode`| =12
2643 |gdef|sxmacro@code#1% \end{macrocode*}[#1|end[macrocode*]]
2644 !% \end{macrocode}
2645 ! because the |\catcode| changes have been made local by
2646 ! commencing a
2647 ! new group, there now follows the matching |\endgroup|
2648 ! in a rather
2649 ! unusual style of writing.
2650 ! \begin{macrocode}
2651 |endgroup
2652 !% \end{macrocode}
2653 \catcode`\!=12
2654 % \end{macro}
2655 % \end{macro}
2656 %
2657 %
2658 %
2659 %
2660 % \subsection{Macros for the `documentation parts'}
2661 %
2662 %
2663
2664 % To put the labels in the left margin we have to use the
2665 % |\reversemarginpar| declaration. (This means that the
2666 % \texttt{doc.sty} can't be used with all classes or packages.)
2667 % We also
2668 % make the |\marginparpush| zero and |\marginparwidth| suitably
2669 % wide.
2670 % \changes{v1.5d}{1989/04/28}{\cs{marginparwidth} setting added.}
2671 % \begin{macrocode}
2672 \reversemarginpar
2673 \setlength\marginparpush{0pt} \setlength\marginparwidth{8pc}
2674 % \end{macrocode}
2675 %
2676 % \begin{macrocode}
2677 \setlength\marginparsep{\labelsep}
2678 % \end{macrocode}
2679 %
2680 % \begin{imacro}{\bslash}
2681 % \changes{v1.7a}{1992/02/26}{Moved \cs{bslash} documentation to `user
2682 % interface' part}
2683 % We start a new group in which to hide the alteration of
2684 % |\catcode|$\,$s, and make \verb+|+ introduce commands,
2685 % whilst |\| becomes an `other' character.
2686 %
2687 % \begin{macrocode}
2688 {\catcode`\|=\z@ \catcode`\\=12
2689 % \end{macrocode}
2690 % Now we are able to define |\bslash| (globally) to generate a
2691 % backslash of |\catcode| `other'. We then close this group,
2692 % restoring original |\catcode|$\,$s.
2693 % \SpecialEscapechar{\|}
2694 % \begin{macrocode}
2695 |gdef|bslash{\}}
2696 % \end{macrocode}
2697 % \end{imacro}
2698 %
2699 %
2700 %
2701 % \begin{environment}{verbatim}
2702 % \begin{environment}{verbatim*}
2703 % \changes{v1.7i}{1992/07/12}{Added changed definition for verbatim!*.}
2704 % The \env{verbatim} environment holds no secrets; it consists of
2705 % the normal \LaTeX{} environment. We also set the
2706 % |\@beginparpenalty| and change to the font given by
2707 % |\MacroFont|.
2708 % \begin{macrocode}
2709 \def\verbatim{\@beginparpenalty \predisplaypenalty \@verbatim
2710 \MacroFont \frenchspacing \@vobeyspaces \@xverbatim}
2711 % \end{macrocode}
2712 % We deal in a similar way with the star form of this environment.
2713 % \begin{macrocode}
2714 \@namedef{verbatim*}{\@beginparpenalty \predisplaypenalty \@verbatim
2715 % \end{macrocode}
2716 %
2717 % \changes{v2.1j}{2019/11/03}{Kernel now sets up \cs{verbvisiblespace} (gh/205)}
2718 % \changes{v2.1k}{2019/11/10}{Put the definition into the right command (gh/205)}
2719 % \begin{macrocode}
2720 \@setupverbvisiblespace
2721 \MacroFont \@vobeyspaces \@sxverbatim}
2722 % \end{macrocode}
2723 % \end{environment}
2724 % \end{environment}
2725 %
2726 % \begin{macro}{\@verbatim}
2727 % Additionally we redefine the |\@verbatim| macro so that it
2728 % suppresses |%| characters at the beginning of the line. The
2729 % first lines are copied literally from \texttt{latex.tex}.
2730 % \changes{v1.7i}{1992/07/12}{Added \cs{@@par} to clear possible
2731 % \cs{parshape}.}
2732 % \changes{v3.0m}{2022/11/13}{Redefinitions of \cs{@verbatim} changed
2733 % to match the kernel definition (gh/953)}
2734 % \begin{macrocode}
2735 \def\@verbatim{\trivlist \item\relax
2736 \if@minipage\else\vskip\parskip\fi
2737 \leftskip\@totalleftmargin\rightskip\z@
2738 \parindent\z@\parfillskip\@flushglue\parskip\z@
2739 \language\l@nohyphenation
2740 \@@par
2741 \@tempswafalse
2742 % \end{macrocode}
2743 % |\@verbatim| sets |^^M|, the end of line character, to
2744 % be equal to |\par|. This control sequence is redefined
2745 % here; |\@@par| is the paragraph primitive of \TeX.
2746 % \changes{v1.7c}{1992/03/24}{Added \cs{interlinepenalty} to
2747 % \cs{par} from verbatim.sty}
2748 % \begin{macrocode}
2749 \def\par{%
2750 \if@tempswa
2751 \leavevmode \null \@@par\penalty\interlinepenalty
2752 \else
2753 \@tempswatrue
2754 \ifhmode\@@par\penalty\interlinepenalty\fi
2755 \fi
2756 % \end{macrocode}
2757 % We add a control sequence |\check@percent| to the definition
2758 % of |\par| whose task it is to check for a percent character.
2759 % \begin{macrocode}
2760 \check@percent}%
2761 % \end{macrocode}
2762 % The rest is again copied literally from \texttt{latex.tex} (less
2763 % "\tt").
2764 % \changes{v1.7a}{1992/02/26}{Removed redundant \cs{tt}.}
2765 % \changes{v1.8b}{1993/09/21}{Changed to conform to new LaTeX verbatim,
2766 % which handles more ligatures.}
2767 % \begin{macrocode}
2768 \let\do\@makeother \dospecials
2769 \obeylines \verbatim@font \@noligs
2770 \everypar \expandafter{\the\everypar \unpenalty}%
2771 }
2772 % \end{macrocode}
2773 % \end{macro}
2774 %
2775 % \begin{macro}{\check@percent}
2776 % Finally we define |\check@percent|. Since this must compare a
2777 % character with a percent sign we must first (locally) change
2778 % percent's |\catcode| so that it is seen by \TeX. The definition
2779 % itself is nearly trivial: grab the following character, check if
2780 % it is a |%|, and insert it again if not. At the end of the
2781 % \env{verbatim} environment this macro will peek at the next
2782 % input line. In that case the argument to |\check@percent| might
2783 % be a |\par| or a macro with arguments. Therefore we make the
2784 % definition |\long| (|\par| allowed) and use the normal |\next|
2785 % mechanism to reinsert the argument after the |\fi| if necessary.
2786 % \changes{v1.5i}{1989/06/07}{Definition changed to `long'}
2787 % \changes{v1.5i}{1989/06/07}{Macro \cs{next} used to guard against
2788 % macro with arguments}
2789 % There is a subtle problem here, the equal sign between
2790 % |\next| and |#1| is actually necessary. Do you see why?
2791 % The omission of this token once caused a funny error.
2792 % \changes{v1.5u}{1989/11/14}{equal sign added.}
2793 % \begin{macrocode}
2794 {\catcode`\%=12
2795 \long\gdef\check@percent#1{\ifx #1%\let\next\@empty \else
2796 \let\next=#1\fi \next}}
2797 % \end{macrocode}
2798 % \end{macro}
2799 %
2800 %
2801 % In the early versions of the package it also redefined \cs{verb}
2802 % because that didn't include the useful test for \enquote{newline} in
2803 % the verbatim text. This is nowadays part of \LaTeX{} so we do not
2804 % redefine it any longer (the original code is still kept in the file
2805 % after \cs{endinput} to keep the long history intact).
2806 %
2807 % \begin{tcounter}{\macro@cnt}
2808 % \label{page:macro} The \env{macro} environment is implemented as
2809 % a \env{trivlist} environment, whereby in order that the macro
2810 % names can be placed under one another in the margin
2811 % (corresponding to the macro's nesting depth), the macro
2812 % |\makelabel| must be altered. In order to store the nesting
2813 % depth, we use a counter. We also need a counter to count the
2814 % number of nested \env{macro} environments.
2815 % \changes{v1.5k}{1989/08/17}{Fix for save stack problem.}
2816 % \changes{v1.9k}{1994/02/22}{Fix probably no longer necessary}
2817 % \begin{macrocode}
2818 \newcount\macro@cnt \macro@cnt=0
2819 % \end{macrocode}
2820 % \end{tcounter}
2821 %
2822 %
2823 % \begin{lskip}{\MacroTopsep}
2824 % Here is the default value for the |\MacroTopsep| parameter
2825 % used above.
2826 % \begin{macrocode}
2827 \newskip\MacroTopsep \MacroTopsep = 7pt plus 2pt minus 2pt
2828 % \end{macrocode}
2829 % \end{lskip}
2830 %
2831 %
2832 %
2833 %
2834 %
2835 % \subsection{Formatting the margin}
2836 %
2837 % The following three macros should be user definable.
2838 % Therefore we define those macros only if they have not already
2839 % been defined.
2840 %
2841 %
2842 % \subsection{Creating index entries by scanning `macrocode'}
2843 %
2844 % The following macros ensure that index entries are created for each
2845 % occurrence of a \TeX-like command (something starting with
2846 % `|\|') providing indexing has been turned on with |\PageIndex|
2847 % or |\CodelineIndex|. With the default definitions of
2848 % |\specialMainMacroIndex|, etc., the index file generated is
2849 % intended to be processed by Chen's \prg{makeindex} program
2850 % \cite{art:Chen}.
2851 %
2852 %
2853 % Of course, in {\em this\/} package file itself we've sometimes had to
2854 % make \verb+|+ take the r\^ole of \TeX's escape character to
2855 % introduce command names at places where |\| has to belong to
2856 % some other category. Therefore, we may also need to recognize
2857 % \verb+|+ as the introducer for a command when setting the text
2858 % inside the \env{macrocode} environment. Other users may have the
2859 % need to make similar reassignments for their macros.
2860 %
2861 %
2862 % \begin{imacro}{\SpecialEscapechar}\label{sect:specialescapechar}
2863 % \begin{macro}{\active@escape@char}
2864 % \begin{macro}{\special@escape@char}
2865 % The macro |\SpecialEscapechar| is used to denote a special escape
2866 % character for the next \env{macrocode} environment. It has one
2867 % argument---the new escape character given as a `single-letter'
2868 % control sequence. Its main purpose is defining
2869 % |\special@escape@char| to produce the chosen escape character
2870 % |\catcode|$\,$d to 12 and |\active@escape@char| to produce the
2871 % same character but with |\catcode| 13.
2872 %
2873 % The macro |\special@escape@char| is used to {\em print\/}
2874 % the escape character while |\active@escape@char| is needed
2875 % in the definition of |\init@crossref| to start the scanning
2876 % mechanism.
2877 %
2878 % In the definition of |\SpecialEscapechar| we need an
2879 % arbitrary character with |\catcode| 13. We use `\~{}' and
2880 % ensure that it is active. The |\begingroup| is used to make
2881 % a possible change local to the expansion of
2882 % |\SpecialEscapechar|.
2883 % \changes{v1.7g}{1992/06/19}{Making tilde active moved outside
2884 % definition}
2885 % \begin{macrocode}
2886 \begingroup
2887 \catcode`\~\active
2888 \gdef\SpecialEscapechar#1{%
2889 \begingroup
2890 % \end{macrocode}
2891 % Now we are ready for the definition of
2892 % |\active@escape@char|. It's a little tricky: we first
2893 % define locally the uppercase code of `\~{}' to be the new escape
2894 % character.
2895 % \begin{macrocode}
2896 \uccode`\~`#1%
2897 % \end{macrocode}
2898 % Around the definition of |\active@escape@char| we place an
2899 % |\uppercase| command. Recall that the expansion of
2900 % |\uppercase| changes characters according to their
2901 % |\uccode|, but leaves their |\catcode|$\,$s untouched
2902 % (cf.\ \TeX{}book page 41).
2903 % \begin{macrocode}
2904 \uppercase{\gdef\active@escape@char{~}}%
2905 % \end{macrocode}
2906 % The definition of |\special@escape@char| is easier, we use
2907 % |\string| to |\catcode| the argument of
2908 % |\SpecialEscapechar| to 12 and suppress the preceding
2909 % |\escapechar|.
2910 % \begin{macrocode}
2911 \escapechar\m@ne \xdef\special@escape@char{\string#1}%
2912 % \end{macrocode}
2913 % Now we close the group and end the definition: the value of
2914 % |\escapechar| as well as the |\uccode| and
2915 % |\catcode| of `\~{}' will be restored.
2916 % \begin{macrocode}
2917 \endgroup}
2918 \endgroup
2919 % \end{macrocode}
2920 % \end{macro}
2921 % \end{macro}
2922 % \end{imacro}
2923 %
2924 %
2925 %
2926 %
2927 % \begin{macro}{\init@crossref}
2928 % The replacement text of |\init@crossref| should fulfill the
2929 % following tasks:
2930 % \begin{itemize}
2931 % \parindent4em
2932 % \item[(1)]
2933 % |\catcode| all characters used in macro names to
2934 % 11 (i.e., `letter').
2935 % \item[(2)]
2936 % |\catcode| the `|\|' character to 13
2937 % (i.e., `active').
2938 % \item[(3a)]
2939 % |\let| the `|\|' equal |\scan@macro|
2940 % (i.e., start the macro scanning mechanism) if there is
2941 % no special escape character (i.e., the
2942 % |\special@escape@char| is `|\|').
2943 % \item[(3b)]
2944 % Otherwise |\let| it equal |\bslash|, i.e.\
2945 % produce a printable |\|.
2946 % \item[(4)]
2947 % Make the \meta{special escape character} active.
2948 % \item[(5)]
2949 % |\let| the active version of the special escape
2950 % character
2951 % (i.e., the expansion of |\active@escape@char|) equal
2952 % |\scan@macro|.
2953 % \end{itemize}
2954 % The reader might ask why we bother to |\catcode| the
2955 % `|\|' first to 12 (at the end of |\macro@code|) then
2956 % re-|\catcode| it to 13 in order to produce a $|\|_{12}$
2957 % in case (3b) above. This is done because we have to ensure that
2958 % `|\|' has |\catcode| 13 within the \env{macrocode}
2959 % environment. Otherwise the delimiter for the argument of
2960 % |\xmacro@code| would not be found (parameter matching
2961 % depends on |\catcode|$\,$s).
2962 %
2963 % Therefore we first re-|\catcode| some characters.
2964 % \begin{macrocode}
2965 \begingroup \catcode`\|=\z@ \catcode`\\=\active
2966 % \end{macrocode}
2967 % We carry out tasks (2) and (3b) first.
2968 % \SpecialEscapechar\|
2969 % \begin{macrocode}
2970 |gdef|init@crossref{|catcode`|\|active |let\|bslash
2971 % \end{macrocode}
2972 % Because of the popularity of the `|@|' character as a
2973 % `letter' in macros, we normally have to change its
2974 % |\catcode| here, and thus fulfill task (1). But the macro
2975 % designer might use other characters as private letters as well,
2976 % so we use a macro to do the |\catcode| switching.
2977 % \SpecialEscapechar\|
2978 % \begin{macrocode}
2979 |MakePrivateLetters
2980 % \end{macrocode}
2981 % Now we |\catcode| the special escape character to 13 and
2982 % |\let| it equal |\scan@macro|, i.e., fulfill tasks (4)
2983 % and (5). Note the use of |\expandafter| to insert the chosen
2984 % escape character saved in |\special@escape@char| and
2985 % |\active@escape@char|.
2986 % \SpecialEscapechar\|
2987 % \begin{macrocode}
2988 |catcode|expandafter`|special@escape@char|active
2989 |expandafter|let|active@escape@char|scan@macro}
2990 |endgroup
2991 % \end{macrocode}
2992 % If there is no special escape character, i.e., if
2993 % |\SpecialEscapechar| is |\\|, the second last line will
2994 % overwrite the previous definition of $|\|_{13}$. In this
2995 % way all tasks are fulfilled.
2996 %
2997 % For happy documenting we give default values to
2998 % |\special@escape@char| and |\active@escape@char| with
2999 % the following line:
3000 % \begin{macrocode}
3001 \SpecialEscapechar{\\}
3002 % \end{macrocode}
3003 % \end{macro}
3004 %
3005 %
3006 %
3007 % \begin{imacro}{\MakePrivateLetters}
3008 % Here is the default definition of this command, which makes just
3009 % the |@| into a letter. The user may change it if he/she
3010 % needs more or other characters masquerading as letters.
3011 % \begin{macrocode}
3012 \@ifundefined{MakePrivateLetters}
3013 {\let\MakePrivateLetters\makeatletter}{}
3014 % \end{macrocode}
3015 % \end{imacro}
3016 %
3017 % \begin{macro}{\close@crossref}
3018 % At the end of a cross-referencing part we prepare ourselves for
3019 % the next one by setting the escape character to `|\|'.
3020 % \begin{macrocode}
3021 \def\close@crossref{\SpecialEscapechar\\}
3022 % \end{macrocode}
3023 % \end{macro}
3024 %
3025 %
3026 %
3027 %
3028 % \subsection{Macros for scanning macro names}
3029 %
3030 % \begin{macro}{\scan@macro}
3031 % \changes{v1.5k}{1989/09/04}{Support for checksum added.}
3032 % \begin{macro}{\macro@namepart}
3033 % The |\init@crossref| will have made |\active| our
3034 % |\special@escape@char|, so that each
3035 % |\active@escape@char| will invoke |\scan@macro| when
3036 % within the \env{macrocode} environment. By this means, we can
3037 % automatically add index entries for every \TeX-like command which
3038 % is met whilst setting (in verbatim) the contents of
3039 % \env{macrocode} environments.
3040 % \begin{macrocode}
3041 \def\scan@macro{%
3042 % \end{macrocode}
3043 % First we output the character which triggered this macro. Its
3044 % version |\catcode|$\,$d to 12 is saved in
3045 % |\special@escape@char|. We also call |\step@checksum|
3046 % to generate later on a proper check-sum (see section
3047 % \ref{sec:checksum} for details).
3048 % \begin{macrocode}
3049 \special@escape@char
3050 \step@checksum
3051 % \end{macrocode}
3052 % If the \env{macrocode} environment contains, for example, the
3053 % command |\\|, the second |\| should not start the
3054 % scanning mechanism. Therefore we use a switch to decide if
3055 % scanning of macro names is allowed.
3056 % \begin{macrocode}
3057 \ifscan@allowed
3058 % \end{macrocode}
3059 % The macro assembles the letters forming a \TeX\ command in
3060 % |\macro@namepart| so this is initially cleared; we then set
3061 % |\next| to the \textit{first\/} character following the
3062 % |\| and call |\macro@switch| to determine whether that
3063 % character is a letter or not.
3064 % \begin{macrocode}
3065 \let\macro@namepart\@empty
3066 \def\next{\futurelet\next\macro@switch}%
3067 % \end{macrocode}
3068 % As you recognize, we actually did something else, because we have
3069 % to defer the |\futurelet| call until after the final
3070 % |\fi|. If, on the other hand, the scanning is disabled we
3071 % simply |\let| |\next| equal `empty'.
3072 % \begin{macrocode}
3073 \else \let\next\@empty \fi
3074 % \end{macrocode}
3075 % Now we invoke |\next| to carry out what's needed.
3076 % \begin{macrocode}
3077 \next}
3078 % \end{macrocode}
3079 % \end{macro}
3080 % \end{macro}
3081 %
3082 %
3083 %
3084 % \begin{imacro}{\EnableCrossrefs}
3085 % \begin{imacro}{\DisableCrossrefs}
3086 % At this point we might define two macros which allow the user to
3087 % disable or enable the cross-referencing mechanism. Processing of
3088 % files will be faster if only main index entries are generated
3089 % (i.e., if |\DisableCrossrefs| is in force).
3090 % \begin{macrocode}
3091 \def\DisableCrossrefs{\@bsphack\scan@allowedfalse\@esphack}
3092 % \end{macrocode}
3093 % The macro |\EnableCrossrefs| will also disable any
3094 % |\DisableCrossrefs| command encountered afterwards.
3095 % \begin{macrocode}
3096 \def\EnableCrossrefs{\@bsphack\scan@allowedtrue
3097 \def\DisableCrossrefs{\@bsphack\@esphack}\@esphack}
3098 % \end{macrocode}
3099 % \end{imacro}
3100 % \end{imacro}
3101 %
3102 %
3103 %
3104 %
3105 % \begin{macro}{\macro@switch}
3106 % Now that we have the character which follows the escape character
3107 % (in |\next|), we can determine whether it's a `letter'
3108 % (which probably includes |@|).
3109 %
3110 % If it is, we let |\next| invoke a macro which assembles the
3111 % full command name.
3112 % \begin{macrocode}
3113 \def\macro@switch{\ifcat\noexpand\next a%
3114 \let\next\macro@name
3115 % \end{macrocode}
3116 % Otherwise, we have a `single-character' command name. For all
3117 % those single-character names, we use |\short@macro| to
3118 % process them into suitable index entries.
3119 % \begin{macrocode}
3120 \else \let\next\short@macro \fi
3121 % \end{macrocode}
3122 % Now that we know what macro to use to process the macro name, we
3123 % invoke it~\ldots
3124 % \begin{macrocode}
3125 \next}
3126 % \end{macrocode}
3127 % \end{macro}
3128 %
3129 %
3130 % \begin{macro}{\short@macro}
3131 %
3132 % \changes{v1.5c}{1989/04/27}{Corrected bad bug by putting the
3133 % scan@allowedfalse macro before printing
3134 % the argument.}
3135 % \changes{v1.7a}{1992/03/10}{Ensure character stored in
3136 % \cs{macro@namepart} as `letter' so index exclusion works.}
3137 % This macro will be invoked (with a single character as parameter)
3138 % when a single-character macro name has been spotted whilst
3139 % scanning within the \env{macrocode} environment.
3140 %
3141 % First we take a look at the |\index@excludelist| to see
3142 % whether this macro name should produce an index entry. This is
3143 % done by the |\ifnot@excluded| macro which assumes that the
3144 % macro name is saved in |\macro@namepart|. The character
3145 % mustn't be stored with a special category code or exclusion from
3146 % the index won't work, so we use \cs{string} to normalize it
3147 % the same way it is done in \cs{DoNotIndex}, i.e. everything ends up
3148 % catcode 12 except for the space character.
3149 % \changes{v2.0e}{1998/12/28}{Correctly use the case-changing trick.}
3150 % \changes{v3.0l}{2022/11/03}{No longer using the case-changing trick.}
3151 % \begin{macrocode}
3152 \def\short@macro#1{%
3153 \edef\macro@namepart{\string#1}%
3154 % \end{macrocode}
3155 % Any indexing is then delegated to
3156 % |\maybe@index@short@macro|. Depending on the actual character seen,
3157 % this macro has to do different things, which is why we keep it separate from
3158 % |\maybe@index@macro| to avoid the special tests in the more
3159 % common case of a multi-letter macro name.
3160 % \begin{macrocode}
3161 \maybe@index@short@macro\macro@namepart
3162 % \end{macrocode}
3163 % Then we disable the cross-referencing mechanism with
3164 % |\scan@allowedfalse| and print the actual character. The
3165 % index entry was generated first to ensure that no page break
3166 % intervenes (recall that a |^^M| will start a new line).
3167 % \begin{macrocode}
3168 \scan@allowedfalse#1%
3169 % \end{macrocode}
3170 % After typesetting the character we can safely enable the
3171 % cross-referencing feature again. Note that this macro won't be
3172 % called (since |\macro@switch| won't be called) if
3173 % cross-referencing is globally disabled.
3174 % \begin{macrocode}
3175 \scan@allowedtrue }
3176 % \end{macrocode}
3177 % \end{macro}
3178 %
3179 %
3180 %
3181 % \begin{macro}{\macro@name}
3182 % We now come to the macro which assembles command names which
3183 % consist of one or more `letters' (which might well include
3184 % |@| symbols, or anything else which has a |\catcode| of
3185 % 11).
3186 %
3187 % To do this we add the `letter' to the existing definition of
3188 % |\macro@namepart| (which you will recall was originally set
3189 % to |\@empty|).
3190 % \begin{macrocode}
3191 \def\macro@name#1{\edef\macro@namepart{\macro@namepart#1}%
3192 % \end{macrocode}
3193 % Then we grab hold of the {\em next\/} single character and let
3194 % |\more@macroname| determine whether it belongs to the letter
3195 % string forming the command name or is a `non-letter'.
3196 % \begin{macrocode}
3197 \futurelet\next\more@macroname}
3198 % \end{macrocode}
3199 % \end{macro}
3200 %
3201 %
3202 %
3203 %
3204 %
3205 % \begin{macro}{\more@macroname}
3206 %
3207 % This causes another call of |\macro@name| to add in the next
3208 % character, if it is indeed a `letter'.
3209 % \begin{macrocode}
3210 \def\more@macroname{\ifcat\noexpand\next a%
3211 \let\next\macro@name
3212 % \end{macrocode}
3213 % Otherwise, it finishes off the index entry by invoking
3214 % |\macro@finish|.
3215 % \begin{macrocode}
3216 \else \let\next\macro@finish \fi
3217 % \end{macrocode}
3218 % Here's where we invoke whatever macro was |\let| equal to
3219 % |\next|.
3220 % \begin{macrocode}
3221 \next}
3222 % \end{macrocode}
3223 % \end{macro}
3224 %
3225 %
3226 %
3227 %
3228 %
3229 % \begin{macro}{\macro@finish}
3230 % When we've assembled the full `letter'-string which forms the
3231 % command name, we set the characters forming the entire command
3232 % name, and generate an appropriate |\index| command (provided
3233 % the command name is not on the list of exclusions). The
3234 % `|\|' is already typeset; therefore we only have to output
3235 % all `letters' saved in |\macro@namepart|.
3236 % \begin{macrocode}
3237 \def\macro@finish{%
3238 \macro@namepart
3239 % \end{macrocode}
3240 % Then we call |\ifnot@excluded| to decide whether we have to
3241 % produce an index entry. The construction with |\@tempa| is
3242 % needed because we want the expansion of |\macro@namepart| in
3243 % the |\index| command.\footnote{The \texttt{\bslash index}
3244 % command will expand its argument in the \texttt{\bslash output}
3245 % routine. At this time \texttt{\bslash macro@namepart} might have a
3246 % new value.}
3247 % \begin{macrocode}
3248 % \ifnot@excluded
3249 % \edef\@tempa{\noexpand\SpecialIndex{\bslash\macro@namepart}}%
3250 % \@tempa \fi
3251 \maybe@index@macro \macro@namepart
3252 }
3253 % \end{macrocode}
3254 % \end{macro}
3255 %
3256 %
3257 %
3258 %
3259 %
3260 % \subsection[The index exclude list]{The index exclude
3261 % list\footnotemark}
3262 % \footnotetext{Info: the incomplete commentary on
3263 % \texttt{\bslash DoNotIndex} and the macros it calls
3264 % was written by Dave Love.}
3265 %
3266 %
3267 %
3268
3269 % \def\MakePrivateLetters{%
3270 % \makeatletter
3271 % \catcode`\_11
3272 % \catcode`\:11}
3273 %
3274 %
3275 % The following part of the code is a new implementation using the
3276 % \LaTeX3 programming layer as the constructs and types
3277 % provided therein are making programming much easier. Over time I
3278 % will probably replace the rest of that \DOC code too.
3279 % \begin{macrocode}
3280 \ExplSyntaxOn
3281 % \end{macrocode}
3282 %
3283 %
3284 % \DescribeMacro\l__doc_donotindex_seq
3285 % Local sequence that holds names (as strings) of commands that
3286 % should not be indexed. Within a \DOC element environment that
3287 % element is placed into the sequence so that it isn't
3288 % unnecessarily index within that part of the code. As the sequence
3289 % is local it will revert this setting at the end of the
3290 % environment so that the command is indexed elsewhere (unless it
3291 % is generally disabled from indexing).
3292 %
3293 % \DescribeMacro\g__doc_idxtype_prop
3294 % Global property list that holds for all commands that are special
3295 % \DOC elements the type of the element. The key is the command
3296 % name without backslash and the value is \DOC element type
3297 % identifier, e.g., |\texttt{Length}| for length registers if that
3298 % type has been set up. \DOC only indexes commands, that is things
3299 % starting with an escape character, i.e., a backslash (by
3300 % default). \DOC elements that do not start with an escape
3301 % character, e.g., environments are not identified when parsing
3302 % code so that aren't indexed automatically inside. Thus for them
3303 % there is no point in keeping them in that property list.
3304 %
3305 % \DescribeMacro{\doc_dont_index:n}
3306 % \DescribeInterfaceMacro{\DoNotIndex}
3307 % Takes a clist of commands (with backslash) as input and exclude
3308 % all of them from the index. User facing we make this available as
3309 % |\DoNotIndex|.
3310 %
3311 %
3312 % \DescribeInterfaceMacro\ShowIndexingState
3313 % Displays the current list of the exclude index list in a fairly
3314 % low-level form.
3315 %
3316 % \DescribeInterfaceMacro\RecordIndexType
3317 % This command takes two arguments: a command (with escape char)
3318 % and its type (i.e., first mandatory
3319 % argument of a |\NewDocElement| declaration). If |#1| should not be
3320 % included from the index, then the data is used to record that
3321 % this command is of this type. The information is then used to
3322 % generate appropriate index entries. Obviously, index entries
3323 % generated earlier will be listing the wrong type. Therefore this
3324 % information is also placed into the \texttt{.aux} file so that it
3325 % will be available at the beginning of further runs.
3326 %
3327 % This command is internally executed as part of any \DOC element
3328 % environment so it only needs to be explicitly given if for some
3329 % reason a command with a special type has no corresponding environment.
3330 %
3331 %
3332 %
3333 %
3334 % \begin{macro}{\l__doc_donotindex_seq}
3335 % \begin{macro}{\g__doc_idxtype_prop}
3336 % Declarations.
3337 % \begin{macrocode}
3338 \seq_new:N \l__doc_donotindex_seq
3339 \prop_new:N \g__doc_idxtype_prop
3340 % \end{macrocode}
3341 % \end{macro}
3342 % \end{macro}
3343 %
3344 % ^^A --------------------------------------------------
3345 %
3346 %
3347 % \begin{macro}{\__doc_trace:e}
3348 % A helper for tracing\ldots
3349 % \begin{macrocode}
3350 \cs_new:Npn\__doc_trace:e {
3351 \legacy_if:nTF{ doc@debugshow }{ \iow_term:e } { \use_none:n }
3352 }
3353 % \end{macrocode}
3354 % \end{macro}
3355 %
3356 %
3357 % ^^A --------------------------------------------------
3358 %
3359 % \begin{macro}{\doc_dont_index:n}
3360 % \begin{macro}{\__doc_dont_index:n}
3361 % \begin{macro}{\__doc_dont_index_aux:n}
3362 %
3363 % Parses the argument a clist of commands with
3364 % |\MakePrivateLetters| in force (so that special characters are
3365 % recognized as being part of command names) and puts each command
3366 % without is backslash as a string into the sequence
3367 % |\l__doc_donotindex_seq|.
3368 % \begin{macrocode}
3369 \cs_new:Npn \doc_dont_index:n {
3370 \group_begin:
3371 \MakePrivateLetters
3372 \__doc_dont_index:n
3373 }
3374 % \end{macrocode}
3375 %
3376 % \begin{macrocode}
3377 \cs_new:Npn \__doc_dont_index:n #1 {
3378 \group_end:
3379 % \end{macrocode}
3380 %
3381 % \begin{macrocode}
3382 \__doc_trace:e{Disable~ indexing~ for~ '\tl_to_str:n{#1}' }
3383 % \end{macrocode}
3384 % Adding the commands to the |\l__doc_donotindex_seq| sequence is
3385 % done by mapping the function |\__doc_dont_index_aux:n| on each
3386 % element in the clist.
3387 % \begin{macrocode}
3388 \clist_map_function:nN {#1} \__doc_dont_index_aux:n
3389 }
3390 % \end{macrocode}
3391 % We record each command by using its name as a string.
3392 % This means more tokens in the sequence but it allows
3393 % to compare names not ``action'' which is important as different
3394 % commands may have the same meaning (e.g., they may not be defined
3395 % at all),
3396 % \begin{macrocode}
3397 \cs_new:Npn \__doc_dont_index_aux:n #1 {
3398 \seq_put_right:Ne \l__doc_donotindex_seq {\expandafter\@gobble \string#1}
3399 }
3400 % \end{macrocode}
3401 % \end{macro}
3402 % \end{macro}
3403 % \end{macro}
3404 %
3405 % \begin{macro}{\DoNotIndex}
3406 % The document-level interface
3407 % \begin{macrocode}
3408 \cs_set_eq:NN \DoNotIndex \doc_dont_index:n
3409 % \end{macrocode}
3410 % \end{macro}
3411 %
3412 %
3413 % \begin{macro}{\ShowIndexingState}
3414 % Some tracing information that may be helpful.
3415 % \begin{macrocode}
3416 \def \ShowIndexingState {
3417 \__doc_trace:e{Show~ doc~ indexing~ state:}
3418 \seq_show:N \l__doc_donotindex_seq
3419 \prop_show:N \g__doc_idxtype_prop
3420 }
3421 % \end{macrocode}
3422 % \end{macro}
3423
3424
3425
3426 % ^^A --------------------------------------------------
3427 %
3428 %
3429 % \begin{macro}{\__doc_idxtype_put:Nn}
3430 % \begin{imacro}{\RecordIndexType}
3431 % \fmi{Change name of interface command!}
3432 % \begin{macro}{\RecordIndexTypeAux}
3433 % This is the internal form for |\RecordIndexType|. The first
3434 % argument is turned into a string and the rest of the processing
3435 % is then done by |\__doc_idxtype_put:nn|
3436 % \begin{macrocode}
3437 \cs_new:Npn \__doc_idxtype_put:Nn #1#2 {
3438 \exp_args:Ne \__doc_idxtype_put:nn { \cs_to_str:N #1 }{#2}
3439 % \end{macrocode}
3440 % We also make an entry in the \texttt{.aux} file so that this
3441 % declaration becomes immediately available in the next
3442 % run. However, for this we aren't reusing |\__doc_idxtype_put:N|
3443 % (a.k.a.\ |\RecordIndexType|) since that would result in doubling
3444 % such lines each time the document is run. Instead we use
3445 % |\RecordIndexTypeAux| which is only updating the data structures
3446 % without writing to the \texttt{.aux} file.
3447 % \begin{macrocode}
3448 \protected@write\@auxout{}
3449 {\string\RecordIndexTypeAux {\string#1 }{#2} }
3450 }
3451 % \end{macrocode}
3452 % When we execute this code from the \texttt{.aux} we better not
3453 % generate a new line in the \texttt{.aux}. Otherwise those would
3454 % cumulate over time.
3455 % \begin{macrocode}
3456 \cs_new:Npn \RecordIndexTypeAux #1#2 {
3457 \exp_args:Ne \__doc_idxtype_put:nn { \cs_to_str:N #1 }{#2}
3458 }
3459 % \end{macrocode}
3460 % Similarly, when the \texttt{.aux} is read at the end of the run we
3461 % should disable that command to avoid unnecessary processing.
3462 % \begin{macrocode}
3463 \AtEndDocument{
3464 \cs_set_eq:NN \RecordIndexTypeAux \use_none:nn
3465 }
3466 % \end{macrocode}
3467 % Finally, we provide the user-level interface
3468 % \begin{macrocode}
3469 \cs_set_eq:NN \RecordIndexType \__doc_idxtype_put:Nn
3470 % \end{macrocode}
3471 % \end{macro}
3472 % \end{imacro}
3473 % \end{macro}
3474 %
3475 %
3476 % \begin{macro}{\__doc_idxtype_put_scan:nn}
3477 % When we want to record an index type for a scanned name we can't
3478 % turn that into a csname and then call |\__doc_idxtype_put:Nn|
3479 % because turning it into a csname may change the meaning of the
3480 % name from ``undefined'' to |\relax|. Got bitten by that when
3481 % processing the kernel sources containing |\@undefined| within the
3482 % code: suddenly that wasn't undefined any longer.
3483 % So here is another version that works only on characters as
3484 % input. As we don't know whether or not they are proper strings
3485 % already we first make sure that this is the case.
3486 % \begin{macrocode}
3487 \cs_new:Npn \__doc_idxtype_put_scan:nn #1#2 {
3488 \exp_args:Nf \__doc_idxtype_put:nn { \tl_to_str:n {#1} }{#2}
3489 % \end{macrocode}
3490 % In this case we also have to append a backslash when writing to
3491 % the \texttt{.aux} file.
3492 % \begin{macrocode}
3493 \protected@write\@auxout{}
3494 {\string\RecordIndexTypeAux {\bslash #1 }{#2} }
3495 }
3496 % \end{macrocode}
3497 % \end{macro}
3498 %
3499 % \begin{macro}{\__doc_idxtype_put_scan:on}
3500 % And here is the one we really need since the characters are
3501 % stored in some macro.
3502 % \begin{macrocode}
3503 \cs_generate_variant:Nn \__doc_idxtype_put_scan:nn {o}
3504 % \end{macrocode}
3505 % \end{macro}
3506 %
3507 % \begin{macro}{\record@index@type@save}
3508 % And here is the interface to the rest of the code:
3509 % \begin{macrocode}
3510 \cs_set_eq:NN \record@index@type@save \__doc_idxtype_put_scan:on
3511 % \end{macrocode}
3512 % \end{macro}
3513 %
3514 %
3515 % \begin{macro}{\__doc_idxtype_put:nn}
3516 % This internal command takes two arguments: a command name as
3517 % string (no backslash) and its type (i.e., first mandatory
3518 % argument of a |\NewDocElement| declaration). If |#1| is not in
3519 % |\l__doc_donotindex_seq| it will add this data to the property
3520 % list |\g__doc_idxtype_prop| using |#1| as key and |#2| as its
3521 % value. If the key already exist its value will be overwritten. If
3522 % the command is later marked for exclusion from the index the
3523 % property list setting remains unchanged but as long as no index
3524 % is produced for the command it will not be consulted.
3525 %
3526 % Note: the command assumes that |#1| is already in string form
3527 % \begin{macrocode}
3528 \cs_new:Npn \__doc_idxtype_put:nn #1#2 {
3529 % \end{macrocode}
3530 % No mystery here: if the command is not marked for exclusion from
3531 % the index add the property. The extra |\tl_to_str:n| is a safety
3532 % measure in case the input wasn't already in that form (should
3533 % only be the case with broken input but \ldots)
3534 % \begin{macrocode}
3535 \exp_args:NNf
3536 \seq_if_in:NnTF \l__doc_donotindex_seq {\tl_to_str:n{#1}}
3537 % \end{macrocode}
3538 % Some tracing info \ldots{}
3539 % \begin{macrocode}
3540 {
3541 \__doc_trace:e{Not~ recording~ index~ type~ for~ '\bslash #1' }
3542 }
3543 {
3544 \__doc_trace:e{Recording~ index~ type~ for~ '\bslash #1' ~ as~ #2 }
3545 % \end{macrocode}
3546 % Stick the data into the property list:
3547 % \begin{macrocode}
3548 \prop_gput:Nnn \g__doc_idxtype_prop {#1}{#2}
3549 }
3550 }
3551 % \end{macrocode}
3552 % \end{macro}
3553 %
3554 % ^^A --------------------------------------------------
3555 %
3556 %
3557 % \begin{macro}{\exp_args:co}
3558 % A helper: construct a function and call it with its first argument
3559 % expanded once:
3560 % \begin{macrocode}
3561 \cs_new:Npn \exp_args:co #1#2
3562 { \cs:w #1 \exp_after:wN \cs_end:\exp_after:wN {#2} }
3563 % \end{macrocode}
3564 % \end{macro}
3565 %
3566 % \changes{v3.0r}{2026-03-13}{Tidy up variants}
3567 %
3568 % ^^A --------------------------------------------------
3569 %
3570 %
3571 %
3572 % \DescribeMacro\maybe@index@macro
3573 %
3574 % This takes a macro name (without backslash) as parsed within a
3575 % \env{macrocode} environment and checks if it should get indexed
3576 % (i.e., is not on the exclude list) and if so how (i.e., gets it
3577 % index type property and makes the right choice depending on that.
3578 %
3579
3580
3581 % \begin{macro}{\maybe@index@macro}
3582 % \begin{macro}{\__doc_maybe_index:o}
3583 % We first make sure that the argument is really a string (so that
3584 % we have a defined situation) and then
3585 % pass it on to |\__doc_maybe_index_aux:nN| to do the work.
3586 % The second argument defines the indexing operation
3587 % \cs{SpecialIndex} for multi-letter macros and below
3588 % \cs{SpecialShortIndex} for single character macros.
3589 % \begin{macrocode}
3590 \cs_new:Npn \__doc_maybe_index:o #1 {
3591 \exp_args:Nf \__doc_maybe_index_aux:nN { \tl_to_str:o {#1} }
3592 \SpecialIndex
3593 }
3594 % \end{macrocode}
3595 % And here is what we call it in the older non-expl3 code:
3596 % \begin{macrocode}
3597 \cs_set_eq:NN \maybe@index@macro \__doc_maybe_index:o
3598 % \end{macrocode}
3599 % \end{macro}
3600 % \end{macro}
3601 %
3602 %
3603 % \begin{macro}{\maybe@index@short@macro}
3604 % \begin{macro}{\__doc_maybe_index_short:o}
3605 % Single character macros are handled similarly but there the
3606 % indexing is done by \cs{SpecialShortIndex} and it is simpler
3607 % because we know that the argument contains a string token not letters.
3608 % \changes{v3.0l}{2022/11/03}{We know the argument expands to a single string token}
3609 % \begin{macrocode}
3610 \cs_new:Npn \__doc_maybe_index_short:o #1 {
3611 \exp_args:No \__doc_maybe_index_aux:nN #1
3612 \SpecialShortIndex
3613 }
3614 \cs_set_eq:NN \maybe@index@short@macro \__doc_maybe_index_short:o
3615 % \end{macrocode}
3616 % \end{macro}
3617 % \end{macro}
3618 %
3619 %
3620 %
3621 % \begin{macro}{\__doc_maybe_index_aux:nN}
3622 % Take a string (representing a macro without backslash) and make
3623 % the right choices with respect to indexing.
3624 % \begin{macrocode}
3625 \cs_new:Npn \__doc_maybe_index_aux:nN #1#2 {
3626 % \end{macrocode}
3627 % A bit of tracing:
3628 % \begin{macrocode}
3629 \__doc_trace:e{Searching~ for~ '\bslash #1'}
3630 % \end{macrocode}
3631 % If the name is on the exclude list do nothing.
3632 % \begin{macrocode}
3633 \seq_if_in:NnTF \l__doc_donotindex_seq {#1}
3634 % \end{macrocode}
3635 %
3636 % \begin{macrocode}
3637 {
3638 \__doc_trace:e{Not~ indexing~ '\bslash #1' }
3639 }
3640 % \end{macrocode}
3641 % Otherwise check if this name has an index type property attached
3642 % to it.
3643 % \begin{macrocode}
3644 {
3645 \prop_get:NnNTF \g__doc_idxtype_prop {#1} \l__doc_idxtype_tl
3646 % \end{macrocode}
3647 % If so construct and execute
3648 % |\Code|\meta{idxtype}|Index|\footnote{I guess this should really
3649 % be an internal name not a user-level one.} which is done inside
3650 % |\__doc_maybe_index_aux|
3651 % \begin{macrocode}
3652 {
3653 \exp_args:Ncno \__doc_maybe_index_aux:Nnn
3654 { Code \tl_use:N \l__doc_idxtype_tl Index }
3655 {code} {\bslash #1}
3656 }
3657 % \end{macrocode}
3658 % Otherwise execute |\SpecialIndex| which is a short form for
3659 % |\CodeMacroIndex{code}| or execute \cs{SpecialShortIndex} which
3660 % deals with some special cases for single letter macros.
3661 % \begin{macrocode}
3662 {
3663 \__doc_trace:e{Indexing~ '\bslash #1'\space (\string #2)}
3664 \exp_args:No #2 {\bslash #1}
3665 }
3666 }
3667 }
3668 % \end{macrocode}
3669 % \end{macro}
3670 %
3671 %
3672 %
3673 % \begin{macro}{\SpecialShortIndex}
3674 % \fmi{to be documented; also needs cleaning up as it is a mix of
3675 % old and new right now}
3676 % \begin{macrocode}
3677 \cs_new:Npn \SpecialShortIndex #1 {
3678 \@SpecialIndexHelper@ #1\@nil
3679 \@bsphack
3680 \ifdoc@noindex \else
3681 \str_case_e:nnF {\@gtempa }
3682 {
3683 {\cs_to_str:N \^^M } {\def\reserved@a{ \string \space \actualchar }
3684 \def\reserved@b { \space }
3685 \let\reserved@c \@empty }
3686 % \end{macrocode}
3687 % With the fix for
3688 % \verb*=\ = we now have to look for a real space to handle that command sequence.
3689 % \changes{v3.0l}{2022/11/03}{look for the right token}
3690 % \begin{macrocode}
3691 { ~ } {\def\reserved@a{ \string \space \actualchar }
3692 \def\reserved@b { \space }
3693 \let\reserved@c \@empty }
3694 {\c_left_brace_str} { \def\reserved@a{ \bgroup \actualchar }
3695 \def\reserved@b { \c_left_brace_str }
3696 \def\reserved@c { \noexpand\iffalse
3697 \c_right_brace_str
3698 \noexpand\fi } }
3699 {\c_right_brace_str} { \def\reserved@a{ \egroup \actualchar
3700 \noexpand\iffalse
3701 \c_left_brace_str
3702 \noexpand\fi }
3703 \def\reserved@b { \c_right_brace_str }
3704 \let\reserved@c \@empty }
3705 % \end{macrocode}
3706 % The case of \cs{verbatimchar} is tricky. We can't stick it into
3707 % the normal \cs{verb} because we would then get something like
3708 % \verb=\verb+\++= which would comes out as ``\verb+\++'' instead
3709 % of \verb=\+=. So we use the \cs{verb} to only generate the
3710 % backslash and then use \cs{texttt} on the \cs{verbatimchar}
3711 % itself. However, that is not enough if we are unlucky and
3712 % somebody (like Will :-)) has used something like \verb=&= with a
3713 % special catcode for the \cs{verbatimchar}. We therefore also
3714 % apply \cs{string} to it when we read it back.
3715 % \begin{macrocode}
3716 {\verbatimchar} { \def\reserved@a{ \quotechar\verbatimchar
3717 \actualchar }
3718 \let\reserved@b \@empty
3719 \def\reserved@c
3720 { \string\texttt{\string\string\verbatimchar} } }
3721 }
3722 { \def\reserved@a {\quotechar \@gtempa \actualchar }
3723 \def\reserved@b {\quotechar \@gtempa }
3724 \let\reserved@c \@empty }
3725 \special@index {
3726 \reserved@a
3727 \string\verb
3728 \quotechar *\verbatimchar \quotechar \bslash
3729 \reserved@b
3730 \verbatimchar
3731 \reserved@c
3732 \encapchar code}
3733 \fi
3734 \@esphack
3735 }
3736 % \end{macrocode}
3737 % \end{macro}
3738
3739
3740
3741
3742
3743 % \begin{macro}{\__doc_maybe_index_aux:Nnn}
3744 % Execute the function passed on as first argument taking argument
3745 % 2 and 3 as input.
3746 % \begin{macrocode}
3747 \cs_new:Npn \__doc_maybe_index_aux:Nnn #1#2#3 {
3748 % \end{macrocode}
3749 % We have to be a little careful: as that function name is
3750 % constructed it may not actually exist (as constructions generate
3751 % |\relax| in \TeX{} in that case). In that case we raise an error,
3752 % otherwise we execute (with a little bit of tracing info):
3753 % \begin{macrocode}
3754 \cs_if_exist:NTF #1
3755 {
3756 \__doc_trace:e{Indexing~ '#3'\space as~
3757 \tl_use:N \l__doc_idxtype_tl }
3758 #1{#2}{#3}
3759 }
3760 {
3761 \PackageError{doc}{Doc~ element~
3762 '\tl_use:N \l__doc_idxtype_tl'~ unknown}%
3763
3764 {When~ using~ '\string\RecordIndexType'~ the~ type~ must~
3765 be~ known~\MessageBreak
3766 to~ the~ system,~ i.e.,~ declared~ via~
3767 '\string\NewDocElement'\MessageBreak
3768 before~ it~ can~ be~ used~ in~ indexing.}
3769 }
3770 }
3771 % \end{macrocode}
3772 % \end{macro}
3773 %
3774 %
3775 % Back to old style coding \ldots
3776 % \begin{macrocode}
3777 \ExplSyntaxOff
3778 % \end{macrocode}
3779 %
3780 %
3781 %
3782 % \subsection{Macros for generating index entries}
3783 %
3784 % Here we provide default definitions for the macros invoked to create
3785 % index entries; these are either invoked explicitly, or automatically
3786 % by |\scan@macro|. As already mentioned, the definitions given
3787 % here presuppose that the |.idx| file will be processed by
3788 % Chen's \prg{makeindex} program --- they may be redefined for use
3789 % with the user's favorite such program.
3790 %
3791 % To assist the reader in locating items in the index, all such
3792 % entries are sorted alphabetically {\em ignoring\/} the initial
3793 % `|\|'; this is achieved by issuing an |\index| command which
3794 % contains the `actual' operator for \prg{makeindex}. The default
3795 % value for the latter operator is `|@|', but the latter character is
3796 % so popular in \LaTeX\ package files that it is necessary to substitute
3797 % another character. This is indicated to \prg{makeindex} by means
3798 % of an `index style file'; the character selected for this function
3799 % is |=|, and therefore this character too must be specially treated
3800 % when it is met in a \TeX\ command. A suitable index style file is
3801 % provided amongst the supporting files for this style file in
3802 % \texttt{gind.ist} and is generated from this source by processing
3803 % with \texttt{docstrip} to extract the module \textbf{gind}. A
3804 % similar style file \texttt{gglo.ist} is supplied for sorting the
3805 % change information in the glossary file and is extracted as module
3806 % \textbf{gglo}. First of all we add some information to the front of
3807 % the \texttt{.ist} files. \changes{v1.7a}{1992/03/11}{glo.ist and
3808 % gind.ist now derivable from doc.dtx with docstrip.}
3809 % \begin{macrocode}
3810 %</package>
3811 %<+gind|gglo>%% This is a MAKEINDEX style file which should be used to
3812 %<+gind>%% generate the formatted index for use with the doc
3813 %<+gglo>%% generate the formatted change history for use with the doc
3814 %<+gind|gglo>%% package. The TeX commands used below are defined in
3815 %<+gind|gglo>%% doc.sty. The commands for MAKEINDEX like `level'
3816 %<+gind|gglo>%% `item_x1' are described in `` Makeindex, A General
3817 %<+gind|gglo>%% Purpose, Formatter-Independent Index Processor'' by
3818 %<+gind|gglo>%% Pehong Chen.
3819 %<+gind|gglo>
3820 % \end{macrocode}
3821 %
3822 % \begin{imacro}{\actualchar}
3823 % \begin{imacro}{\quotechar}
3824 % \begin{imacro}{\levelchar}
3825 % First come the definitions of |\actualchar|,
3826 % |\quotechar| and |\levelchar|. Note, that our defaults
3827 % are not the ones used by the \prg{makeindex} program without a
3828 % style file.
3829 % \begin{macrocode}
3830 %<*package>
3831 \@ifundefined{actualchar}{\def\actualchar{=}}{}
3832 \@ifundefined{quotechar}{\def\quotechar{!}}{}
3833 \@ifundefined{levelchar}{\def\levelchar{>}}{}
3834 %</package>
3835 %<+gind|gglo>actual '='
3836 %<+gind|gglo>quote '!'
3837 %<+gind|gglo>level '>'
3838 %<*package>
3839 % \end{macrocode}
3840 % \end{imacro}
3841 % \end{imacro}
3842 % \end{imacro}
3843 %
3844 %
3845 % \begin{imacro}{\encapchar}
3846 % The \prg{makeindex} default for the |\encapchar| isn't
3847 % changed.
3848 % \begin{macrocode}
3849 \@ifundefined{encapchar}{\def\encapchar{|}}{}
3850 % \end{macrocode}
3851 % \end{imacro}
3852 %
3853 %
3854 % \begin{imacro}{\verbatimchar}
3855 % We also need a special character to be used as a delimiter for
3856 % the |\verb*| command used in the definitions below.
3857 % \begin{macrocode}
3858 \@ifundefined{verbatimchar}{\def\verbatimchar{+}}{}
3859 % \end{macrocode}
3860 % \end{imacro}
3861 %
3862 %
3863 %
3864 % \begin{macro}{\@SpecialIndexHelper@}
3865 % \fmi{doc or drop}
3866 % \begin{macrocode}
3867 \begingroup
3868 \catcode`\|=0
3869 \catcode`\\=12
3870 % \end{macrocode}
3871 % \SpecialEscapechar\|
3872 % \begin{macrocode}
3873 |gdef|@SpecialIndexHelper@#1#2|@nil{%
3874 |if |noexpand#1\%
3875 |gdef|@gtempa{#2}%
3876 |else
3877 |begingroup
3878 |escapechar|m@ne
3879 |expandafter|gdef|expandafter|@gtempa|expandafter{|string#1#2}%
3880 |endgroup
3881 |fi}
3882 |endgroup
3883 % \end{macrocode}
3884 %
3885 % \end{macro}
3886 %
3887 %
3888 %
3889 % \begin{imacro}{\SortIndex}
3890 % This macro is used to generate the index entries for any
3891 % single-character command that |\scan@macro| encounters. The
3892 % first parameter specifies the lexical order for the character,
3893 % whilst the second gives the actual characters to be printed in
3894 % the entry. It can also be used directly to generate index entries
3895 % which differ in sort key and actual entry.
3896 % \begin{macrocode}
3897 \def\SortIndex#1#2{%
3898 \ifdoc@noindex\else
3899 \index{#1\actualchar#2}%
3900 \fi
3901 }
3902 % \end{macrocode}
3903 % \end{imacro}
3904 %
3905 %
3906 %
3907 %
3908 % \begin{imacro}{\LeftBraceIndex}
3909 % \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
3910 % \begin{imacro}{\RightBraceIndex}
3911 % \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)} These
3912 % two macros fix the problems with \prg{makeindex}. Note the
3913 % `hack' with \iffalse{-to get matching braces\fi |\iffalse}\fi|
3914 % to satisfy both \TeX{} and the
3915 % \prg{makeindex} program. When this is written to the
3916 % \texttt{.idx} file \TeX{} will see both braces (so we get a
3917 % balanced text). \prg{makeindex} will also see balanced braces
3918 % but when the actual index entry is again processed by \TeX{} the
3919 % brace in between |\iffalse| |\fi| will vanish.
3920 % \begin{macrocode}
3921 \@ifundefined{LeftBraceIndex}{\def\LeftBraceIndex{%
3922 \special@index{\bgroup\actualchar
3923 \string\verb% % to fool emacs highlighting
3924 \quotechar*\verbatimchar
3925 \quotechar\bslash{\verbatimchar\string\iffalse}\string\fi}}}{}
3926
3927 \@ifundefined{RightBraceIndex}{\def\RightBraceIndex{%
3928 \special@index{\egroup\actualchar\string\iffalse{\string\fi
3929 \string\verb% % to fool emacs highlighting
3930 \quotechar*\verbatimchar\quotechar\bslash}\verbatimchar}}}{}
3931 % \end{macrocode}
3932 % \end{imacro}
3933 % \end{imacro}
3934 %
3935 %
3936 % \begin{imacro}{\PercentIndex}
3937 % \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
3938 % \changes{v1.7c}{1992/03/25}{Default now for bug-fixed makeindex}
3939 % By default we assume a version of \prg{makeindex} without the
3940 % percent bug is being used.
3941 % \begin{macrocode}
3942 \@ifundefined{PercentIndex}
3943 {\def\PercentIndex{\it@is@a\percentchar}}{}
3944 % \end{macrocode}
3945 % \end{imacro}
3946 %
3947 %
3948 % \begin{omacro}{\OldMakeindex}
3949 % \changes{v1.7c}{1992/03/26}{Replaced \cs{NewMakeIndex}.}
3950 % \begin{imacro}{\percentchar}
3951 % Here is one solution for the percent bug in \prg{makeindex}.
3952 % The macro |\percentchar| denotes a |%|$_{12}$. Calling this from
3953 % a package or the driver file sets things up
3954 % appropriately.\label{bug:fixes}
3955 % \begin{macrocode}
3956 \def\OldMakeindex{\def\PercentIndex{%
3957 \special@index{\quotechar\percentchar\actualchar
3958 \string\verb% % to fool emacs highlighting
3959 \quotechar*\verbatimchar\quotechar\bslash
3960 \percentchar\percentchar\verbatimchar}}}
3961 {\catcode`\%=12 \gdef\percentchar{%}}
3962 % \end{macrocode}
3963 % \end{imacro}
3964 % \end{omacro}
3965 %
3966 %
3967 % \begin{macro}{\it@is@a}
3968 % This macro is supposed to produce a correct |\SortIndex|
3969 % entry for a given character. Since this character might be
3970 % recognized as a `command' character by the index program used,
3971 % all characters are quoted with the |\quotechar|.
3972 % \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
3973 % \begin{macrocode}
3974 \def\it@is@a#1{\special@index{\quotechar #1\actualchar
3975 \string\verb% % to fool emacs highlighting
3976 \quotechar*\verbatimchar
3977 \quotechar\bslash\quotechar#1\verbatimchar}}
3978 % \end{macrocode}
3979 % \end{macro}
3980 %
3981 %
3982 %
3983 %
3984 %
3985 %
3986 % \subsection{Redefining the \env{index} environment}
3987 %
3988 %\changes{v1.4r}{1989/04/22}{twocols env. placed into separate file}
3989 %\changes{v1.4?}{1989/04/19}{use DEK's algorithm and implement
3990 % a twocols env.}
3991 %\changes{v1.4?}{1989/04/16}{changes to the index env.}
3992 %\changes{v1.5a}{1989/04/26}{Now input multicol.sty instead of
3993 % multcols.sty}
3994
3995 %
3996 % \begin{ldimen}{\IndexMin}
3997 % \begin{lcounter}{IndexColumns}
3998 % \changes{v1.4t}{1989/04/24}{Counter added.}
3999 % If \texttt{multicol} is in use,
4000 % when the index is started we compute the remaining space on the
4001 % current page; if it is greater than |\IndexMin|, the first
4002 % part of the index will then be placed in the available space.
4003 % The number of columns set is controlled by the counter
4004 % |\c@IndexColumns| which can be changed with a
4005 % |\setcounter| declaration.
4006 % \begin{macrocode}
4007 \newdimen\IndexMin \IndexMin = 80pt
4008 \newcount\c@IndexColumns \c@IndexColumns = 3
4009 % \end{macrocode}
4010 % \end{lcounter}
4011 % \end{ldimen}
4012 %
4013 %
4014 %
4015 % \begin{environment}{theindex}
4016 % Now we start the multi-column mechanism, if appropriate. We use the
4017 % \LaTeX{} counter |\c@IndexColumns| declared above to denote
4018 % the number of columns and insert the `index prologue' text (which
4019 % might contain a |\section| call, etc.). See the default
4020 % definition for an example.
4021 % \changes{v1.4t}{1989/04/24}{Incorporated new multicols env.}
4022 % \changes{v1.5a}{1989/04/26}{Call multicols first}
4023 % \changes{v1.6e}{1991/04/03}{Turned into env definition.}
4024 % \changes{v1.7a}{1992/03/04}{Include test for multicols.}
4025 % \begin{macrocode}
4026 \ifdoc@multicol
4027 % \end{macrocode}
4028 %
4029 % \begin{macrocode}
4030 \RequirePackage{multicol}
4031 % \end{macrocode}
4032 %
4033 % \begin{macrocode}
4034 \renewenvironment{theindex}
4035 {\begin{multicols}\c@IndexColumns[\index@prologue][\IndexMin]%
4036 % \end{macrocode}
4037 % Then we make a few last minute assignments to read the individual
4038 % index |\item|$\,$s and finish off by ignoring any initial
4039 % space.
4040 % \begin{macrocode}
4041 \IndexParms \let\item\@idxitem \ignorespaces}%
4042 % \end{macrocode}
4043 %
4044 % \begin{macro}{\endtheindex}
4045 % \changes{v1.4t}{1989/04/24}{Incorporated new multicols env.}
4046 % At the end of the index, we have only to end the \env{multicols}
4047 % environment.
4048 % \begin{macrocode}
4049 {\end{multicols}}
4050 % \end{macrocode}
4051 % If we can't use \env{multicols} we warn the user and use an
4052 % environment that's basically the one from \texttt{article.sty}.
4053 % \begin{macrocode}
4054 \else
4055 \def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
4056 \columnseprule \z@ \columnsep 35\p@
4057 \twocolumn[\index@prologue]%
4058 \IndexParms \let\item\@idxitem \ignorespaces}
4059 \def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
4060 \fi
4061 % \end{macrocode}
4062 % \end{macro}
4063 % \end{environment}
4064 %
4065 % Here are the necessary \prg{makeindex} declarations. We disable
4066 % scanning of macro names inside the index with |\scan@allowedfalse\n|
4067 % to avoid recursion.
4068 % \begin{macrocode}
4069 %</package>
4070 %<+gind>preamble
4071 %<+gind>"\n \\begin{theindex} \n \\makeatletter\\scan@allowedfalse\n"
4072 %<+gind>postamble
4073 %<+gind>"\n\n \\end{theindex}\n"
4074 %<*package>
4075 % \end{macrocode}
4076 %
4077 %
4078 % \begin{imacro}{\IndexPrologue}
4079 % \begin{macro}{\index@prologue}
4080 % \changes{v1.9w}{1995/12/27}{Text changed}
4081 % \changes{v1.9x}{1996/01/11}{Text depends on code lines used}
4082 % The |\IndexPrologue| macro is used to place a short message
4083 % into the document above the index. It is implemented by
4084 % redefining |\index@prologue|, a macro which holds the
4085 % default text. We'd better make it a |\long| macro to allow
4086 % |\par| commands in its argument.
4087 % \begin{macrocode}
4088 \long\def\IndexPrologue#1{\@bsphack\def\index@prologue{#1}\@esphack}
4089 % \end{macrocode}
4090 % Now we test whether the default is already defined by another
4091 % package file. If not we define it.
4092 % \changes{v2.0j}{2000/05/22}{Less obscure wording? (CAR pr/3202)}
4093 % \begin{macrocode}
4094 \@ifundefined{index@prologue}
4095 {\def\index@prologue{\section*{Index}%
4096 \markboth{Index}{Index}%
4097 Numbers written in italic refer to the page
4098 where the corresponding entry is described;
4099 numbers underlined refer to the
4100 \ifcodeline@index
4101 code line of the
4102 \fi
4103 definition; numbers in roman refer to the
4104 \ifcodeline@index
4105 code lines
4106 \else
4107 pages
4108 \fi
4109 where the entry is used.
4110 }}{}
4111 % \end{macrocode}
4112 % \end{macro}
4113 % \end{imacro}
4114 %
4115 %
4116 %
4117 % \begin{imacro}{\IndexParms}
4118 % These are some last-minute assignments for formatting the index
4119 % entries. They are defined in a separate macro so that a user can
4120 % substitute different definitions. We start by defining the
4121 % various parameters controlling leading and the separation between
4122 % the two columns. The entire index is set in |\small| size.
4123 % \begin{macrocode}
4124 \@ifundefined{IndexParms}
4125 {\def\IndexParms{%
4126 \parindent \z@
4127 \columnsep 15pt
4128 \parskip 0pt plus 1pt
4129 \rightskip 15pt
4130 \mathsurround \z@
4131 \parfillskip=-15pt
4132 \small
4133 % \end{macrocode}
4134 % \begin{macro}{\@idxitem}
4135 % \begin{macro}{\subitem}
4136 % \begin{macro}{\subsubitem}
4137 % Index items are formatted with hanging indentation for any items
4138 % which may require more than one line.
4139 % \begin{macrocode}
4140 \def\@idxitem{\par\hangindent 30pt}%
4141 % \end{macrocode}
4142 % Any sub-item in the index is formatted with a 15pt indentation
4143 % under its main heading.
4144 % \begin{macrocode}
4145 \def\subitem{\@idxitem\hspace*{15pt}}%
4146 % \end{macrocode}
4147 % Whilst sub-sub-items go in a further 10pt.
4148 % \begin{macrocode}
4149 \def\subsubitem{\@idxitem\hspace*{25pt}}%
4150 % \end{macrocode}
4151 % \begin{macro}{\indexspace}
4152 % The \prg{makeindex} program generates an |\indexspace|
4153 % before each new alphabetic section commences. After this final
4154 % definition we end the |\@ifundefined| and the definition of
4155 % |\IndexParms|.
4156 % \begin{macrocode}
4157 \def\indexspace{\par\vspace{10pt plus 2pt minus 3pt}}%
4158 }}{}
4159 % \end{macrocode}
4160 % \end{macro}
4161 % \end{macro}
4162 % \end{macro}
4163 % \end{macro}
4164 % \end{imacro}
4165 %
4166 %
4167 % \begin{imacro}{\efill}
4168 % This definition of |\efill| is intended to be used after index
4169 % items which have no following text (for example, ``\textit{
4170 % see\/}'' entries). It just ensures that the current line is
4171 % filled, preventing ``|Underfull \hbox|'' messages.
4172 % \begin{macrocode}
4173 \def\efill{\hfill\nopagebreak}%
4174 %</package>
4175 %<+gind|gglo>item_x1 "\\efill \n \\subitem "
4176 %<+gglo>item_x2 "\\ "
4177 %<+gind>item_x2 "\\efill \n \\subsubitem "
4178 %<*package>
4179 % \end{macrocode}
4180 % \end{imacro}
4181 %
4182 %
4183 %
4184 % \begin{imacro}{\pfill}
4185 % The following definitions provide the |\pfill| command; if
4186 % this is specified in the index style file to \prg{makeindex} as
4187 % the delimiter to appear after index items, then the intervening
4188 % space before the referenced page numbers will be filled with
4189 % dots, with a little white space interpolated at each end of the
4190 % dots. If the line is broken the dots will show up on both lines.
4191 % \begin{macrocode}
4192 \def\pfill{\unskip~%
4193 \leaders\hbox to.6em{\hss .\hss}\hfill
4194 \penalty500\strut\nobreak
4195 \leaders\hbox to.6em{\hss .\hss}\hfil
4196 ~\ignorespaces}%
4197 %</package>
4198 %<+gind|gglo>delim_0 "\\pfill "
4199 %<+gind|gglo>delim_1 "\\pfill "
4200 %<+gind|gglo>delim_2 "\\pfill "
4201 %<*package>
4202 % \end{macrocode}
4203 % \end{imacro}
4204 %
4205 %
4206 %
4207 % \begin{imacro}{\*}
4208 % Here is the definition for the |\*| macro. It isn't used in
4209 % this set of macros.
4210 % \begin{macrocode}
4211 \def\*{\leavevmode\lower.8ex\hbox{$\,\widetilde{\ }\,$}}
4212 % \end{macrocode}
4213 % \end{imacro}
4214 %
4215 %
4216 % \begin{imacro}{\main}
4217 % The \textit{defining\/} entry for a macro name is flagged with
4218 % the string \texttt{\encapchar main}\footnote{With the current
4219 % definition of \texttt{\bslash encapchar} substituted for
4220 % \texttt{\encapchar}} in the |\index| command; \prg{makeindex}
4221 % processes this so that the |\main| macro will be invoked to
4222 % underline the page number(s) on which the {\em definition\/} of
4223 % the macro will be found.
4224 % \begin{macrocode}
4225 \@ifundefined{main}{\def\main#1{\underline{#1}}}{}
4226 % \end{macrocode}
4227 % \end{imacro}
4228 %
4229 % \begin{imacro}{\usage}
4230 % The |\usage| macro is used to indicate entries describing
4231 % the usage of a macro. The corresponding page number(s) will be
4232 % set in \textit{italics}.
4233 % \begin{macrocode}
4234 \@ifundefined{usage}{\def\usage#1{\textit{#1}}}{}
4235 % \end{macrocode}
4236 % \end{imacro}
4237 %
4238 % \begin{imacro}{\code}
4239 % The |\code| macro is used to indicate index entries to code lines
4240 % that aren't main entries.
4241 % By default we do nothing special with them
4242 % the usage of a macro.
4243 % \begin{macrocode}
4244 \@ifundefined{code}{\def\code#1{#1}}{}
4245 % \end{macrocode}
4246 % \end{imacro}
4247 %
4248 %
4249 % \begin{imacro}{\PrintIndex}
4250 % \changes{v1.5k}{1989/09/04}{\cs{printindex} changed to
4251 % \cs{PrintIndex}}
4252 % \changes{v1.7a}{1992/02/26}{Documentation moved to interface section.}
4253 % \changes{v1.9h}{1994/02/10}{Use \cs{@input@} instead of \cs{@input}.}
4254 % \changes{v1.9w}{1995/12/29}{Turn the cmd into a noop after use.}
4255 % This is the same as |\printindex| in the \pkg{makeidx} package.
4256 % \begin{macrocode}
4257 \def\PrintIndex{\@input@{\jobname.ind}%
4258 \global\let\PrintIndex\@empty}
4259 % \end{macrocode}
4260 % \end{imacro}
4261 %
4262 %
4263 % We want headings in the index (and changes list) according to the
4264 % initial character of the next block of entries and have to instruct
4265 % \prg{makeindex} appropriately. Unfortunately the specification
4266 % for this changed sometime between versions 2.4 and 2.11 of
4267 % \prg{makeindex}. We provide both ways of doing it but
4268 % unfortunately this will always produce a warning message from
4269 % \prg{makeindex}. This is for older versions:
4270 % \changes{v1.7h}{1992/07/01}{Turn off headings in gls file}
4271 % \begin{macrocode}
4272 %</package>
4273 %<+gind,gglo>% The next lines will produce some warnings when
4274 %<+gind,gglo>% running Makeindex as they try to cover two different
4275 %<+gind,gglo>% versions of the program:
4276 %<+gind,gglo>lethead_prefix "{\\bfseries\\hfil "
4277 %<+gind,gglo>lethead_suffix "\\hfil}\\nopagebreak\n"
4278 %<+gind>lethead_flag 1
4279 %<+gglo>lethead_flag 0
4280 % \end{macrocode}
4281 % This works for newer ones:
4282 % \begin{macrocode}
4283 %<+gind,gglo>heading_prefix "{\\bfseries\\hfil "
4284 %<+gind,gglo>heading_suffix "\\hfil}\\nopagebreak\n"
4285 %<+gind>headings_flag 1
4286 %<+gglo>headings_flag 0
4287 %<*package>
4288 % \end{macrocode}
4289 %
4290 %
4291 %
4292 % \subsection[Dealing with the change history]
4293 % {Dealing with the change history\footnotemark}
4294 % \footnotetext{The whole section was proposed by Brian \textsc{Hamilton
4295 % Kelly}. He also documented and debugged the macros as
4296 % well as many other parts of this package.}
4297 %
4298 % To provide a change history log, the |\changes| command has
4299 % been introduced. This takes three arguments, respectively, the
4300 % version number of the file, the date of the change, and some detail
4301 % regarding what change has been made. The second of these arguments
4302 % is otherwise ignored, but the others are written out and may be used
4303 % to generate a history of changes, to be printed at the end of the
4304 % document. However, note that older versions of Chen's standard
4305 % \prg{makeindex}
4306 % program limit any textual field to just 64 characters; therefore,
4307 % is important that the number of characters in the second and third
4308 % parameters should not exceed 61 altogether (to allow for the
4309 % parentheses placed around the date).
4310 %
4311 % \begin{imacro}{\changes}
4312 % \changes{BHK}{1989/04/26}{Documented \texttt{\protect\bslash changes}
4313 % command.}
4314 % \changes{BHK}{1989/04/26}{Changed definition of
4315 % \texttt{\protect\bslash protect}.} The output of the |\changes|
4316 % command goes into the \meta{Glossary\_File} and therefore uses
4317 % the normal |\glossaryentry| commands.\footnote{Note that a recent
4318 % change in \LaTeX{} 2.09 changed the command name in the
4319 % \texttt{.glo} file from \texttt{\bslash indexentry} to
4320 % \texttt{\bslash glossaryentry}. It is therefore necessary to
4321 % have a special \prg{makeindex} style file called
4322 % \texttt{gglo.ist} to process this file correctly.} Thus
4323 % \prg{makeindex} or a similar program can be used to process
4324 % the output into a sorted ``glossary''. The |\changes| command
4325 % commences by taking the usual measures to hide its spacing, and
4326 % then redefines |\protect| for use within the argument of the
4327 % generated |\indexentry| command.
4328 %
4329 % We re-code nearly all chars found in |\sanitize| to letter
4330 % since the use of special package which make some characters
4331 % active might upset the |\changes| command when writing its
4332 % entries to the file. However we have to leave |%| as comment
4333 % and \verb*+ + as \meta{space} otherwise chaos will happen.
4334 % And, of course the |\| should be available as escape
4335 % character.
4336 % \changes{v1.5v}{1990/01/28}{`Re-code a lot of chars.}
4337 % \changes{v1.5m}{1989/09/20}{\cs{actualchar} in second level removed.}
4338 % \changes{v1.5o}{1989/09/24}{New sorting.}
4339 % \changes{v1.6c}{1990/06/29}{Again new sorting.}
4340 % \changes{v1.9u}{1995/08/06}{Use \cs{protected@edef}}
4341 % \begin{macrocode}
4342 \def\changes{\@bsphack\begingroup\@sanitize
4343 \catcode`\\\z@ \catcode`\ 10 \MakePercentIgnore
4344 \changes@}
4345 \def\changes@#1#2#3{%
4346 \protected@edef\@tempa{\noexpand\glossary{#1%
4347 % \end{macrocode}
4348 % If asked for we also show the date of in the change log (after
4349 % the version).
4350 % \changes{v3.0g}{2022/06/01}{Show change dates if asked for (gh/531)}
4351 % \begin{macrocode}
4352 \ifdoc@reportchangedates
4353 \space -- #2\fi
4354 \levelchar
4355 % \end{macrocode}
4356 % \changes{v1.9u}{1995/08/06}{Use value of \cs{saved@macroname} to
4357 % find out about change entries at outer level}
4358 % If the macro |\saved@macroname| doesn't contain any macro name
4359 % (ie is empty) the current changes entry was done at top-level.
4360 % In this case we precede it by |\generalname|.
4361 % \begin{macrocode}
4362 \ifx\saved@macroname\@empty
4363 % \end{macrocode}
4364 % Putting a |!| at the beginning of the entry hopefully moves this
4365 % entry to the very beginning during sorting.
4366 % \begin{macrocode}
4367 \quotechar!%
4368 \actualchar
4369 \generalname
4370 \else
4371 % \end{macrocode}
4372 % \changes{v2.1g}{2016/02/15}{Use \cs{saved@indexname}}
4373 % \begin{macrocode}
4374 \saved@indexname
4375 \actualchar
4376 \string\verb% % to fool emacs highlighting
4377 \quotechar*%
4378 \verbatimchar\saved@macroname
4379 \verbatimchar
4380 \fi
4381 :\levelchar #3}}%
4382 \@tempa\endgroup\@esphack}
4383 % \end{macrocode}
4384 % \end{imacro}
4385 %
4386 %
4387 % \begin{macro}{\saved@macroname}
4388 % \changes{BHK}{1989/04/26}{Provided for sorting outside \env{macro}
4389 % environment} The entries are sorted for convenience by the name
4390 % of the most recently introduced macroname (i.e., that in the most
4391 % recent |\begin{macro}| command). We therefore provide
4392 % |\saved@macroname| to record that argument, and provide a default
4393 % definition in case |\changes| is used outside a \env{macro}
4394 % environment. (This is a {\em wicked\/} hack to get such entries
4395 % at the beginning of the sorted list! It works providing no macro
4396 % names start with |!| or |"|.) \changes{v1.7a}{1992/03/02}{Changed
4397 % string used for better sorting.}
4398 % \changes{v1.9u}{1995/08/06}{Now empty by default}
4399 % \begin{macrocode}
4400 \def\saved@macroname{}
4401 % \end{macrocode}
4402 % \end{macro}
4403 %
4404 % \begin{macro}{\saved@indexname}
4405 % \changes{v2.1g}{2016/02/15}{Use \cs{saved@indexname}}
4406 % The macroname being document without a backslash for the index
4407 % (or the environment name which doesn't have one in the first place).
4408 % \begin{macrocode}
4409 \def\saved@indexname{}
4410 % \end{macrocode}
4411 % \end{macro}
4412 %
4413 % \begin{imacro}{\generalname}
4414 % \changes{v1.9u}{1995/08/06}{Macro added}
4415 % This macro holds the string placed before changes entries on
4416 % top-level.
4417 % \begin{macrocode}
4418 \def\generalname{General}
4419 % \end{macrocode}
4420 % \end{imacro}
4421 %
4422 %
4423 % \begin{imacro}{\RecordChanges}
4424 % \changes{BHK}{1989/04/26}{Renames former \texttt{\protect\bslash
4425 % PrintChanges} command.}
4426 % To cause the changes to be written (to a \texttt{.glo}) file, we
4427 % define |\RecordChanges| to invoke \LaTeX's usual
4428 % |\makeglossary| command.
4429 % \begin{macrocode}
4430 \let\RecordChanges\makeglossary
4431 % \end{macrocode}
4432 % \end{imacro}
4433 %
4434 %
4435 % \begin{ldimen}{\GlossaryMin}
4436 % \changes{BHK}{1989/04/26}{Added to support
4437 % \texttt{\protect\bslash changes}.}
4438 % \begin{lcounter}{GlossaryColumns}
4439 % \changes{BHK}{1989/04/26}{Added to support \texttt{\protect\bslash
4440 % changes}.} The remaining macros are all analogues of those used
4441 % for the \env{theindex} environment. When the glossary is
4442 % started we compute the space which remains at the bottom of the
4443 % current page; if this is greater than |\GlossaryMin| then the
4444 % first part of the glossary will be placed in the available space.
4445 % The number of columns set are controlled by the counter
4446 % |\c@GlossaryColumns| which can be changed with a |\setcounter|
4447 % declaration.
4448 % \begin{macrocode}
4449 \newdimen\GlossaryMin \GlossaryMin = 80pt
4450 \newcount\c@GlossaryColumns \c@GlossaryColumns = 2
4451 % \end{macrocode}
4452 % \end{lcounter}
4453 % \end{ldimen}
4454 %
4455 %
4456 % \begin{environment}{theglossary}
4457 % \changes{BHK}{1989/04/26}{Added to support
4458 % \texttt{\protect\bslash changes}.}
4459 % \changes{v1.5p}{1989/09/28}{Now call \cs{multicols} first.}
4460 % \changes{v1.6e}{1991/04/03}{Turned into env definition.}
4461 % \changes{v1.7a}{1992/03/10}{Changed to work without multicols if
4462 % necessary.}
4463 % \changes{BHK}{1989/04/26}{Added to support
4464 % \texttt{\protect\bslash changes}.}
4465 % The environment \env{theglossary} is defined in the same manner
4466 % as the \env{theindex} environment.
4467 % \begin{macrocode}
4468 \ifdoc@multicol
4469 \newenvironment{theglossary}{%
4470 \begin{multicols}\c@GlossaryColumns
4471 [\glossary@prologue][\GlossaryMin]%
4472 \GlossaryParms \let\item\@idxitem \ignorespaces}%
4473 {\end{multicols}}
4474 \else
4475 \newenvironment{theglossary}{%
4476 \@restonecoltrue\if@twocolumn\@restonecolfalse\fi
4477 \columnseprule \z@ \columnsep 35\p@
4478 \twocolumn[\glossary@prologue]%
4479 \GlossaryParms \let\item\@idxitem \ignorespaces}
4480 {\if@restonecol\onecolumn\else\clearpage\fi}
4481 \fi
4482 % \end{macrocode}
4483 % \end{environment}
4484 %
4485 % Here are the necessary \prg{makeindex} declarations with scanning
4486 % disabled as for the index.
4487 % \begin{macrocode}
4488 %</package>
4489 %<+gglo>preamble
4490 %<+gglo>"\n \\begin{theglossary} \n
4491 %<+gglo> \\makeatletter\\scan@allowedfalse\n"
4492 %<+gglo>postamble
4493 %<+gglo>"\n\n \\end{theglossary}\n"
4494 % \end{macrocode}
4495 % This difference from \texttt{gind.ist} is necessary if you have an
4496 % up-to-date \LaTeX.
4497 % \begin{macrocode}
4498 %<+gglo>keyword "\\glossaryentry"
4499 %<*package>
4500 % \end{macrocode}
4501 %
4502 %
4503 % \begin{imacro}{\GlossaryPrologue}
4504 % \changes{BHK}{1989/04/26}{Added to support
4505 % \texttt{\protect\bslash changes}.}
4506 % \begin{macro}{\glossary@prologue}
4507 % \changes{BHK}{1989/04/26}{Added to support
4508 % \texttt{\protect\bslash changes}.}
4509 % The |\GlossaryPrologue| macro is used to place a short
4510 % message above the glossary into the document. It is implemented
4511 % by redefining |\glossary@prologue|, a macro which holds the
4512 % default text. We better make it a long macro to allow
4513 % |\par| commands in its argument.
4514 % \begin{macrocode}
4515 \long\def\GlossaryPrologue#1{\@bsphack
4516 \def\glossary@prologue{#1}%
4517 \@esphack}
4518 % \end{macrocode}
4519 % Now we test whether the default is already defined by another
4520 % package file. If not we define it.
4521 % \begin{macrocode}
4522 \@ifundefined{glossary@prologue}
4523 {\def\glossary@prologue{\section*{{Change History}}%
4524 \markboth{{Change History}}{{Change History}}%
4525 }}{}
4526 % \end{macrocode}
4527 % \end{macro}
4528 % \end{imacro}
4529 %
4530 % \begin{imacro}{\GlossaryParms}
4531 % \changes{BHK}{1989/04/26}{Added to support
4532 % \texttt{\protect\bslash changes}.}
4533 % Unless the user specifies otherwise, we set the change history
4534 % using the same parameters as for the index except that we make it sort
4535 % of ragged right as it contains text that often doesn't break nicely in
4536 % small columns.
4537 % \changes{v2.1g}{2016/02/15}{Use ragged setting by default}
4538 % \begin{macrocode}
4539 \@ifundefined{GlossaryParms}{\let\GlossaryParms\IndexParms
4540 \expandafter\def\expandafter\GlossaryParms\expandafter{\GlossaryParms
4541 \rightskip 15pt plus 1fil
4542 \parfillskip -15pt plus -1fil\relax}
4543 }{}
4544 % \end{macrocode}
4545 % \end{imacro}
4546 %
4547 % \begin{imacro}{\PrintChanges}
4548 % \changes{BHK}{1989/04/26}{Added to support
4549 % \texttt{\protect\bslash changes}.}
4550 % To read in and print the sorted change history, just put the
4551 % |\PrintChanges| command as the last (commented-out, and thus
4552 % executed during the documentation pass through the file) command
4553 % in your package file. Alternatively, this command may form one of
4554 % the arguments of the |\MaybeStop| command, although a
4555 % change history is probably {\em not\/} required if only the
4556 % description is being printed.
4557 %
4558 % The command assumes that \prg{makeindex} or some other program
4559 % has processed the \texttt{.glo} file to generate a sorted
4560 % \texttt{.gls} file.
4561 % \changes{v1.9h}{1994/02/10}{Use \cs{@input@} instead of \cs{@input}.}
4562 % \changes{v1.9w}{1995/12/29}{Turn the cmd into a noop after use.}
4563 % \begin{macrocode}
4564 \def\PrintChanges{\@input@{\jobname.gls}%
4565 \global\let\PrintChanges\@empty}
4566 % \end{macrocode}
4567 % \end{imacro}
4568 %
4569 %
4570 %
4571 %
4572 %
4573 % \subsection{Bells and whistles}
4574 %
4575 % \begin{imacro}{\MaybeStop}
4576 % \changes{v1.5k}{1989/09/04}{Support for checksum.}
4577 % \begin{imacro}{\Finale}
4578 % \changes{v1.5k}{1989/09/04}{Support for checksum.}
4579 % \changes{v1.5z}{1990/04/22}{Define \cs{Finale} globally.}
4580 % \begin{imacro}{\AlsoImplementation}
4581 % \changes{v1.9w}{1995/12/27}{Macro added}
4582 % \begin{imacro}{\OnlyDescription}
4583 % If |\AlsoImplementation| is in force the whole documentation
4584 % including the code part will be typeset. This is the default.
4585 % \begin{macrocode}
4586 \newcommand\AlsoImplementation{%
4587 % \end{macrocode}
4588 % To make this happen we have to define
4589 % |\MaybeStop| in a way that its argument is typeset at the
4590 % very end or more exactly at |\Finale|. For this we
4591 % save its argument in the macro |\Finale|.
4592 % \begin{macrocode}
4593 \long\def\MaybeStop##1{\@bsphack\gdef\Finale{##1%
4594 % \end{macrocode}
4595 % But |\Finale| will be called at the very end of a file. This
4596 % is exactly the point were we want to know if the file is
4597 % uncorrupted. Therefore we also call |\check@checksum| at this
4598 % point.
4599 % \begin{macrocode}
4600 \check@checksum}%
4601 % \end{macrocode}
4602 % On the other hand: |\MaybeStop| is more or less a
4603 % dividing point between description and code. So we start to look
4604 % for the check-sum of the documented file by calling
4605 % |\init@checksum|.
4606 % \begin{macrocode}
4607 \init@checksum
4608 \@esphack}%
4609 }
4610 % \end{macrocode}
4611 %
4612 % Since |\AlsoImplementation| should be the default we execute it
4613 % and thus |\MaybeStop| gets the desired meaning.
4614 % \begin{macrocode}
4615 \AlsoImplementation
4616 % \end{macrocode}
4617 % When the user places an |\OnlyDescription| declaration in
4618 % the driver file the document should only be typeset up to
4619 % |\MaybeStop|. We therefore have to redefine this macro.
4620 % \begin{macrocode}
4621 \def\OnlyDescription{\@bsphack\long\def\MaybeStop##1{%
4622 % \end{macrocode}
4623 % In this case the argument of |\MaybeStop| should be set
4624 % and afterwards \TeX{} should stop reading from this file.
4625 % Therefore we finish this macro with
4626 % \begin{macrocode}
4627 ##1\endinput}\@esphack}
4628 % \end{macrocode}
4629 % If no |\MaybeStop| command is given we silently ignore a
4630 % |\Finale| issued.
4631 % \changes{v1.9n}{1994/04/28}{Ignore \cs{Finale} if no
4632 % \cs{MaybeStop} is given}
4633 % \begin{macrocode}
4634 \let\Finale\relax
4635 % \end{macrocode}
4636 % \end{imacro}
4637 % \end{imacro}
4638 % \end{imacro}
4639 % \end{imacro}
4640 %
4641 %
4642 % \begin{omacro}{\StopEventually}
4643 % The old wrong name for |\MaybeStop|. We need to use |\def|
4644 % (i.e., expansion) as |\MaybeStop| gets redefined once in a while.
4645 % \begin{macrocode}
4646 \def\StopEventually{\MaybeStop}
4647 % \end{macrocode}
4648 % \end{omacro}
4649 %
4650 % \begin{imacro}{\meta}
4651 % \changes{v1.4t}{1989/04/24}{Macro added.}
4652 % \changes{v1.5w}{1990/02/03}{Breaks at space allowed.}
4653 % \changes{v1.6a}{1990/05/24}{Extra space bug corrected.}
4654 % The |\meta| macro is a bit tricky. We want to allow line
4655 % breaks at blanks in the argument but we don't want a break
4656 % in between. In the past this was done by defining |\meta| in a way that a
4657 % \verb*+ + is active when the argument is scanned. Words are then
4658 % scanned into |\hbox|es. The active \verb*+ + will end the
4659 % preceding |\hbox| add an ordinary space and open a new
4660 % |\hbox|. In this way breaks are only possible at spaces. The
4661 % disadvantage of this method was that |\meta| was neither robust
4662 % nor could it be |\protect|ed. The new implementation fixes this
4663 % problem by defining |\meta| in a radically different way: we
4664 % prevent hyphenation by defining a |\language| which has no
4665 % patterns associated with it and use this to typeset the words
4666 % within the angle brackets.
4667 % \changes{v2.0i}{2000/05/21}{New implementation (pr/3170)}
4668 % \begin{macrocode}
4669 \ifx\l@nohyphenation\undefined
4670 \newlanguage\l@nohyphenation
4671 \fi
4672 % \end{macrocode}
4673 %
4674 % \begin{macrocode}
4675 \DeclareRobustCommand\meta[1]{%
4676 % \end{macrocode}
4677 % Since the old implementation of |\meta| could be used in math we
4678 % better ensure that this is possible with the new one as
4679 % well. So we use |\ensuremath| around |\langle| and
4680 % |\rangle|. However this is not enough: if |\meta@font@select|
4681 % below expands to |\itshape| it will fail if used in math
4682 % mode. For this reason we hide the whole thing inside an
4683 % |\nfss@text| box in that case.
4684 % \changes{v2.0l}{2000/06/10}{Fixing changes for (pr/3170)}
4685 % \begin{macrocode}
4686 \ensuremath\langle
4687 \ifmmode \expandafter \nfss@text \fi
4688 {%
4689 \meta@font@select
4690 % \end{macrocode}
4691 % Need to keep track of what we changed just in case the user
4692 % changes font inside the argument so we store the font explicitly.
4693 % \changes{v2.0m}{2000/07/04}{More fixing changes for (pr/3170)}
4694 % \begin{macrocode}
4695 \edef\meta@hyphen@restore
4696 {\hyphenchar\the\font\the\hyphenchar\font}%
4697 \hyphenchar\font\m@ne
4698 \language\l@nohyphenation
4699 #1\/%
4700 \meta@hyphen@restore
4701 }\ensuremath\rangle
4702 }
4703 % \end{macrocode}
4704 % \end{imacro}
4705 %
4706 %
4707 % \begin{macro}{\meta@font@select}
4708 % \changes{v2.0k}{2000/05/26}{Macro added (pr/3170)}
4709 % Make font used inside |\meta| customizable.
4710 % \begin{macrocode}
4711 \def\meta@font@select{\itshape}
4712 % \end{macrocode}
4713 % \end{macro}
4714 %
4715 %
4716 % \begin{imacro}{\IndexInput}
4717 % This next macro may be used to read in a separate file (possibly
4718 % a package file that is {\em not\/} documented by this means) and
4719 % set it verbatim, whilst scanning for macro names and indexing the
4720 % latter. This could be a useful first pass in preparing to
4721 % generate documentation for the file read.
4722 % \begin{macrocode}
4723 \def\IndexInput#1{%
4724 % \end{macrocode}
4725 % We commence by setting up a group, and initializing a
4726 % |\trivlist| as is normally done by a
4727 % |\begin{macrocode}| command.
4728 % \begin{macrocode}
4729 \begingroup \macro@code
4730 % \end{macrocode}
4731 % We also make spacing behave as in the \env{macrocode}
4732 % environment, because otherwise all the spaces will be shown
4733 % explicitly.
4734 % \begin{macrocode}
4735 \frenchspacing \@vobeyspaces
4736 % \end{macrocode}
4737 % Then it only remains to read in the specified file, and finish
4738 % off the |\trivlist|.
4739 % \changes{v1.5t}{1989/11/07}{Call \cs{endmacrocode} instead
4740 % of \cs{endtrivlist}.}
4741 % \begin{macrocode}
4742 \input{#1}\endmacrocode
4743 % \end{macrocode}
4744 % Of course, we need to finish off the group as well.
4745 % \begin{macrocode}
4746 \endgroup}
4747 % \end{macrocode}
4748 % \end{imacro}
4749 %
4750 %
4751 % \begin{imacro}{\maketitle}
4752 % The macro to generate titles is easily altered in order that it
4753 % can be used more than once (an article with many titles). In the
4754 % original, diverse macros were concealed after use with
4755 % |\relax|. We must cancel anything that may have been put
4756 % into |\@thanks|, etc., otherwise {\em all\/} titles will
4757 % carry forward any earlier such setting!
4758 % \changes{v1.5j}{1989/06/09}{thispagestyle plain removed}
4759 % \changes{v1.9r}{1994/06/09}{Added new definitions of
4760 % \cs{@makefnmark} and \cs{@makefntext}}
4761 % \begin{macrocode}
4762 \def\maketitle{\par
4763 \begingroup \def \thefootnote {\fnsymbol {footnote}}%
4764 \setcounter {footnote}\z@
4765 \def\@makefnmark{\hbox to\z@{$\m@th^{\@thefnmark}$\hss}}%
4766 \long\def\@makefntext##1{\parindent 1em\noindent
4767 \hbox to1.8em{\hss$\m@th^{\@thefnmark}$}##1}%
4768 \if@twocolumn \twocolumn [\@maketitle ]%
4769 \else \newpage \global \@topnum \z@ \@maketitle \fi
4770 % \end{macrocode}
4771 % \changes{v1.5k}{1989/09/04}{Added \cs{ps@titlepage}}
4772 % For special formatting requirements (such as in TUGboat), we use
4773 % pagestyle |titlepage| for this; this is later defined to be
4774 % |plain|, unless already defined, as, for example, by
4775 % |ltugboat.sty|.
4776 % \begin{macrocode}
4777 \thispagestyle{titlepage}\@thanks \endgroup
4778 % \end{macrocode}
4779 % If the driver file documents many files, we don't want parts of a
4780 % title of one to propagate to the next, so we have to cancel
4781 % these:
4782 % \begin{macrocode}
4783 \setcounter {footnote}\z@
4784 \gdef\@date{\today}\gdef\@thanks{}%
4785 \gdef\@author{}\gdef\@title{}}
4786 % \end{macrocode}
4787 % \end{imacro}
4788 %
4789 %
4790 % \begin{imacro}{\ps@titlepage}
4791 % \changes{v1.5k}{1989/09/04}{Added \texttt{\protect\bslash
4792 % ps@titlepage}} When a number of articles are concatenated into a
4793 % journal, for example, it is not usual for the title pages of such
4794 % documents to be formatted differently. Therefore, a class
4795 % such as \cls{ltugboat} can define this macro in advance.
4796 % However, if no such definition exists, we use pagestyle
4797 % \texttt{plain} for title pages.
4798 % \begin{macrocode}
4799 \@ifundefined{ps@titlepage}
4800 {\let\ps@titlepage=\ps@plain}{}
4801 % \end{macrocode}
4802 % \end{imacro}
4803 %
4804 % \begin{imacro}{\MakeShortVerb}
4805 % \changes{v1.7a}{1992/02/27}{Added (from newdoc but now alters
4806 % \cs{dospecials}, \cs{@sanitize}).}
4807 % This arranges an abbreviation for |\verb| such that if you say
4808 % |\MakeShortVerb{\|\meta{c}|}| subsequently using
4809 % \meta{c}\meta{text}\meta{c} is equivalent to
4810 % |\verb|\meta{c}\meta{text}\meta{c}.\footnote{Warning:
4811 % the commentary in the rest of this section was written by Dave
4812 % Love.} In addition, the fact
4813 % that \meta{c} is made active is recorded for the benefit of the
4814 % \env{verbatim} and \env{macrocode} environments.
4815 % Note particularly that the definitions below are global.
4816 % The first thing we do (it needn't be first) is to record
4817 % the---presumably new---special character in |\dospecials| and
4818 % |\@sanitize| using |\add@special|.
4819 %
4820 % \changes{v1.9e.2}{1994/02/07}{-js: Check if \protect\meta{c} is
4821 % already an
4822 % abbreviation for \cs{verb}.}
4823 % Some unwary user might issue |\MakeShortVerb| for a second time, we
4824 % better protect against this. We assume that this happened if a
4825 % control sequence |\cc\|\meta{c} is bound, the probability that this
4826 % name is used by another module is low. We will output a warning
4827 % below, so that a possible error might be noticed by the programmer
4828 % if he reads the |LOG| file. (Should have used module internal names,
4829 % 'though.)
4830 %
4831 % \begin{imacro}{\MakeShortVerb*}
4832 % \changes{v2.1a}{2003/12/09}{(HjG) Added \texttt{*} form}
4833 % This arranges an abbreviation for |\verb*| such that if you say
4834 % |\MakeShortVerb*{\|\meta{c}|}| subsequently using
4835 % \meta{c}\meta{text}\meta{c} is equivalent to
4836 % |\verb*|\meta{c}\meta{text}\meta{c}.
4837 % \begin{macrocode}
4838 %</package>
4839 %<*package|shortvrb>
4840 \def\MakeShortVerb{%
4841 \@ifstar
4842 {\def\@shortvrbdef{\verb*}\@MakeShortVerb}%
4843 {\def\@shortvrbdef{\verb}\@MakeShortVerb}}
4844 % \end{macrocode}
4845 % \end{imacro}
4846 % \end{imacro}
4847 %
4848 % \begin{macro}{\@MakeShortVerb}
4849 % \begin{macrocode}
4850 \def\@MakeShortVerb#1{%
4851 \expandafter\ifx\csname cc\string#1\endcsname\relax
4852 % \end{macrocode}
4853 % \changes{v1.9v}{1995/11/03}{(DPC) Use \cs{@shortvrbinfo}}
4854 % \begin{macrocode}
4855 \@shortvrbinfo{Made }{#1}\@shortvrbdef
4856 \add@special{#1}%
4857 % \end{macrocode}
4858 % Then the character's current catcode is stored in |\cc\|\meta{c}.
4859 % \begin{macrocode}
4860 \expandafter
4861 \xdef\csname cc\string#1\endcsname{\the\catcode`#1}%
4862 % \end{macrocode}
4863 % The character is spliced into the definition using the same trick as
4864 % used in |\verb| (for instance), having activated |~| in a group.
4865 % \begin{macrocode}
4866 \begingroup
4867 \catcode`\~\active \lccode`\~`#1%
4868 \lowercase{%
4869 % \end{macrocode}
4870 % The character's old meaning is recorded in |\ac\|\meta{c} prior to
4871 % assigning it a new one.
4872 % \begin{macrocode}
4873 \global\expandafter\let
4874 \csname ac\string#1\endcsname~%
4875 \expandafter\gdef\expandafter~\expandafter{\@shortvrbdef~}}%
4876 \endgroup
4877 % \end{macrocode}
4878 % Finally the character is made active.
4879 % \begin{macrocode}
4880 \global\catcode`#1\active
4881 % \end{macrocode}
4882 % If we suspect that \meta{c} is already a short reference, we tell
4883 % the user. Now he or she is responsible if anything goes wrong\,\dots
4884 % \begin{macrocode}
4885 \else
4886 % \end{macrocode}
4887 % \changes{v1.9v}{1995/11/03}{(DPC) Use \cs{@shortvrbinfo}}
4888 % \begin{macrocode}
4889 \@shortvrbinfo\@empty{#1 already}%
4890 {\@empty\verb% % to fool emacs highlighting
4891 (*)}%
4892 \fi}
4893 % \end{macrocode}
4894 % \end{macro}
4895 %
4896 %
4897 % \begin{imacro}{\DeleteShortVerb}
4898 % \changes{v1.7a}{1992/02/27}{Added (from newdoc but now alters
4899 % \cs{dospecials}, \cs{@sanitize}).}
4900 % Here's the means of undoing a |\MakeShortVerb|, for instance in a
4901 % region where you need to use the character outside a verbatim
4902 % environment. It arranges for |\dospecials| and |\@sanitize| to be
4903 % altered appropriately, restores the saved catcode and, if necessary,
4904 % the character's meaning (as stored by
4905 % |\MakeShortVerb|). If the catcode wasn't stored in
4906 % |\cc\|\meta{c} (by |\MakeShortVerb|) the command is silently
4907 % ignored.
4908 % \changes{v1.7a}{1992/02/28}{Check for previous matched
4909 % \cs{MakeShortVerb}
4910 % to avoid error.}
4911 % \begin{macrocode}
4912 \def\DeleteShortVerb#1{%
4913 \expandafter\ifx\csname cc\string#1\endcsname\relax
4914 % \end{macrocode}
4915 % \changes{v2.1a}{2003/12/10}{(HjG) Notify user
4916 % if it's not a short verb character}
4917 % \begin{macrocode}
4918 \@shortvrbinfo\@empty{#1 not}%
4919 {\@empty\verb% % to fool emacs highlighting
4920 (*)}%
4921 \else
4922 % \end{macrocode}
4923 % \changes{v1.9v}{1995/11/03}{(DPC) Use \cs{@shortvrbinfo}}
4924 % \begin{macrocode}
4925 \@shortvrbinfo{Deleted }{#1 as}%
4926 {\@empty\verb% % to fool emacs
4927 % highlighting
4928 (*)}%
4929 \rem@special{#1}%
4930 \global\catcode`#1\csname cc\string#1\endcsname
4931 % \end{macrocode}
4932 % \changes{v1.9e.2}{1994/02/07}{-js: Reset `cc`\protect\meta{c} in
4933 % in \cs{DeleteShortVerb}}
4934 % We must not forget to reset |\cc\|\meta{c}, otherwise the check in
4935 % |\MakeShortVerb| for a repeated definition will not work.
4936 % \begin{macrocode}
4937 \global \expandafter\let \csname cc\string#1\endcsname \relax
4938 \ifnum\catcode`#1=\active
4939 \begingroup
4940 \catcode`\~\active \lccode`\~`#1%
4941 \lowercase{%
4942 \global\expandafter\let\expandafter~%
4943 \csname ac\string#1\endcsname}%
4944 \endgroup \fi \fi}
4945 % \end{macrocode}
4946 % \end{imacro}
4947 %
4948 % \begin{macro}{\@shortvrbinfo}
4949 % \changes{v1.9v}{1995/11/03}{(DPC) Macro added}
4950 % \changes{v2.1a}{2003/12/10}{(HjG) Third argument added
4951 % on behalf of \cmd{\MakeShortVerb*}}
4952 % Helper function for info messages.
4953 % \begin{macrocode}
4954 \def\@shortvrbinfo#1#2#3{%
4955 %<shortvrb> \PackageInfo{shortvrb}{%
4956 %<!shortvrb> \PackageInfo{doc}{%
4957 #1\expandafter\@gobble\string#2 a short reference
4958 for \expandafter\string#3}}
4959 % \end{macrocode}
4960 % \end{macro}
4961 %
4962 % \begin{macro}{\add@special}
4963 % \changes{v1.7a}{1992/02/27}{Added for short verb facility.}
4964 % This helper macro adds its argument to the
4965 % |\dospecials| macro which is conventionally used by verbatim macros
4966 % to alter the catcodes of the currently active characters. We need
4967 % to add |\do\|\meta{c} to the expansion of |\dospecials| after
4968 % removing the character if it was already there to avoid multiple
4969 % copies building up should |\MakeShortVerb| not be balanced by
4970 % |\DeleteShortVerb| (in case anything that uses |\dospecials| cares
4971 % about repetitions).
4972 % \begin{macrocode}
4973 \def\add@special#1{%
4974 \rem@special{#1}%
4975 \expandafter\gdef\expandafter\dospecials\expandafter
4976 {\dospecials \do #1}%
4977 % \end{macrocode}
4978 % Similarly we have to add |\@makeother\|\meta{c} to |\@sanitize|
4979 % (which is used in things like |\index| to re-catcode all special
4980 % characters except braces).
4981 % \begin{macrocode}
4982 \expandafter\gdef\expandafter\@sanitize\expandafter
4983 {\@sanitize \@makeother #1}}
4984 % \end{macrocode}
4985 % \end{macro}
4986 %
4987 %
4988 % \begin{macro}{\rem@special}
4989 % \changes{v1.7a}{1992/02/27}{Added for short verb facility.}
4990 % The inverse of |\add@special| is slightly trickier. |\do| is
4991 % re-defined to expand to nothing if its argument is the character of
4992 % interest, otherwise to expand simply to the argument. We can then
4993 % re-define |\dospecials| to be the expansion of itself. The space
4994 % after |=`##1| prevents an expansion to |\relax|!
4995 % \begin{macrocode}
4996 \def\rem@special#1{%
4997 \def\do##1{%
4998 \ifnum`#1=`##1 \else \noexpand\do\noexpand##1\fi}%
4999 \xdef\dospecials{\dospecials}%
5000 % \end{macrocode}
5001 % Fixing |\@sanitize| is the same except that we need to re-define
5002 % |\@makeother| which obviously needs to be done in a group.
5003 % \begin{macrocode}
5004 \begingroup
5005 \def\@makeother##1{%
5006 \ifnum`#1=`##1 \else \noexpand\@makeother\noexpand##1\fi}%
5007 \xdef\@sanitize{\@sanitize}%
5008 \endgroup}
5009 %</package|shortvrb>
5010 %<*package>
5011 % \end{macrocode}
5012 % \end{macro}
5013 %
5014 %
5015 % \subsection[Providing a checksum and character table]
5016 % {Providing a checksum and character table\footnotemark}
5017 % \footnotetext{Warning: the commentary in this section was
5018 % written by Dave Love. }
5019 %
5020 %
5021 % \begin{macro}{\init@checksum}
5022 % The checksum mechanism works by counting backslashes in the
5023 % macrocode. This initializes the count (when called from
5024 % |\MaybeStop|).
5025 % \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
5026 % \begin{macrocode}
5027 \def\init@checksum{\relax
5028 \global\bslash@cnt\z@}
5029 % \end{macrocode}
5030 % \end{macro}
5031 %
5032 %
5033 % \begin{macro}{\check@checksum}
5034 % \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
5035 % This reports the sum compared with the value (|\bslash@cnt|) the
5036 % file advertises. It's called from |\Finale| (if that hasn't been
5037 % re-defined).
5038 % \changes{v2.1f}{2016/02/12}{Suppress \cs{CheckSum} check if no checksum
5039 % is specified in the file}
5040 % \begin{macrocode}
5041 \def\check@checksum{\relax
5042 \ifnum\check@sum>\m@ne
5043 % \end{macrocode}
5044 % We do nothing if the checksum in the file is negative (or not given as
5045 % it is initialized with -1).
5046 % \begin{macrocode}
5047 \ifnum\check@sum=\z@
5048 \typeout{**********************************}%
5049 \typeout{* This macro file has no checksum!}%
5050 \typeout{* The checksum should be \the\bslash@cnt!}%
5051 \typeout{**********************************}%
5052 \else
5053 \ifnum\check@sum=\bslash@cnt
5054 \typeout{*******************}%
5055 \typeout{* Checksum passed *}%
5056 \typeout{*******************}%
5057 \else
5058 \PackageError{doc}{Checksum not passed
5059 (\the\check@sum<>\the\bslash@cnt)}%
5060 {The file currently documented seems to be wrong.^^J%
5061 Try to get a correct version.}%
5062 \fi
5063 \fi
5064 \fi
5065 \global\check@sum\m@ne}
5066 % \end{macrocode}
5067 % \end{macro}
5068 %
5069 %
5070 % \begin{tcounter}{\check@sum}
5071 % \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
5072 % \begin{tcounter}{\bslash@cnt}
5073 % \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
5074 % We need to define counters, |\bslash@cnt| for the number of
5075 % backslashes counted and |\check@sum| for the value advertised by the
5076 % file if any. A negative value means there is no checksum checking which is the default.
5077 % \changes{v2.1f}{2016/02/12}{Suppress \cs{CheckSum} check if no checksum
5078 % is specified in the file}
5079 % \begin{macrocode}
5080 \newcount\check@sum \check@sum = \m@ne
5081 \newcount\bslash@cnt \bslash@cnt = \z@
5082 % \end{macrocode}
5083 % \end{tcounter}
5084 % \end{tcounter}
5085 %
5086 %
5087 % \begin{omacro}{\CheckSum}
5088 % \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
5089 % This is the interface to setting |\check@sum|.
5090 % \begin{macrocode}
5091 \def\CheckSum#1{\@bsphack\global\check@sum#1\relax\@esphack}
5092 % \end{macrocode}
5093 % \end{omacro}
5094 %
5095 %
5096 %
5097 % \begin{macro}{\step@checksum}
5098 % \changes{v1.5k}{1989/09/04}{Macro added to support checksum.}
5099 % This advances the count when a backslash is encountered in the
5100 % macrocode.
5101 % \begin{macrocode}
5102 \def\step@checksum{\global\advance\bslash@cnt\@ne}
5103 % \end{macrocode}
5104 % \end{macro}
5105 %
5106 % \begin{omacro}{\CharacterTable}
5107 % The user interface to the character table-checking does some
5108 % |\catcode|ing and then compares the following table with the
5109 % stored version. We need to have |@| of type ``other'' within the
5110 % table since this is the way it is usually returned when reading
5111 % in a normal document. To nevertheless have a private letter we
5112 % use |~| for this purpose. |~| does no harm as a ``letter'' as it
5113 % comes last in the table and therefore will not gobble following
5114 % space.
5115 % \changes{v1.5m}{1989/09/20}{Macro added to check character translation
5116 % problems.}
5117 % \changes{v1.5q}{1989/11/01}{Made character table more readable.}
5118 % \changes{v1.5t}{1989/11/07}{Make \string\~{} letter in chartable
5119 % macros.}
5120 % \changes{v1.5u}{1989/11/14}{Made @ other in default table.}
5121 % \begin{macrocode}
5122 \def\CharacterTable{\begingroup \CharTableChanges \character@table}
5123 % \end{macrocode}
5124 % \end{omacro}
5125 %
5126 % \def\MakePrivateLetters{\catcode`\~=11\makeatletter}
5127 %
5128 % \begin{macro}{\character@table}
5129 % This does the work of comparing the tables and reporting the result.
5130 % Note that the following code is enclosed in a group
5131 % with |~| catcoded to letter.
5132 % \begin{macrocode}
5133 \begingroup
5134 \catcode`\~=11
5135 \gdef\character@table#1{\def\used~table{#1}%
5136 \ifx\used~table\default~table
5137 \typeout{***************************}%
5138 \typeout{* Character table correct *}%
5139 \typeout{***************************}%
5140 \else
5141 \PackageError{doc}{Character table corrupted}
5142 {\the\wrong@table}
5143 \show\default~table
5144 \show\used~table
5145 \fi
5146 \endgroup}
5147 % \end{macrocode}
5148 % \end{macro}
5149 %
5150 % \begin{omacro}{\CharTableChanges}
5151 % When the character table is read in we need to scan it with a
5152 % fixed set of |\catcode|s. The reference table below was defined by
5153 % assuming the normal |\catcode|s of \TeX{}, i.e.\ |@| is of type
5154 % other and the only token of type ``letter'' are the usual letters
5155 % of the alphabet. If, for some reason, other characters are made
5156 % ``letters'' then their |\catcode|s need to be restored before
5157 % checking the table. Otherwise spaces in the table are gobbled and
5158 % we get the information that the tables are different, even if
5159 % they are actually equal. For this reason |\CharTableChanges| can
5160 % be set up to locally restore the |\catcode|s of such ``letters''
5161 % to ``other''.
5162 % \begin{macrocode}
5163 \global\let\CharTableChanges\@empty
5164 % \end{macrocode}
5165 % \end{omacro}
5166 %
5167 % \begin{macro}{\default~table}
5168 % Here's what the table {\em should\/} look like (modulo spaces).
5169 % \begin{macrocode}
5170 \makeatother
5171 \gdef\default~table
5172 {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
5173 Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
5174 Digits \0\1\2\3\4\5\6\7\8\9
5175 Exclamation \! Double quote \" Hash (number) \#
5176 Dollar \$ Percent \% Ampersand \&
5177 Acute accent \' Left paren \( Right paren \)
5178 Asterisk \* Plus \+ Comma \,
5179 Minus \- Point \. Solidus \/
5180 Colon \: Semicolon \; Less than \<
5181 Equals \= Greater than \> Question mark \?
5182 Commercial at \@ Left bracket \[ Backslash \\
5183 Right bracket \] Circumflex \^ Underscore \_
5184 Grave accent \` Left brace \{ Vertical bar \|
5185 Right brace \} Tilde \~}
5186 \endgroup
5187 % \end{macrocode}
5188 % \end{macro}
5189 % \let\MakePrivateLetters=\makeatletter
5190 %
5191 % \begin{macro}{\wrong@table}
5192 % \changes{v1.7a}{1992/02/28}{Moved to where the catcodes are right
5193 % so it works.}
5194 % We need a help message in case of problems.
5195 % \begin{macrocode}
5196 \newhelp\wrong@table{Some of the ASCII characters are corrupted.^^J
5197 I now \string\show\space you both tables for comparison.}
5198 % \end{macrocode}
5199 % \end{macro}
5200 %
5201 %
5202 % \subsection[Attaching line numbers to code lines]
5203 % {Attaching line numbers to code lines\footnotemark}
5204 % \footnotetext{Warning: the commentary was written by Dave
5205 % Love.}
5206 %
5207 %
5208 % The code in this section allows index entries to refer to code line
5209 % numbers---the number of the first line of macrocode in the
5210 % \env{macro} environment.
5211 %
5212 %
5213 % \begin{macro}{\codeline@index}
5214 % Indexing by code line is controlled by the |codeline@index| switch.
5215 % \changes{v1.5s}{1989/11/05}{Support for code line no. (Undoc)}
5216 % \changes{v1.7a}{1992/02/24}{Documented code line no. support.}
5217 % \begin{imacro}{\CodelineNumbered}
5218 % \changes{v1.8a}{1993/05/19}{Macro added}
5219 % \begin{macrocode}
5220 \newif\ifcodeline@index \codeline@indexfalse
5221 \let\CodelineNumbered\codeline@indextrue
5222 % \end{macrocode}
5223 % \end{imacro}
5224 % \end{macro}
5225 %
5226 % \begin{macro}{\codeline@wrindex}
5227 % The code index entries are written out by |\special@index|. If
5228 % indexing is by code line this is |\let| to |\codeline@wrindex|;
5229 % if indexing is by page it is just |\index|. However, if
5230 % |\nofiles| is given, we omit writing such an index entry at all.
5231 % \changes{v1.7j}{1992/08/14}{Added \cs{if@filesw}.}
5232 % \begin{macrocode}
5233 \def\codeline@wrindex#1{\if@filesw
5234 \begingroup
5235 \set@display@protect
5236 \immediate\write\@indexfile
5237 {\string\indexentry{#1}%
5238 {\number\c@CodelineNo}}%
5239 \endgroup
5240 \fi}
5241 % \end{macrocode}
5242 % \end{macro}
5243 %
5244 % \begin{macro}{\special@index}
5245 % By default no index entries are written out.
5246 % \begin{macrocode}
5247 \let\special@index = \@gobble
5248 % \end{macrocode}
5249 % \end{macro}
5250 % \begin{macro}{\CodelineIndex}
5251 % \changes{v1.5u}{1989/11/14}{Added \cs{PageIndex} and
5252 % \cs{CodelineIndex} (Undoc)}
5253 % This switches on use of the index file with |\makeindex|, sets the
5254 % switch to indicate code line numbering and defines |\special@index|
5255 % appropriately.
5256 % \begin{macrocode}
5257 \def\CodelineIndex{\makeindex
5258 \codeline@indextrue
5259 \let\special@index\codeline@wrindex}
5260 % \end{macrocode}
5261 % \end{macro}
5262 % \begin{imacro}{\PageIndex}
5263 % |\PageIndex| is similar.
5264 % \begin{macrocode}
5265 \def\PageIndex{\makeindex
5266 \codeline@indexfalse
5267 \let\special@index\index}
5268 % \end{macrocode}
5269 % \end{imacro}
5270 %
5271 %
5272 % \begin{lcounter}{CodelineNo}
5273 % \changes{v1.5l}{1989/09/10}{Counter added to support code line
5274 % numbers}
5275 % \changes{v1.5y}{1990/02/24}{Default changed.}
5276 % \changes{v1.6b}{1990/06/15}{\cs{rm} moved before \cs{scriptsize} to
5277 % avoid unnecessary fontwarning.}
5278 % We need a counter to keep track of the line number.
5279 % \begin{macrocode}
5280 \newcount\c@CodelineNo \c@CodelineNo\z@
5281 % \end{macrocode}
5282 % \end{lcounter}
5283 %
5284 % \begin{macro}{\theCodelineNo}
5285 % \changes{v1.7a}{1992/02/25}{Existing definition not overwritten.}
5286 % \changes{v1.7a}{1992/03/12}{Use \cs{reset@font} for NFSS.}
5287 % This provides a hook to control the format of line numbers which may
5288 % be defined in a class file.
5289 % \begin{macrocode}
5290 \@ifundefined{theCodelineNo}
5291 {\ifx\selectfont\undefined
5292 \def\theCodelineNo{\rmfamily\scriptsize\arabic{CodelineNo}}%
5293 \else
5294 \def\theCodelineNo{\reset@font\scriptsize\arabic{CodelineNo}}%
5295 \fi}
5296 {}
5297 % \end{macrocode}
5298 % \end{macro}
5299 %
5300 %
5301 %
5302 %
5303 % \subsection{Layout Parameters for documenting package files}
5304 %
5305 % \begin{macro}{\tolerance}
5306 % People documenting package files would probably rather have things
5307 % ``sticking out'' in overfull |\hbox|es and poorish spacing,
5308 % because they probably don't want to spend a lot of time on making
5309 % all the line breaks perfect!
5310 % \begin{macrocode}
5311 \tolerance=1000\relax
5312 % \end{macrocode}
5313 % \end{macro}
5314 %
5315 %
5316 % The following |\mathcode| definitions allow the characters
5317 % `|\|'
5318 % and `\texttt{@}' to appear in |\ttfamily| font when invoked in math
5319 % mode;\footnote{You may wonder why the definitions state that both
5320 % characters belong to the {\em variable family\/}
5321 % (i.e.\ the number 7 in front). The reason is this:
5322 % Originally the \texttt{\bslash mathcode} of
5323 % \texttt{\bslash} was defined to be \texttt{"075C},
5324 % i.e.\ ordinary character number 92 (hex 5C) in
5325 % math family number 7 which is the typewriter family in
5326 % standard \LaTeX.
5327 % But this file should not depend on this specific
5328 % setting, so I changed these
5329 % \texttt{\bslash mathcode}$\,$s
5330 % to work with any family assignments. For an example
5331 % see the article about the new font selection scheme.}
5332 % particularly for something like |\@abc=1|.
5333 %
5334 % If an {\em old\/} version of the \pkg{german} package is in
5335 % force, then the `|"|' character is active and would upset the
5336 % definition of the \meta{16-bit number} quantities below, therefore
5337 % we change the |\catcode| of |"| inside a group, and use
5338 % |\global|.
5339 % \begin{macrocode}
5340 { \catcode`\"=12
5341 \global\mathcode`\\="705C \global\mathcode`\@="7040 }
5342 % \end{macrocode}
5343 % \MakeShortVerb{\"}
5344 %
5345 % \begin{macro}{\DocstyleParms}
5346 % This macro can be used, for example, to assign new values to
5347 % |\MacrocodeTopsep| and |\MacroIndent| and some other internal
5348 % registers. If it is already defined, the default definition
5349 % won't be carried out. Note that it is necessary to assign new
5350 % values via this macro if it should be done in a class file (like
5351 % \texttt{ltugboat.cls} for example) since the registers are
5352 % undefined before \texttt{doc.sty} is read in. The default values
5353 % for the internal registers are scattered over this file.
5354 % \changes{v1.5u}{1989/11/14}{\cs{DocStyleParms} now empty}
5355 % \changes{v2.1h}{2018/02/01}{Only use\cs{DocStyleParms} if defined
5356 % (previously the test defined it)}
5357 % \begin{macrocode}
5358 \@ifundefined{DocstyleParms}{}{\DocstyleParms}
5359 % \end{macrocode}
5360 % Clear out |\DocstyleParms| after use (or non-use).
5361 % \begin{macrocode}
5362 \let\DocstyleParms\relax
5363 % \end{macrocode}
5364 % \end{macro}
5365 %
5366 %
5367 %
5368 % \begin{macro}{\AmSTeX}
5369 % \changes{v1.5j}{1989/06/09}{Macro AmsTeX renamed to AmSTeX}
5370 % \begin{macro}{\BibTeX}
5371 % \begin{macro}{\SliTeX}
5372 % Here are a few definitions which can usefully be employed when
5373 % documenting package files: now we can readily refer to \AmSTeX,
5374 % \BibTeX\ and \SliTeX, as well as the usual \TeX\ and \LaTeX.
5375 % \begin{macrocode}
5376 \@ifundefined{AmSTeX}
5377 {\def\AmSTeX{\leavevmode\hbox{$\mathcal A\kern-.2em\lower.376ex%
5378 \hbox{$\mathcal M$}\kern-.2em\mathcal S$-\TeX}}}{}
5379 \@ifundefined{BibTeX}
5380 {\def\BibTeX{{\rmfamily B\kern-.05em%
5381 \textsc{i\kern-.025em b}\kern-.08em%
5382 T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}}{}
5383 \@ifundefined{SliTeX}
5384 {\def\SliTeX{{\rmfamily S\kern-.06emL\kern-.18em\raise.32ex\hbox
5385 {\scshape i}\kern -.03em\TeX}}}{}
5386 % \end{macrocode}
5387 % \end{macro}
5388 % \end{macro}
5389 % \end{macro}
5390 % \begin{macro}{\PlainTeX}
5391 % \changes{v1.5g}{1989/05/07}{space between plain and TeX changed.}
5392 % \begin{macro}{\Web}
5393 % There's even a \PlainTeX{} and a \Web.
5394 % \begin{macrocode}
5395 \@ifundefined{PlainTeX}{\def\PlainTeX{\textsc{Plain}\kern2pt\TeX}}{}
5396 \@ifundefined{Web}{\def\Web{\textsc{Web}}}{}
5397 % \end{macrocode}
5398 % \end{macro}
5399 % \end{macro}
5400 %
5401 %
5402 % \subsection{Changing the \texttt{\protect\bslash catcode} of \%}
5403 %
5404 % \begin{imacro}{\MakePercentIgnore}
5405 % \begin{imacro}{\MakePercentComment}
5406 % And finally the most important bit: we change the |\catcode|
5407 % of `|%|' so that it is ignored (which is how we are able to
5408 % produce this document!). We provide two commands to do the actual
5409 % switching.
5410 %^^A The |\MakePercentIgnore| is then called as the
5411 %^^A last command in this file.
5412 % \begin{macrocode}
5413 \def\MakePercentIgnore{\catcode`\%9\relax}
5414 \def\MakePercentComment{\catcode`\%14\relax}
5415 % \end{macrocode}
5416 % \end{imacro}
5417 % \end{imacro}
5418 %
5419 % \begin{imacro}{\DocInput}
5420 % The two macros above are now used to define the |\DocInput| macro
5421 % which was introduced in version v1.5l (or so) of the \DOC{}
5422 % package. In older versions |\MakePercentIgnore| was placed
5423 % at the very end of \texttt{doc.sty}.
5424 % \begin{macrocode}
5425 \def\DocInput#1{\MakePercentIgnore\input{#1}\MakePercentComment}
5426 % \end{macrocode}
5427 % \end{imacro}
5428 %
5429 % \subsection{GetFileInfo}
5430 %
5431 % \begin{macro}{\GetFileInfo}
5432 % \changes{v1.9o}{1994/05/08}{Macro added}
5433 % \changes{v1.9z}{1997/02/05}{Missing percent latex/2404}
5434 % Define |\filedate| and friends from info in the
5435 % |\ProvidesPackage| etc.\ commands.
5436 % \begin{macrocode}
5437 \def\GetFileInfo#1{%
5438 \def\filename{#1}%
5439 \def\@tempb##1 ##2 ##3\relax##4\relax{%
5440 \def\filedate{##1}%
5441 \def\fileversion{##2}%
5442 \def\fileinfo{##3}}%
5443 \edef\@tempa{\csname ver@#1\endcsname}%
5444 \expandafter\@tempb\@tempa\relax? ? \relax\relax}
5445 % \end{macrocode}
5446 % \end{macro}
5447 %
5448
5449
5450
5451
5452 % \section{Integrating hypdoc}
5453 %
5454 % If the option \texttt{hyperref} is selected (which is the
5455 % default), then we load the \pkg{hypdoc} package. We do that as
5456 % late as possible so that we don't generate option clashes if it
5457 % is also loaded in the preamble. That package currently changes
5458 % more commands than it should (not knowing about their new
5459 % definitions defined below) so we have to save and restore a few.
5460 %
5461 % Midterm all this code in \pkg{hypdoc} should be directly included
5462 % in \DOC. For now, while they are separate we have to do this
5463 % juggling.
5464 % \begin{macrocode}
5465 \AddToHook{begindocument/before}[doc/hyperref]{%
5466 \ifdoc@hyperref
5467 % \end{macrocode}
5468 % Annoying to code around issue \#22
5469 % \begin{macrocode}
5470 \expandafter\let\expandafter\doc@eoph@@k\csname doc.sty-h@@k\endcsname
5471 % \end{macrocode}
5472 % We require the package without any option so if it was already
5473 % loaded there is no option clash.
5474 % \changes{v3.0q}{2024/06/04}{Use hooks to save and restore
5475 % definitions when hypdoc gets loaded (gh/1000)}
5476 % \begin{macrocode}
5477 \RequirePackage{hypdoc}
5478 \expandafter\let\csname doc.sty-h@@k\endcsname\doc@eoph@@k
5479 % \end{macrocode}
5480 % The package adds new definitions for \cs{special@index} into
5481 % \cs{CodelineIndex} and \cs{PageIndex} but since we might be loading it
5482 % very late we are already past them (in the preamble). So we test
5483 % the final state and do it here, if necessary.
5484 % \begin{macrocode}
5485 \ifx\special@index\@gobble % do we write index entries at all?
5486 \else
5487 \ifcodeline@index
5488 \let\special@index\HD@codeline@wrindex
5489 \else
5490 \let\special@index\HD@page@wrindex
5491 \fi
5492 \fi
5493 % \end{macrocode}
5494 % The \pkg{amsmath} documentation uses \cs{env} in headings and
5495 % with \pkg{hyperref} enabled this causes trouble in bookmarks.
5496 % \fmi{fix elsewhere eventually}
5497 % \begin{macrocode}
5498 \AddToHook{class/amsdtx/after}{%
5499 \pdfstringdefDisableCommands{\let\env\@empty }}%
5500 % \end{macrocode}
5501 % That package also adds extra code into |\index| entries but it doesn't
5502 % know about all the stuff that \DOC does (now). So we need to provide
5503 % us with two helpers that handle the |\encapchar| case in some entries.
5504 % \begin{macrocode}
5505 \def\doc@providetarget{\HD@target}%
5506 \def\doc@handleencap#1{\encapchar hdclindex{\the\c@HD@hypercount}{#1}}%
5507 % \end{macrocode}
5508 % If that package is not loaded these helpers do little to nothing.
5509 % \begin{macrocode}
5510 \else
5511 \let\doc@providetarget\@empty
5512 \def\doc@handleencap#1{\encapchar #1}%
5513 % \end{macrocode}
5514 % We define the next commands just in case the user changed the option
5515 % \texttt{hyperref} from \texttt{true} to \texttt{false} without
5516 % removing the auxiliary files.
5517 % \begin{macrocode}
5518 \def\hdclindex#1#2{\ifx\@nil#2\@nil\else\csname #2\expandafter\endcsname\fi}%
5519 \def\hdpindex #1{\ifx\@nil#1\@nil\else\csname #1\expandafter\endcsname\fi}%
5520 \fi
5521 }
5522 % \end{macrocode}
5523 %
5524 %
5525 %
5526 %
5527 %
5528 % \section{Integrating the \DOX package code}
5529 %
5530 % The code in this section is largely taken over from the \DOX package
5531 % by Didier with only minor modifications (so far). This means it is a
5532 % bit back and forth and both the code and the documentation need
5533 % further updates.
5534 %
5535 % \subsection{\DOX environments}
5536
5537 % \begin{macro}{\@doc@env,\@doc@env@}
5538 % \fmi{original doc -- fix}
5539 % \marg{are-we-macrolike}\marg{item}\marg{indextype}\marg{name}\\
5540 % In \texttt{doc.sty}, the \texttt{macro} and \texttt{environment}
5541 % environments go through the \cs{m@cro@} macro which implements specific
5542 % parts by testing a boolean condition as its first argument. This mechanism
5543 % is not extensible, so I have to hack away a more generic version that
5544 % would work for any new \texttt{dox} item, only which looks pretty much
5545 % like the original one (with the addition of options management).
5546 %
5547 % First step is to see if we have a comma-separated list of names
5548 % in |#3| and if so we call the macro doing the work individually
5549 % for each
5550 % \begin{macrocode}
5551 \ExplSyntaxOn
5552 % \end{macrocode}
5553 %
5554 % \begin{macrocode}
5555 \long\def\@doc@env#1#2#3{
5556 % \end{macrocode}
5557 % The |\endgroup| here closes the scanning of names (using special catcodes).
5558 % \begin{macrocode}
5559 \endgroup
5560 \clist_map_inline:nn {#3} { \@doc@env@{#1}{#2}{##1} }
5561 }
5562
5563 \ExplSyntaxOff
5564 % \end{macrocode}
5565 %
5566 % And here is the payload for each name from the given list:
5567 % \begin{macrocode}
5568 \long\def\@doc@env@#1#2#3{%
5569 \topsep\MacroTopsep
5570 \trivlist
5571 \edef\saved@macroname{\string#3}%
5572 % \end{macrocode}
5573 % Since version 2.1g, \texttt{doc} creates a \cs{saved@indexname} command
5574 % which in used by \cs{changes}. We now support that as well. The expansion of
5575 % this command depends on whether the documented item is macrolike or not,
5576 % which we don't know here (it's only known by \cs{NewDocElement}). That's why we
5577 % need one specific command generating \cs{saved@indexname} the right way for
5578 % every single item. These commands are
5579 % named\cs{@Save\meta{item}IndexName};
5580 % they are technically part of the generated API, only not meant for public
5581 % use.
5582 %
5583 % \fmi{above docu is no longer right (but code probably needs further changes
5584 % anyway)}
5585 %
5586 % |#1| is either \texttt{TT} (for true = macrolike) or \texttt{TF}.
5587 % If true then we drop the first char from |\saved@macroname| and
5588 % store the result in |\saved@indexname| and use the latter for
5589 % sorting in the index.
5590 % \begin{macrocode}
5591 \if #1%
5592 \edef\saved@indexname{\expandafter\@gobble\saved@macroname}%
5593 %
5594 % \end{macrocode}
5595 % If the \DOC element described is macrolike but not a normal
5596 % ``macro'' then its type should be recorded and this is the places
5597 % where this happens. For macros (which should make up the bulk of
5598 % these items) we don't do this and for anything else that looks
5599 % from an indexing perspective like a macro we don't do that either
5600 % to keep the list of exceptions small. That would be the case if
5601 % the indexing command |\Code|\meta{doc-element}|Index| is
5602 % equivalent to \cs{CodeMacroIndex}.
5603 % \begin{macrocode}
5604 \expandafter\ifx
5605 \csname Code#2Index\endcsname
5606 \CodeMacroIndex
5607 \else
5608 \record@index@type@save
5609 {\saved@indexname}{#2}%
5610 \fi
5611 \else
5612 \let\saved@indexname\saved@macroname
5613 \fi
5614 %
5615 \def\makelabel##1{\llap{##1}}%
5616 \if@inlabel
5617 \let\@tempa\@empty
5618 \count@\macro@cnt
5619 \loop\ifnum\count@>\z@
5620 \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne
5621 \repeat
5622 \edef\makelabel##1{\llap{\vtop to\baselineskip{\@tempa\hbox{##1}\vss}}}%
5623 \advance\macro@cnt\@ne
5624 \else
5625 \macro@cnt\@ne
5626 \fi
5627 \ifdoc@noprint
5628 \item
5629 \else
5630 \edef\@tempa{%
5631 \noexpand\item[%
5632 % \end{macrocode}
5633 % The second notable modification to the original macro involves dynamically
5634 % constructing the name of the print macro:
5635 % \begin{macrocode}
5636 \noexpand\doc@providetarget
5637 \noexpand\strut
5638 \noexpand\@nameuse{Print#2Name}{\saved@macroname}]}%
5639 \@tempa
5640 \fi
5641 \ifdoc@noindex\else
5642 \global\advance\c@CodelineNo\@ne
5643 % \end{macrocode}
5644 % and the third one involves dynamically constructing the name of the index
5645 % macro:
5646 % \begin{macrocode}
5647 \csname SpecialMain#2Index\expandafter\endcsname
5648 \expandafter{\saved@macroname}\nobreak
5649 \global\advance\c@CodelineNo\m@ne
5650 \fi
5651 % \end{macrocode}
5652 % Suppress further |\index| entries when we are within a
5653 % \texttt{macrolike} environment. There is no point doing that for
5654 % non-\texttt{macrolike} environments are index entries are only
5655 % generated for items starting with a backslash anyway.
5656 % \fmi{fix}
5657 % \begin{macrocode}
5658 \if#1\expandafter\DoNotIndex \expandafter {\saved@macroname}\fi
5659 \ignorespaces}
5660 % \end{macrocode}
5661 % \end{macro}
5662 %
5663 %
5664 %
5665 %
5666 %
5667 %
5668 % \begin{macro}{\doc@env}
5669 % \marg{true-value}\marg{item}\oarg{options}\\
5670 % Handle optional arguments and call \cs{@doc@env}. Because environments can
5671 % be nested, we can't rely on grouping for getting options default values.
5672 % Hence, we need to reset the options at every call.
5673 % \fmi{Use 2e interface for \cs{keys\_set:nn} when available}
5674 % \begin{macrocode}
5675 \def\doc@env#1#2[#3]{%
5676 \@nameuse{doc@noprint\doc@noprintdefault}%
5677 \@nameuse{doc@noindex\doc@noindexdefault}%
5678 \csname keys_set:nn\endcsname{doc}{#3}%
5679 \begingroup
5680 \ifdoc@outer
5681 \catcode`\\12
5682 \fi
5683 \MakePrivateLetters
5684 \@doc@env{#1}{#2}%
5685 }
5686 % \end{macrocode}
5687 % \end{macro}
5688
5689
5690
5691 % \subsection{\DOC descriptions}
5692 %
5693 % \begin{macro}{\@doc@describe}
5694 % \marg{item}\marg{name}\\
5695 % \begin{macrocode}
5696 \def\@doc@describe#1#2{%
5697 \ifdoc@noprint\else
5698 \marginpar{\raggedleft
5699 % \end{macrocode}
5700 % The hyperref target has to be in horizontal mode (which is the
5701 % case if it is after the \cs{strut}).
5702 % \begin{macrocode}
5703 \strut
5704 \doc@providetarget
5705 \@nameuse{PrintDescribe#1}{#2}}%
5706 \fi
5707 \ifdoc@noindex\else
5708 \@nameuse{Special#1Index}{#2}%
5709 \fi
5710 \@esphack
5711 \endgroup
5712 \ignorespaces}
5713 % \end{macrocode}
5714 % \end{macro}
5715 % \begin{macro}{\doc@describe}
5716 % \marg{item}\oarg{options}\\
5717 % Handle optional arguments and call \cs{@doc@describe}.
5718 % \fmi{Use 2e interface for \cs{keys\_set:nn} when available}
5719 % \begin{macrocode}
5720 \def\doc@describe#1[#2]{%
5721 \leavevmode\@bsphack
5722 \csname keys_set:nn\endcsname{doc}{#2}%
5723 \@doc@describe{#1}}
5724 % \end{macrocode}
5725 % \end{macro}
5726 %
5727 %
5728 %
5729 %
5730 % \subsection{API construction}
5731 %
5732 %
5733 % \begin{macro}{\@temptokenb}
5734 % A scratch register (which may have been defined elsewhere)
5735 % \begin{macrocode}
5736 \@ifundefined{temptokenb}{\newtoks\@temptokenb}{}
5737 % \end{macrocode}
5738 % \end{macro}
5739 %
5740 %
5741 % \begin{macro}{\doc@createspecialmainindex}
5742 % \marg{item}\marg{idxtype}\marg{idxcat}
5743 % \begin{macro}{\doc@createspecialmainmacrolikeindex}
5744 % \marg{item}\marg{idxtype}\marg{idxcat}\\
5745 % \fmi{original doc -- fix}
5746 % The ``macrolike'' version does something similar to |doc|'s
5747 % \cs{SpecialIndex@} macro, but simplified. Let's just hope nobody will ever
5748 % define \verb*|\ | or nonletter macros as macrolike \DOC elements\ldots
5749 % \begin{macrocode}
5750 \def\doc@createspecialindexes#1#2#3{%
5751 % \end{macrocode}
5752 %
5753 % \begin{macrocode}
5754 \@temptokena{\space (#2)}%
5755 \@temptokenb{#3:}%
5756 % \end{macrocode}
5757 %
5758 % \begin{macrocode}
5759 \@nameedef{SpecialMain#1Index}##1{%
5760 \noexpand\@bsphack
5761 \ifdoc@toplevel
5762 \noexpand\special@index{##1\noexpand\actualchar
5763 {\string\ttfamily\space##1}%
5764 \ifx\@nil#2\@nil\else \the\@temptokena \fi
5765 \noexpand\encapchar main}%
5766 \fi
5767 \ifx\@nil#3\@nil\else
5768 \noexpand\special@index{\the\@temptokenb\noexpand\levelchar
5769 ##1\noexpand\actualchar{\string\ttfamily\space##1}%
5770 \noexpand\encapchar main}%
5771 \fi
5772 \noexpand\@esphack}%
5773 % \end{macrocode}
5774 %
5775 % \begin{macrocode}
5776 \@nameedef{Special#1Index}##1{%
5777 \noexpand\@bsphack
5778 \ifdoc@toplevel
5779 \noexpand\doc@providetarget
5780 \noexpand\index{##1\noexpand\actualchar{\string\ttfamily\space##1}%
5781 \ifx\@nil#2\@nil\else \the\@temptokena \fi
5782 \noexpand\doc@handleencap{usage}}%
5783 \fi
5784 \ifx\@nil#3\@nil\else
5785 \noexpand\index{\the\@temptokenb\noexpand\levelchar
5786 ##1\noexpand\actualchar{\string\ttfamily\space##1}%
5787 \noexpand\doc@handleencap{usage}}%
5788 \fi
5789 \noexpand\@esphack}}
5790 % \end{macrocode}
5791 %
5792 % \begin{macrocode}
5793 \def\doc@createspecialmacrolikeindexes#1#2#3{%
5794 % \end{macrocode}
5795 %
5796 % \begin{macrocode}
5797 \@temptokena{\space (#2)}%
5798 \@temptokenb{#3:}%
5799 % \end{macrocode}
5800 %
5801 % \begin{macrocode}
5802 \@nameedef{Code#1Index}##1##2{%
5803 \noexpand\@SpecialIndexHelper@##2\noexpand\@nil
5804 \noexpand\@bsphack
5805 \noexpand\ifdoc@noindex\noexpand\else
5806 \ifdoc@toplevel
5807 \noexpand\special@index{\noexpand\@gtempa\noexpand\actualchar
5808 \string\verb% % to fool emacs highlighting
5809 \noexpand\quotechar*\noexpand\verbatimchar
5810 \noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
5811 \ifx\@nil#2\@nil\else \the\@temptokena \fi
5812 \noexpand\encapchar ##1}%
5813 \fi
5814 \ifx\@nil#3\@nil\else
5815 \noexpand\special@index{\the\@temptokenb\noexpand\levelchar
5816 \noexpand\@gtempa\noexpand\actualchar
5817 \string\verb% % to fool emacs highlighting
5818 \noexpand\quotechar*\noexpand\verbatimchar
5819 \noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
5820 \noexpand\encapchar ##1}%
5821 \fi
5822 \noexpand\fi
5823 \noexpand\@esphack}%
5824 % \end{macrocode}
5825 %
5826 % \begin{macrocode}
5827 \@nameedef{SpecialMain#1Index}##1{%
5828 \expandafter\noexpand\csname Code#1Index\endcsname
5829 {main}{##1}}%
5830 % \end{macrocode}
5831 %
5832 % \begin{macrocode}
5833 \@nameedef{Special#1Index}##1{%
5834 \noexpand\@SpecialIndexHelper@##1\noexpand\@nil
5835 \noexpand\@bsphack
5836 \noexpand\ifdoc@noindex\noexpand\else
5837 \ifdoc@toplevel
5838 \noexpand\doc@providetarget
5839 \noexpand\index{\noexpand\@gtempa\noexpand\actualchar
5840 \string\verb% % to fool emacs highlighting
5841 \noexpand\quotechar*\noexpand\verbatimchar
5842 \noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
5843 \ifx\@nil#2\@nil\else \the\@temptokena \fi
5844 \noexpand\doc@handleencap{usage}}%
5845 \fi
5846 \ifx\@nil#3\@nil\else
5847 \noexpand\index{\the\@temptokenb\noexpand\levelchar
5848 \noexpand\@gtempa\noexpand\actualchar
5849 \string\verb% % to fool emacs highlighting
5850 \noexpand\quotechar*\noexpand\verbatimchar
5851 \noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
5852 \noexpand\doc@handleencap{usage}}%
5853 \fi
5854 \noexpand\fi
5855 \noexpand\@esphack}}
5856 % \end{macrocode}
5857 % \end{macro}
5858 % \end{macro}
5859
5860
5861
5862 % \begin{macro}{\doc@createdescribe}
5863 % \marg{item}
5864 % \begin{macrocode}
5865 \def\doc@createdescribe#1{%
5866 \@namedef{Describe#1}{%
5867 % \end{macrocode}
5868 % Because of the optional argument we have to set
5869 % |\MakePrivateLetters| already before parsing that (fingers
5870 % crossed). Otherwise incorrect but quite common usage, such as
5871 % |\DescribeMacro\foo@bar| will break because the scan for the
5872 % optional argument will tokenize the following input (i.e., |\foo|
5873 % in that case) before the |@| sign becomes a letter. As a result
5874 % |DescribeMacro| would receive only |\foo| as its argument.
5875 % \begin{macrocode}
5876 \begingroup
5877 \MakePrivateLetters
5878 \@ifnextchar[%]
5879 {\doc@describe{#1}}{\doc@describe{#1}[]}}}
5880 % \end{macrocode}
5881 % \end{macro}
5882 %
5883 %
5884 % \begin{macro}{\doc@createenv}
5885 % \marg{item}\marg{envname}
5886 % \begin{macrocode}
5887 \def\doc@createenv#1#2#3{%
5888 \@namedef{#3}{%
5889 \@ifnextchar[%]
5890 {\doc@env{#1}{#2}}{\doc@env{#1}{#2}[]}}%
5891 % \end{macrocode}
5892 % Instead of |\let|ting the end of the environment to
5893 % |\endtrivlist| we use one level of expansion. This way any
5894 % possible change in that environment (if that ever happens) is
5895 % properly reflected.
5896 % \begin{macrocode}
5897 \@namedef{end#3}{\endtrivlist}%
5898 % \expandafter\let\csname end#3\endcsname\endtrivlist
5899 }
5900 % \end{macrocode}
5901 % \end{macro}
5902
5903
5904 %
5905 % \begin{macro}{\@nameedef}
5906 %
5907 % \begin{macrocode}
5908 \def\@nameedef#1{\expandafter\edef\csname #1\endcsname}
5909 % \end{macrocode}
5910 % \end{macro}
5911
5912 %
5913 % \subsection{API creation}
5914 %
5915 % The whole user interface is created in one macro call.
5916 %
5917 %\begin{verbatim}
5918 % defaults:
5919 %
5920 % idxtype = #3
5921 % idxgroup = #3s
5922 % printtype =
5923 %\end{verbatim}
5924
5925
5926
5927 % \begin{macro}{\doc@declareerror}
5928 %
5929 % \begin{macrocode}
5930 \def\doc@declareerror#1#2{%
5931 \PackageError{doc}{Doc element '#1/#2' already defined?\@gobble}%
5932 {There is already a definition for
5933 '\string\Print#1Name',\MessageBreak
5934 '\string\PrintDescribe#1'
5935 or the environment '#2'.\MessageBreak
5936 Maybe you are overwriting something by mistake!\MessageBreak
5937 Otherwise use '\string\RenewDocElement' instead.}%
5938 }
5939 % \end{macrocode}
5940 % \end{macro}
5941
5942 % \begin{macro}{\doc@notdeclarederror}
5943 %
5944 % \begin{macrocode}
5945 \def\doc@notdeclarederror#1#2{%
5946 \PackageError{doc}{Doc element '#1/#2' unknown}%
5947 {I expected an existing definition for
5948 '\string\Print#1Name',\MessageBreak
5949 '\string\PrintDescribe#1' and
5950 the environment '#2' but\MessageBreak
5951 not all of them are defined.\MessageBreak
5952 Maybe you wanted to use
5953 '\string\NewDocElement'?}%
5954 }
5955 % \end{macrocode}
5956 % \end{macro}
5957 %
5958 % \begin{macro}{\doc@ignoredinfo}
5959 %
5960 % \begin{macrocode}
5961 \def\doc@ignoredinfo#1#2{%
5962 \PackageInfo{doc}{Doc element '#1/#2' declaration
5963 ignored}%
5964 }
5965 % \end{macrocode}
5966 % \end{macro}
5967 %
5968 %
5969 % \begin{imacro}{\NewDocElement}
5970 % \oarg{options}\marg{name}\marg{envname}
5971 %
5972 % \begin{macrocode}
5973 \newcommand\NewDocElement[3][]{%
5974 % \end{macrocode}
5975 %
5976 % \begin{macrocode}
5977 \@ifundefined{Print#2Name}%
5978 {\@ifundefined{PrintDescribe#2}%
5979 {\@ifundefined{#3}%
5980 {\@ifundefined{end#3}%
5981 {\@NewDocElement{#1}}%
5982 \doc@declareerror
5983 }\doc@declareerror
5984 }\doc@declareerror
5985 }\doc@declareerror
5986 {#2}{#3}%
5987 }
5988 % \end{macrocode}
5989 % \end{imacro}
5990 %
5991 % \begin{imacro}{\ProvideDocElement}
5992 % \oarg{options}\marg{name}\marg{envname}
5993 % This does nothing unless the doc element could be declared with
5994 % \cs{NewDocElement}.
5995 % \begin{macrocode}
5996 \newcommand\ProvideDocElement[3][]{%
5997 % \end{macrocode}
5998 %
5999 % \begin{macrocode}
6000 \@ifundefined{Print#2Name}%
6001 {\@ifundefined{PrintDescribe#2}%
6002 {\@ifundefined{#3}%
6003 {\@ifundefined{end#3}%
6004 {\@NewDocElement{#1}}%
6005 \doc@ignoredinfo
6006 }\doc@ignoredinfo
6007 }\doc@ignoredinfo
6008 }\doc@ignoredinfo
6009 {#2}{#3}%
6010 }
6011 % \end{macrocode}
6012 % \end{imacro}
6013 %
6014 %
6015 % \begin{imacro}{\RenewDocElement}
6016 % \oarg{options}\marg{name}\marg{envname}
6017 %
6018 % \begin{macrocode}
6019 \newcommand\RenewDocElement[3][]{%
6020 % \end{macrocode}
6021 %
6022 % \begin{macrocode}
6023 \@ifundefined{Print#2Name}\doc@notdeclarederror
6024 {\@ifundefined{PrintDescribe#2}\doc@notdeclarederror
6025 {\@ifundefined{#3}\doc@notdeclarederror
6026 {\@ifundefined{end#3}\doc@notdeclarederror
6027 {\@NewDocElement{#1}}%
6028 }%
6029 }%
6030 }%
6031 {#2}{#3}%
6032 }
6033 % \end{macrocode}
6034 % \end{imacro}
6035 %
6036 %
6037 % \begin{macro}{\@NewDocElement}
6038 % \marg{options}\marg{name}\marg{envname}
6039 %
6040 % \begin{macrocode}
6041 \def\@NewDocElement#1#2#3{%
6042 % \end{macrocode}
6043 %
6044 % \begin{macrocode}
6045 \doc@macrolikefalse
6046 \doc@topleveltrue
6047 % \end{macrocode}
6048 %
6049 % \fmi{Use 2e interface for \cs{keys\_set:nn} when available}
6050 % \begin{macrocode}
6051 \def\doc@idxtype{#3}%
6052 \def\doc@idxgroup{#3s}%
6053 \let\doc@printtype\@empty
6054 \csname keys_set:nn\endcsname{doc}{#1}%
6055 % \end{macrocode}
6056 % \begin{imacro}{\Print...Name}
6057 % \marg{name}
6058 % \fmi{extremely messy this with so many \cs{expandafter}s \ldots{}
6059 % should reimplement in expl3}
6060 % \begin{macrocode}
6061 \ifx\doc@printtype\@empty
6062 \@temptokena{}%
6063 \else
6064 \@temptokena\expandafter{\expandafter
6065 \textnormal\expandafter{\expandafter
6066 \space\expandafter
6067 (\doc@printtype)}}%
6068 \fi
6069 \@nameedef{Print#2Name}##1{%
6070 {\noexpand\MacroFont
6071 \ifdoc@macrolike
6072 \noexpand\string
6073 \fi
6074 ##1%
6075 \the\@temptokena
6076 }}%
6077 % \end{macrocode}
6078 % \end{imacro}
6079 %
6080 % \begin{imacro}{\PrintDescribe...}
6081 % \marg{name}
6082 % \begin{macrocode}
6083 \expandafter\let\csname PrintDescribe#2\expandafter\endcsname
6084 \csname Print#2Name\endcsname
6085 % \end{macrocode}
6086 % \end{imacro}
6087 %
6088 % \begin{imacro}{\SpecialMain...Index}
6089 % \marg{name}
6090 % \begin{imacro}{\Special...Index}
6091 % \marg{name}
6092 % \begin{macrocode}
6093 \edef\doc@expr{%
6094 \ifdoc@macrolike
6095 \noexpand\doc@createspecialmacrolikeindexes
6096 \else
6097 \noexpand\doc@createspecialindexes
6098 \fi
6099 {#2}%
6100 }%
6101 \expandafter\expandafter\expandafter
6102 \doc@expr
6103 \expandafter\expandafter\expandafter
6104 {\expandafter\doc@idxtype\expandafter}\expandafter
6105 {\doc@idxgroup}%
6106 % \end{macrocode}
6107 % \end{imacro}
6108 % \end{imacro}
6109 %
6110 % \begin{imacro}{\Describe...}
6111 % \oarg{options}\marg{name}
6112 % \begin{macrocode}
6113 \doc@createdescribe{#2}%
6114 % \end{macrocode}
6115 % \end{imacro}
6116 %
6117 % \begin{environment}{\meta{DocElement}}
6118 % \fmi{can't have formatting in argument -- fix}
6119 % \oarg{options}\marg{name}
6120 % \begin{macrocode}
6121 \ifdoc@macrolike
6122 \doc@createenv{TT}{#2}{#3}%
6123 \else
6124 \doc@createenv{TF}{#2}{#3}%
6125 \fi
6126 }
6127 % \end{macrocode}
6128 % \end{environment}
6129 % \end{macro}
6130
6131
6132
6133
6134
6135 % \subsection{Setting up the default \DOC elements}
6136
6137 % \subsubsection{Macro facilities}
6138 %
6139 % Macros get only a single index entry (no index group, no index
6140 % type) and they do not get any label either when printing in the margin.
6141 % \begin{macrocode}
6142 \NewDocElement[macrolike = true ,
6143 idxtype = ,
6144 idxgroup = ,
6145 printtype =
6146 ]{Macro}{macro}
6147 % \end{macrocode}
6148
6149
6150 % \begin{macro}{\SpecialMainIndex}
6151 %
6152 % In \DOC v2 we had \cs{SpecialMainIndex} and
6153 % \cs{SpecialMainEnvIndex} but now with additional \DOC elements we
6154 % always add the element name after ``\texttt{Main}'' so this would
6155 % be \cs{SpecialMainMacroIndex}. We use |\def| not |\let| so any
6156 % redefinition of |\SpecialMainMacroIndex| will be transparent.
6157 % \begin{macrocode}
6158 \def\SpecialMainIndex{\SpecialMainMacroIndex}
6159 % \end{macrocode}
6160 % \end{macro}
6161
6162 % \begin{macro}{\SpecialUsageIndex}
6163 % \DOC v2 also had \cs{SpecialUsageIndex} which is now called
6164 % \cs{SpecialMacroIndex} generating the ``usage'' index entry for
6165 % a macro. Again we provide that as an alias via |\def|.
6166 %
6167 % In fact the documentation of \DOC v2 claimed that one can use
6168 % this for both macros and environments but that was never true as
6169 % for environments the result was that the first character was
6170 % dropped in sorting of the index. The correct way is to use
6171 % \cs{SpecialEnvIndex} for this.
6172 % \begin{macrocode}
6173 \def\SpecialUsageIndex{\SpecialMacroIndex}
6174 % \end{macrocode}
6175 % \end{macro}
6176 %
6177
6178 % \begin{macro}{\SpecialIndex}
6179 % \begin{macrocode}
6180 \def\SpecialIndex {\CodeMacroIndex{code}}
6181 % \end{macrocode}
6182 % \end{macro}
6183
6184
6185 %
6186 % \subsubsection{Environment facilities}
6187 %
6188 % Providing documentation support for environments. Here we differ
6189 % from \DOC V2 by marking the environments with ``(\textit{env.})''
6190 % when printing the name in the margin.
6191 % \begin{macrocode}
6192 \NewDocElement[macrolike = false ,
6193 idxtype = env. ,
6194 idxgroup = environments ,
6195 printtype = \textit{env.}
6196 ]{Env}{environment}
6197 % \end{macrocode}
6198 %
6199 %
6200 %
6201 % To be able to restore the definition after \pkg{hypdoc} is loaded
6202 % we better save them beforehand. We only load the package at the end of
6203 % the preamble, but the user might do this earlier and then chaos
6204 % is ensured. Thus, to support this generally we save them directly
6205 % before the package is loaded.
6206 % In this way the user can still alter the definition for
6207 % \cs{PrintDescribeMacro} and friends in the preamble.
6208 % \changes{v3.0q}{2024/06/04}{Use hooks to save and restore
6209 % definitions when hypdoc gets loaded (gh/1000)}
6210 % \begin{macrocode}
6211 \AddToHook{package/hypdoc/before}{%
6212 \let\@@PrintDescribeMacro \PrintDescribeMacro
6213 \let\@@PrintDescribeEnv \PrintDescribeEnv
6214 \let\@@PrintMacroName \PrintMacroName
6215 \let\@@PrintEnvName \PrintEnvName
6216 \let\@@SpecialUsageIndex \SpecialUsageIndex
6217 \let\@@SpecialEnvIndex \SpecialEnvIndex
6218 \let\@@SortIndex \SortIndex
6219 \let\@@DescribeMacro \DescribeMacro
6220 \let\@@DescribeEnv \DescribeEnv
6221 }
6222 % \end{macrocode}
6223 % After \pkg{hypdoc} got loaded we need to reset those macros
6224 % again. This is done in the generic hook
6225 % \texttt{package/hypdoc/after}.
6226 % \begin{macrocode}
6227 \AddToHook{package/hypdoc/after}{%
6228 \let\PrintDescribeMacro \@@PrintDescribeMacro
6229 \let\PrintDescribeEnv \@@PrintDescribeEnv
6230 \let\PrintMacroName \@@PrintMacroName
6231 \let\PrintEnvName \@@PrintEnvName
6232 \let\SpecialUsageIndex \@@SpecialUsageIndex
6233 \let\SpecialEnvIndex \@@SpecialEnvIndex
6234 \let\SortIndex \@@SortIndex
6235 \let\DescribeMacro \@@DescribeMacro
6236 \let\DescribeEnv \@@DescribeEnv
6237 }
6238 % \end{macrocode}
6239 %
6240 %
6241 % \section{Misc additions}
6242
6243 % \begin{imacro}{\cs}
6244 % \begin{macrocode}
6245 \DeclareRobustCommand\cs[1]{\texttt{\bslash #1}}
6246 % \end{macrocode}
6247 % \cls{amsdtx} has its own definition for \cs{cs} but that now
6248 % gets overwritten because the class loads \pkg{doc} afterwards. So
6249 % for now we reinstall it here.
6250 % \fmi{fix elsewhere}
6251 % \begin{macrocode}
6252 \AddToHook{class/amsdtx/after}{%
6253 \DeclareRobustCommand\cs[1]{%
6254 \@boxorbreak{%
6255 \ntt
6256 \addbslash#1\@empty
6257 \@xp\@xp\@xp\@indexcs\@xp\@nobslash\string#1\@nil
6258 }%
6259 }%
6260 \def\cn{\cs}%
6261 }
6262 % \end{macrocode}
6263 % \end{imacro}
6264
6265
6266 % We can now finish the \texttt{docstrip} main module.
6267 % \begin{macrocode}
6268 %</package>
6269 % \end{macrocode}
6270 %
6271 %
6272 % \Finale
6273 % \PrintChanges
6274 %
6275 %
6276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6277 \endinput
6278 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6279
6280
6281
6282 ^^A Needed for emacs
6283 ^^A
6284 ^^A Local Variables:
6285 ^^A mode: latex
6286 ^^A coding: utf-8-unix
6287 ^^A End: