summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex-dev/base/doc.sty
blob: 49bb2f6205c22d26c9e8c6571398dd502c5afb01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
%%
%% This is file `doc.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% doc.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% The source is maintained by the LaTeX Project team and bug
%% reports for it can be opened at https://latex-project.org/bugs.html
%% (but please observe conditions on bug reports sent to that address!)
%% 
%% 
%% Copyright (C) 1993-2022
%% The LaTeX Project and any individual authors listed elsewhere
%% in this file.
%% 
%% This file was generated from file(s) of the LaTeX base system.
%% --------------------------------------------------------------
%% 
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%    https://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008 or later.
%% 
%% This file has the LPPL maintenance status "maintained".
%% 
%% This file may only be distributed together with a copy of the LaTeX
%% base system. You may however distribute the LaTeX base system without
%% such generated files.
%% 
%% The list of all files belonging to the LaTeX base distribution is
%% given in the file `manifest.txt'. See also `legal.txt' for additional
%% information.
%% 
%% The list of derived (unpacked) files belonging to the distribution
%% and covered by LPPL is defined by the unpacking scripts (with
%% extension .ins) which are part of the distribution.
\NeedsTeXFormat{LaTeX2e}[1994/12/01]

\providecommand\DeclareRelease[3]{}
\providecommand\DeclareCurrentRelease[2]{}

\DeclareRelease{v2.1g}{2016-02-15}
                      {doc-2016-02-15.sty}
\DeclareRelease{v2}{2021-06-01}
                   {doc-2021-06-01.sty}
\DeclareCurrentRelease{v3}{2022-06-01}

\ProvidesPackage{doc}
  [2022/11/13 v3.0m
   Standard LaTeX documentation package V3 (FMi)]
%%
%% Package `doc' to use with LaTeX 2e
%% Copyright (C) 1989-2022 Frank Mittelbach, all rights reserved.





\@ifundefined{macro@cnt}{}{\endinput}
\catcode`\^^A=14
\catcode`\^^X=14
\AtBeginDocument{\catcode`\^^A=14\relax\catcode`\^^X=14\relax}
\DeclareKeys
  {
    noprint           .if    = {doc@noprint},
    noindex           .if    = {doc@noindex},
    hyperref          .if    = {doc@hyperref},
    nohyperref        .ifnot = {doc@hyperref},
    multicol          .if    = {doc@multicol},
    nomulticol        .ifnot = {doc@multicol},
    debugshow         .if    = {doc@debugshow},
    reportchangedates .if    = {doc@reportchangedates},
    toplevel          .if    = {doc@toplevel},
    notoplevel        .ifnot = {doc@toplevel},
    macrolike         .if    = {doc@macrolike},
    envlike           .ifnot = {doc@macrolike},
    idxtype           .store = \doc@idxtype,
    idxgroup          .store = \doc@idxgroup,
    printtype         .store = \doc@printtype,
    outer             .if    = {doc@outer},
  }
\doc@hyperreftrue
\doc@multicoltrue
\doc@topleveltrue
\ProcessKeyOptions
\newif\ifscan@allowed    \scan@allowedtrue
\def\SetupDoc#1{%
  \csname keys_set:nn\endcsname{doc}{#1}%
    \edef\doc@noprintdefault{\ifdoc@noprint true\else false\fi}%
  \ifdoc@noindex
    \def\doc@noindexdefault{true}%
    \scan@allowedfalse
  \else
    \def\doc@noindexdefault{false}%
  \fi
}
\SetupDoc{}              % just save the default values
\def\macrocode{\macro@code
   \frenchspacing \@vobeyspaces
   \xmacro@code}
\def\macro@code{%
   \topsep \MacrocodeTopsep
   \@beginparpenalty \predisplaypenalty
   \if@inlabel\leavevmode\fi
   \trivlist \parskip \z@ \item[]%
   \global\setbox\@labels\box\voidb@x
   \macro@font
   \leftskip\@totalleftmargin \advance\leftskip\MacroIndent
   \rightskip\z@ \parindent\z@ \parfillskip\@flushglue
   \blank@linefalse \def\par{\ifblank@line
                             \leavevmode\fi
                             \blank@linetrue\@@par
                             \penalty\interlinepenalty}
   \obeylines
   \let\do\do@noligs \verbatim@nolig@list
   \let\do\@makeother \dospecials
   \global\@newlistfalse
   \global\@minipagefalse
   \ifcodeline@index
     \everypar{\global\advance\c@CodelineNo\@ne
               \llap{\theCodelineNo\ \hskip\@totalleftmargin}%
               \check@module}%
   \else \everypar{\check@module}%
   \fi
   \init@crossref}
\newif\ifblank@line
\def\endmacrocode{%
                 \ifpm@module \endgroup \pm@modulefalse \fi
                 \everypar{}%
                 \global\@inlabelfalse
                 \endtrivlist
                 \close@crossref}
\@ifundefined{MacroFont}{%
  \if@compatibility
    \def\MacroFont{\small
                   \usefont\encodingdefault
                           \ttdefault
                           \mddefault
                           \shapedefault
                   }%
  \else
    \def\MacroFont{\fontencoding\encodingdefault
                   \fontfamily\ttdefault
                   \fontseries\mddefault
                   \fontshape\shapedefault
                   \small}%
  \fi
  }{}
\@ifundefined{AltMacroFont}{%
  \if@compatibility
    \def\AltMacroFont{\small
                      \usefont\encodingdefault
                              \ttdefault
                              \mddefault
                              \sldefault
                      }%
  \else
    \def\AltMacroFont{\fontencoding\encodingdefault
                      \fontfamily\ttdefault
                      \fontseries\mddefault
                      \fontshape\sldefault
                      \small
                      }%
 \fi
  }{}
\AtBeginDocument{\let\macro@font\MacroFont}
\def\check@module{%
  \ifcheck@modules
    \ifpm@module \endgroup \pm@modulefalse \fi
    \expandafter\futurelet\expandafter\next\expandafter\ch@percent
  \fi}
\newif\ifpm@module
\def\DontCheckModules{\check@modulesfalse}
\def\CheckModules{\check@modulestrue}
\newif\ifcheck@modules  \check@modulestrue
\def\ch@percent{%
  \if \percentchar\next
    \expandafter\check@angle
  \fi}
\def\check@angle#1{\futurelet\next\ch@angle}
\begingroup
\catcode`\<\active
\gdef\ch@angle{\ifx<\next
    \expandafter\ch@plus@etc
  \else \percentchar \fi}
\gdef\ch@plus@etc<{\futurelet\next\check@plus@etc}
\gdef\check@plus@etc{%
    \if +\next
      \let\next\pm@module
    \else\if -\next
      \let\next\pm@module
    \else\if *\next
      \let\next\star@module
    \else\if /\next
      \let\next\slash@module
    \else\ifx <\next
      \percentchar
    \else
      \let\next\pm@module
    \fi\fi\fi\fi\fi
    \next}
\endgroup
\begingroup
\catcode`\~=\active
\lccode`\~=`\>
\lowercase{\gdef\pm@module#1~}{\pm@moduletrue
   \Module{#1}\begingroup
     \advance\guard@level\@ne
     \ifnum\guard@level>\c@StandardModuleDepth\AltMacroFont\fi
}
\lowercase{\gdef\star@module#1~}{%
  \Module{#1}%
  \global \advance \guard@level\@ne
  \ifnum \guard@level>\c@StandardModuleDepth
    \global\let\macro@font=\AltMacroFont \macro@font
  \fi}
\catcode`\>=\active
\gdef\slash@module#1>{%
  \Module{#1}%
  \global \advance \guard@level\m@ne
  \ifnum \guard@level=\c@StandardModuleDepth
    \global\let\macro@font\MacroFont  \macro@font
  \fi
}
\endgroup
\newcounter{StandardModuleDepth}
\newcount \guard@level

\@ifundefined{Module}{%
      \def\Module#1{\mod@math@codes$\langle\mathsf{#1}\rangle$}
  }{}
\def\mod@math@codes{\mathcode`\|="226A \mathcode`\&="2026
                    \mathcode`\-="702D \mathcode`\+="702B
                    \mathcode`\:="703A \mathcode`\=="703D }
\newskip\MacrocodeTopsep \MacrocodeTopsep = 3pt plus 1.2pt minus 1pt
\newdimen\MacroIndent
\settowidth\MacroIndent{\rmfamily\scriptsize 00\ }
\@namedef{macrocode*}{\macro@code\sxmacro@code}
\expandafter\let\csname endmacrocode*\endcsname = \endmacrocode
\catcode`\!=\catcode`\%   ^^A In this section there must not be
                              ^^A any exclamation marks.
                              ^^A
\begingroup
\catcode`\|=\z@ \catcode`\[=\@ne \catcode`\]=\tw@
\catcode`\{=12 \catcode`\}=12
\catcode`\%=12 \catcode`\ =\active \catcode`\\=\active
!%    \end{macrocode*}
!    Next follows the actual definition of  |\macro@code|;
!    notice the
!    use of the new escape character.  We manage to get the argument
!    surrounded by the string |\end{macrocode}|, but at the end
!    however, in spite of the actual characters used during the
!    definition of
!    this macro, |\end| with the argument |{macrocode}|
!    will be executed, to ensure a balanced environment.
!    \begin{macrocode*}
|gdef|xmacro@code#1%    \end{macrocode}[#1|end[macrocode]]
!%    \end{macrocode*}
! \begin{macro}{\sxmacro@code}
!    The definition of |\sxmacro@code| is completely analogous,
!    only
!    here a slightly different terminating string will be used.
!    Note that the space is not active in this environment.
!    \begin{macrocode}
|catcode`| =12
|gdef|sxmacro@code#1%    \end{macrocode*}[#1|end[macrocode*]]
!%    \end{macrocode}
!    because the |\catcode| changes have been made local by
!    commencing a
!    new group, there now follows the matching |\endgroup|
!    in a rather
!    unusual style of writing.
!    \begin{macrocode}
|endgroup
!%    \end{macrocode}
\catcode`\!=12

\reversemarginpar
\setlength\marginparpush{0pt}  \setlength\marginparwidth{8pc}
\setlength\marginparsep{\labelsep}
{\catcode`\|=\z@ \catcode`\\=12
|gdef|bslash{\}}
\def\verbatim{\@beginparpenalty \predisplaypenalty \@verbatim
              \MacroFont \frenchspacing \@vobeyspaces \@xverbatim}
\@namedef{verbatim*}{\@beginparpenalty \predisplaypenalty \@verbatim
              \@setupverbvisiblespace
              \MacroFont \@vobeyspaces \@sxverbatim}
\def\@verbatim{\trivlist \item\relax
  \if@minipage\else\vskip\parskip\fi
  \leftskip\@totalleftmargin\rightskip\z@
  \parindent\z@\parfillskip\@flushglue\parskip\z@
  \language\l@nohyphenation
  \@@par
  \@tempswafalse
  \def\par{%
    \if@tempswa
      \leavevmode \null \@@par\penalty\interlinepenalty
    \else
      \@tempswatrue
      \ifhmode\@@par\penalty\interlinepenalty\fi
    \fi
   \check@percent}%
  \let\do\@makeother \dospecials
  \obeylines \verbatim@font \@noligs
  \everypar \expandafter{\the\everypar \unpenalty}%
}
{\catcode`\%=12
 \long\gdef\check@percent#1{\ifx #1%\let\next\@empty \else
                                    \let\next=#1\fi \next}}
\newcount\macro@cnt \macro@cnt=0
\newskip\MacroTopsep     \MacroTopsep = 7pt plus 2pt minus 2pt
\begingroup
\catcode`\~\active
\gdef\SpecialEscapechar#1{%
    \begingroup
     \uccode`\~`#1%
     \uppercase{\gdef\active@escape@char{~}}%
     \escapechar\m@ne  \xdef\special@escape@char{\string#1}%
   \endgroup}
\endgroup
\begingroup   \catcode`\|=\z@  \catcode`\\=\active
|gdef|init@crossref{|catcode`|\|active   |let\|bslash
    |MakePrivateLetters
    |catcode|expandafter`|special@escape@char|active
    |expandafter|let|active@escape@char|scan@macro}
|endgroup
\SpecialEscapechar{\\}
\@ifundefined{MakePrivateLetters}
    {\let\MakePrivateLetters\makeatletter}{}
\def\close@crossref{\SpecialEscapechar\\}
\def\scan@macro{%
   \special@escape@char
   \step@checksum
   \ifscan@allowed
      \let\macro@namepart\@empty
      \def\next{\futurelet\next\macro@switch}%
   \else \let\next\@empty \fi
   \next}
\def\DisableCrossrefs{\@bsphack\scan@allowedfalse\@esphack}
\def\EnableCrossrefs{\@bsphack\scan@allowedtrue
                     \def\DisableCrossrefs{\@bsphack\@esphack}\@esphack}
\def\macro@switch{\ifcat\noexpand\next a%
     \let\next\macro@name
     \else \let\next\short@macro  \fi
   \next}
\def\short@macro#1{%
   \edef\macro@namepart{\string#1}%
     \maybe@index@short@macro\macro@namepart
    \scan@allowedfalse#1%
    \scan@allowedtrue }
\def\macro@name#1{\edef\macro@namepart{\macro@namepart#1}%
     \futurelet\next\more@macroname}
\def\more@macroname{\ifcat\noexpand\next a%
     \let\next\macro@name
     \else \let\next\macro@finish \fi
     \next}
\def\macro@finish{%
  \macro@namepart
  \maybe@index@macro \macro@namepart
}

\ExplSyntaxOn
\seq_new:N  \l__doc_donotindex_seq
\prop_new:N \g__doc_idxtype_prop
\cs_new:Npn\__doc_trace:x {
  \legacy_if:nTF{ doc@debugshow }{ \iow_term:x } { \use_none:n }
}
\cs_new:Npn \doc_dont_index:n {
  \group_begin:
    \MakePrivateLetters
    \__doc_dont_index:n
}
\cs_new:Npn \__doc_dont_index:n #1 {
  \group_end:
  \__doc_trace:x{Disable~ indexing~ for~ '\tl_to_str:n{#1}' }
  \clist_map_function:nN {#1} \__doc_dont_index_aux:n
}
\cs_new:Npn \__doc_dont_index_aux:n #1 {
  \seq_put_right:Nx \l__doc_donotindex_seq {\expandafter\@gobble \string#1}
}
\cs_set_eq:NN \DoNotIndex \doc_dont_index:n
\def \ShowIndexingState {
  \__doc_trace:x{Show~ doc~ indexing~ state:}
  \seq_show:N  \l__doc_donotindex_seq
  \prop_show:N \g__doc_idxtype_prop
}

\cs_new:Npn \__doc_idxtype_put:Nn #1#2 {
  \exp_args:Nx \__doc_idxtype_put:nn { \cs_to_str:N #1 }{#2}
  \protected@write\@auxout{}
     {\string\RecordIndexTypeAux {\string#1 }{#2} }
}
\cs_new:Npn \RecordIndexTypeAux #1#2 {
  \exp_args:Nx \__doc_idxtype_put:nn { \cs_to_str:N #1 }{#2}
}
\AtEndDocument{
  \cs_set_eq:NN \RecordIndexTypeAux \use_none:nn
}
\cs_set_eq:NN \RecordIndexType \__doc_idxtype_put:Nn
\cs_new:Npn \__doc_idxtype_put_scan:nn #1#2 {
  \exp_args:Nf \__doc_idxtype_put:nn { \tl_to_str:n {#1} }{#2}
  \protected@write\@auxout{}
     {\string\RecordIndexTypeAux {\bslash #1 }{#2} }
}
\cs_generate_variant:Nn \__doc_idxtype_put_scan:nn {o}
\cs_set_eq:NN \record@index@type@save \__doc_idxtype_put_scan:on
\cs_new:Npn \__doc_idxtype_put:nn #1#2 {
  \exp_args:NNf
  \seq_if_in:NnTF \l__doc_donotindex_seq {\tl_to_str:n{#1}}
     {
       \__doc_trace:x{Not~ recording~ index~ type~ for~ '\bslash #1' }
     }
     {
       \__doc_trace:x{Recording~ index~ type~ for~ '\bslash #1' ~ as~ #2 }
       \prop_gput:Nnn \g__doc_idxtype_prop {#1}{#2}
     }
}
\cs_new:Npn \exp_args:co #1#2
   { \cs:w #1 \exp_after:wN \cs_end:\exp_after:wN {#2} }
\cs_generate_variant:Nn \tl_to_str:n {o}

\cs_new:Npn \__doc_maybe_index:o #1 {
  \exp_args:Nf \__doc_maybe_index_aux:nN { \tl_to_str:o {#1} }
                                         \SpecialIndex
}
\cs_set_eq:NN \maybe@index@macro \__doc_maybe_index:o
\cs_new:Npn \__doc_maybe_index_short:o #1 {
  \exp_args:No \__doc_maybe_index_aux:nN #1
                                         \SpecialShortIndex
}
\cs_set_eq:NN \maybe@index@short@macro \__doc_maybe_index_short:o
\cs_new:Npn \__doc_maybe_index_aux:nN #1#2 {
  \__doc_trace:x{Searching~ for~ '\bslash #1'}
  \seq_if_in:NnTF \l__doc_donotindex_seq {#1}
    {
     \__doc_trace:x{Not~ indexing~ '\bslash #1' }
    }
    {
     \prop_get:NnNTF \g__doc_idxtype_prop {#1} \l__doc_idxtype_tl
       {
        \exp_args:Ncno \__doc_maybe_index_aux:Nnn
              { Code \tl_use:N \l__doc_idxtype_tl Index }
              {code} {\bslash #1}
        }
        {
          \__doc_trace:x{Indexing~ '\bslash #1'\space (\string #2)}
          \exp_args:No #2 {\bslash #1}
        }
    }
}
\cs_new:Npn \SpecialShortIndex #1 {
    \@SpecialIndexHelper@ #1\@nil
  \@bsphack
  \ifdoc@noindex \else
    \str_case_e:nnF {\@gtempa }
        {
          {\cs_to_str:N \^^M } {\def\reserved@a{ \string \space \actualchar }
                                \def\reserved@b { \space }
                                \let\reserved@c \@empty                          }
          { ~ }                {\def\reserved@a{ \string \space \actualchar }
                                \def\reserved@b { \space }
                                \let\reserved@c \@empty                          }
          {\c_left_brace_str} { \def\reserved@a{ \bgroup \actualchar }
                                \def\reserved@b { \c_left_brace_str }
                                \def\reserved@c { \noexpand\iffalse
                                                  \c_right_brace_str
                                                  \noexpand\fi }                 }
          {\c_right_brace_str} { \def\reserved@a{ \egroup \actualchar
                                                  \noexpand\iffalse
                                                    \c_left_brace_str
                                                  \noexpand\fi }
                                 \def\reserved@b { \c_right_brace_str }
                                 \let\reserved@c \@empty                         }
          {\verbatimchar}  { \def\reserved@a{ \quotechar\verbatimchar
                                              \actualchar }
                             \let\reserved@b \@empty
                             \def\reserved@c
                                 { \string\texttt{\string\string\verbatimchar} } }
        }
        { \def\reserved@a {\quotechar \@gtempa \actualchar }
          \def\reserved@b {\quotechar \@gtempa  }
          \let\reserved@c \@empty                             }
    \special@index {
    \reserved@a
    \string\verb
    \quotechar *\verbatimchar \quotechar \bslash
    \reserved@b
    \verbatimchar
    \reserved@c
    \encapchar code}
  \fi
  \@esphack
}

\cs_new:Npn \__doc_maybe_index_aux:Nnn #1#2#3 {
    \cs_if_exist:NTF #1
      {
        \__doc_trace:x{Indexing~ '#3'\space as~
                       \tl_use:N \l__doc_idxtype_tl }
        #1{#2}{#3}
      }
      {
        \PackageError{doc}{Doc~ element~
           '\tl_use:N \l__doc_idxtype_tl'~ unknown}%

          {When~ using~ '\string\RecordIndexType'~ the~ type~ must~
           be~ known~\MessageBreak
           to~ the~ system,~ i.e.,~ declared~ via~
           '\string\NewDocElement'\MessageBreak
           before~ it~ can~ be~ used~ in~ indexing.}
     }
}
\ExplSyntaxOff
\@ifundefined{actualchar}{\def\actualchar{=}}{}
\@ifundefined{quotechar}{\def\quotechar{!}}{}
\@ifundefined{levelchar}{\def\levelchar{>}}{}
\@ifundefined{encapchar}{\def\encapchar{|}}{}
\@ifundefined{verbatimchar}{\def\verbatimchar{+}}{}
\begingroup
 \catcode`\|=0
 \catcode`\\=12
 |gdef|@SpecialIndexHelper@#1#2|@nil{%
   |if |noexpand#1\%
     |gdef|@gtempa{#2}%
   |else
     |begingroup
       |escapechar|m@ne
       |expandafter|gdef|expandafter|@gtempa|expandafter{|string#1#2}%
     |endgroup
   |fi}
|endgroup
\def\SortIndex#1#2{%
  \ifdoc@noindex\else
    \index{#1\actualchar#2}%
  \fi
}
\@ifundefined{LeftBraceIndex}{\def\LeftBraceIndex{%
   \special@index{\bgroup\actualchar
                  \string\verb% % to fool emacs highlighting
                  \quotechar*\verbatimchar
                  \quotechar\bslash{\verbatimchar\string\iffalse}\string\fi}}}{}

\@ifundefined{RightBraceIndex}{\def\RightBraceIndex{%
 \special@index{\egroup\actualchar\string\iffalse{\string\fi
           \string\verb% % to fool emacs highlighting
           \quotechar*\verbatimchar\quotechar\bslash}\verbatimchar}}}{}
\@ifundefined{PercentIndex}
  {\def\PercentIndex{\it@is@a\percentchar}}{}
\def\OldMakeindex{\def\PercentIndex{%
    \special@index{\quotechar\percentchar\actualchar
           \string\verb% % to fool emacs highlighting
           \quotechar*\verbatimchar\quotechar\bslash
           \percentchar\percentchar\verbatimchar}}}
{\catcode`\%=12 \gdef\percentchar{%}}
\def\it@is@a#1{\special@index{\quotechar #1\actualchar
                          \string\verb% % to fool emacs highlighting
                          \quotechar*\verbatimchar
                          \quotechar\bslash\quotechar#1\verbatimchar}}

\newdimen\IndexMin         \IndexMin       = 80pt
\newcount\c@IndexColumns   \c@IndexColumns = 3
\ifdoc@multicol
  \RequirePackage{multicol}
  \renewenvironment{theindex}
    {\begin{multicols}\c@IndexColumns[\index@prologue][\IndexMin]%
      \IndexParms \let\item\@idxitem \ignorespaces}%
    {\end{multicols}}
\else
  \def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
    \columnseprule \z@  \columnsep 35\p@
    \twocolumn[\index@prologue]%
    \IndexParms \let\item\@idxitem \ignorespaces}
  \def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
\fi
\long\def\IndexPrologue#1{\@bsphack\def\index@prologue{#1}\@esphack}
\@ifundefined{index@prologue}
     {\def\index@prologue{\section*{Index}%
                 \markboth{Index}{Index}%
                 Numbers written in italic refer to the page
                 where the corresponding entry is described;
                 numbers underlined refer to the
                 \ifcodeline@index
                   code line of the
                 \fi
                 definition; numbers in roman refer to the
                 \ifcodeline@index
                   code lines
                 \else
                   pages
                 \fi
                 where the entry is used.
                 }}{}
\@ifundefined{IndexParms}
    {\def\IndexParms{%
       \parindent \z@
       \columnsep 15pt
       \parskip 0pt plus 1pt
       \rightskip 15pt
       \mathsurround \z@
       \parfillskip=-15pt
        \small
       \def\@idxitem{\par\hangindent 30pt}%
       \def\subitem{\@idxitem\hspace*{15pt}}%
       \def\subsubitem{\@idxitem\hspace*{25pt}}%
       \def\indexspace{\par\vspace{10pt plus 2pt minus 3pt}}%
      }}{}
\def\efill{\hfill\nopagebreak}%
\def\pfill{\unskip~%
           \leaders\hbox to.6em{\hss .\hss}\hfill
           \penalty500\strut\nobreak
           \leaders\hbox to.6em{\hss .\hss}\hfil
           ~\ignorespaces}%
\def\*{\leavevmode\lower.8ex\hbox{$\,\widetilde{\ }\,$}}
\@ifundefined{main}{\def\main#1{\underline{#1}}}{}
\@ifundefined{usage}{\def\usage#1{\textit{#1}}}{}
\@ifundefined{code}{\def\code#1{#1}}{}
\def\PrintIndex{\@input@{\jobname.ind}%
                \global\let\PrintIndex\@empty}
\def\changes{\@bsphack\begingroup\@sanitize
   \catcode`\\\z@ \catcode`\ 10 \MakePercentIgnore
   \changes@}
\def\changes@#1#2#3{%
  \protected@edef\@tempa{\noexpand\glossary{#1%
                   \ifdoc@reportchangedates
                     \space -- #2\fi
                   \levelchar
                   \ifx\saved@macroname\@empty
                      \quotechar!%
                      \actualchar
                      \generalname
                   \else
                      \saved@indexname
                      \actualchar
                      \string\verb% % to fool emacs highlighting
                      \quotechar*%
                      \verbatimchar\saved@macroname
                      \verbatimchar
                   \fi
                   :\levelchar #3}}%
  \@tempa\endgroup\@esphack}
\def\saved@macroname{}
\def\saved@indexname{}
\def\generalname{General}
\let\RecordChanges\makeglossary
\newdimen\GlossaryMin         \GlossaryMin       = 80pt
\newcount\c@GlossaryColumns   \c@GlossaryColumns = 2
\ifdoc@multicol
  \newenvironment{theglossary}{%
    \begin{multicols}\c@GlossaryColumns
                     [\glossary@prologue][\GlossaryMin]%
    \GlossaryParms \let\item\@idxitem \ignorespaces}%
   {\end{multicols}}
\else
  \newenvironment{theglossary}{%
      \@restonecoltrue\if@twocolumn\@restonecolfalse\fi
      \columnseprule \z@  \columnsep 35\p@
      \twocolumn[\glossary@prologue]%
      \GlossaryParms \let\item\@idxitem \ignorespaces}
    {\if@restonecol\onecolumn\else\clearpage\fi}
\fi
\long\def\GlossaryPrologue#1{\@bsphack
                             \def\glossary@prologue{#1}%
                             \@esphack}
\@ifundefined{glossary@prologue}
     {\def\glossary@prologue{\section*{{Change History}}%
                 \markboth{{Change History}}{{Change History}}%
                 }}{}
\@ifundefined{GlossaryParms}{\let\GlossaryParms\IndexParms
  \expandafter\def\expandafter\GlossaryParms\expandafter{\GlossaryParms
     \rightskip 15pt plus 1fil
     \parfillskip -15pt plus -1fil\relax}
}{}
\def\PrintChanges{\@input@{\jobname.gls}%
                  \global\let\PrintChanges\@empty}
\newcommand\AlsoImplementation{%
   \long\def\MaybeStop##1{\@bsphack\gdef\Finale{##1%
                  \check@checksum}%
              \init@checksum
              \@esphack}%
         }
\AlsoImplementation
\def\OnlyDescription{\@bsphack\long\def\MaybeStop##1{%
           ##1\endinput}\@esphack}
\let\Finale\relax
\def\StopEventually{\MaybeStop}
\ifx\l@nohyphenation\undefined
  \newlanguage\l@nohyphenation
\fi
\DeclareRobustCommand\meta[1]{%
     \ensuremath\langle
     \ifmmode \expandafter \nfss@text \fi
     {%
      \meta@font@select
      \edef\meta@hyphen@restore
        {\hyphenchar\the\font\the\hyphenchar\font}%
      \hyphenchar\font\m@ne
      \language\l@nohyphenation
      #1\/%
      \meta@hyphen@restore
     }\ensuremath\rangle
}
\def\meta@font@select{\itshape}
\def\IndexInput#1{%
     \begingroup \macro@code
   \frenchspacing \@vobeyspaces
     \input{#1}\endmacrocode
     \endgroup}
\def\maketitle{\par
      \begingroup \def \thefootnote {\fnsymbol {footnote}}%
      \setcounter {footnote}\z@
      \def\@makefnmark{\hbox to\z@{$\m@th^{\@thefnmark}$\hss}}%
      \long\def\@makefntext##1{\parindent 1em\noindent
            \hbox to1.8em{\hss$\m@th^{\@thefnmark}$}##1}%
      \if@twocolumn \twocolumn [\@maketitle ]%
      \else \newpage \global \@topnum \z@ \@maketitle \fi
       \thispagestyle{titlepage}\@thanks \endgroup
      \setcounter {footnote}\z@
      \gdef\@date{\today}\gdef\@thanks{}%
      \gdef\@author{}\gdef\@title{}}
\@ifundefined{ps@titlepage}
    {\let\ps@titlepage=\ps@plain}{}
\def\MakeShortVerb{%
  \@ifstar
    {\def\@shortvrbdef{\verb*}\@MakeShortVerb}%
    {\def\@shortvrbdef{\verb}\@MakeShortVerb}}
\def\@MakeShortVerb#1{%
  \expandafter\ifx\csname cc\string#1\endcsname\relax
    \@shortvrbinfo{Made }{#1}\@shortvrbdef
    \add@special{#1}%
    \expandafter
    \xdef\csname cc\string#1\endcsname{\the\catcode`#1}%
    \begingroup
      \catcode`\~\active  \lccode`\~`#1%
      \lowercase{%
      \global\expandafter\let
         \csname ac\string#1\endcsname~%
      \expandafter\gdef\expandafter~\expandafter{\@shortvrbdef~}}%
    \endgroup
    \global\catcode`#1\active
  \else
    \@shortvrbinfo\@empty{#1 already}%
                         {\@empty\verb% % to fool emacs highlighting
                          (*)}%
  \fi}
\def\DeleteShortVerb#1{%
  \expandafter\ifx\csname cc\string#1\endcsname\relax
    \@shortvrbinfo\@empty{#1 not}%
                         {\@empty\verb% % to fool emacs highlighting
                          (*)}%
  \else
    \@shortvrbinfo{Deleted }{#1 as}%
                            {\@empty\verb% % to fool emacs
                                           % highlighting
                            (*)}%
    \rem@special{#1}%
    \global\catcode`#1\csname cc\string#1\endcsname
    \global \expandafter\let \csname cc\string#1\endcsname \relax
    \ifnum\catcode`#1=\active
      \begingroup
        \catcode`\~\active   \lccode`\~`#1%
        \lowercase{%
          \global\expandafter\let\expandafter~%
          \csname ac\string#1\endcsname}%
      \endgroup \fi \fi}
\def\@shortvrbinfo#1#2#3{%
  \PackageInfo{doc}{%
     #1\expandafter\@gobble\string#2 a short reference
                                          for \expandafter\string#3}}
\def\add@special#1{%
  \rem@special{#1}%
  \expandafter\gdef\expandafter\dospecials\expandafter
    {\dospecials \do #1}%
  \expandafter\gdef\expandafter\@sanitize\expandafter
    {\@sanitize \@makeother #1}}
\def\rem@special#1{%
  \def\do##1{%
    \ifnum`#1=`##1 \else \noexpand\do\noexpand##1\fi}%
  \xdef\dospecials{\dospecials}%
  \begingroup
    \def\@makeother##1{%
      \ifnum`#1=`##1 \else \noexpand\@makeother\noexpand##1\fi}%
    \xdef\@sanitize{\@sanitize}%
  \endgroup}
\def\init@checksum{\relax
    \global\bslash@cnt\z@}
\def\check@checksum{\relax
  \ifnum\check@sum>\m@ne
     \ifnum\check@sum=\z@
       \typeout{**********************************}%
       \typeout{* This macro file has no checksum!}%
       \typeout{* The checksum should be \the\bslash@cnt!}%
       \typeout{**********************************}%
     \else
       \ifnum\check@sum=\bslash@cnt
         \typeout{*******************}%
         \typeout{* Checksum passed *}%
         \typeout{*******************}%
       \else
         \PackageError{doc}{Checksum not passed
                    (\the\check@sum<>\the\bslash@cnt)}%
          {The file currently documented seems to be wrong.^^J%
           Try to get a correct version.}%
       \fi
     \fi
  \fi
  \global\check@sum\m@ne}
\newcount\check@sum           \check@sum  = \m@ne
\newcount\bslash@cnt          \bslash@cnt = \z@
\def\CheckSum#1{\@bsphack\global\check@sum#1\relax\@esphack}
\def\step@checksum{\global\advance\bslash@cnt\@ne}
\def\CharacterTable{\begingroup \CharTableChanges \character@table}
\begingroup
  \catcode`\~=11
  \gdef\character@table#1{\def\used~table{#1}%
      \ifx\used~table\default~table
           \typeout{***************************}%
           \typeout{* Character table correct *}%
           \typeout{***************************}%
      \else
         \PackageError{doc}{Character table corrupted}
                           {\the\wrong@table}
         \show\default~table
         \show\used~table
      \fi
      \endgroup}
  \global\let\CharTableChanges\@empty
  \makeatother
  \gdef\default~table
     {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
      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
      Digits        \0\1\2\3\4\5\6\7\8\9
      Exclamation   \!     Double quote  \"     Hash (number) \#
      Dollar        \$     Percent       \%     Ampersand     \&
      Acute accent  \'     Left paren    \(     Right paren   \)
      Asterisk      \*     Plus          \+     Comma         \,
      Minus         \-     Point         \.     Solidus       \/
      Colon         \:     Semicolon     \;     Less than     \<
      Equals        \=     Greater than  \>     Question mark \?
      Commercial at \@     Left bracket  \[     Backslash     \\
      Right bracket \]     Circumflex    \^     Underscore    \_
      Grave accent  \`     Left brace    \{     Vertical bar  \|
      Right brace   \}     Tilde         \~}
\endgroup
  \newhelp\wrong@table{Some of the ASCII characters are corrupted.^^J
            I now \string\show\space you both tables for comparison.}
\newif\ifcodeline@index \codeline@indexfalse
\let\CodelineNumbered\codeline@indextrue
\def\codeline@wrindex#1{\if@filesw
     \begingroup
        \set@display@protect
        \immediate\write\@indexfile
            {\string\indexentry{#1}%
             {\number\c@CodelineNo}}%
      \endgroup
    \fi}
\let\special@index = \@gobble
\def\CodelineIndex{\makeindex
                   \codeline@indextrue
                   \let\special@index\codeline@wrindex}
\def\PageIndex{\makeindex
               \codeline@indexfalse
               \let\special@index\index}
\newcount\c@CodelineNo  \c@CodelineNo\z@
\@ifundefined{theCodelineNo}
  {\ifx\selectfont\undefined
     \def\theCodelineNo{\rmfamily\scriptsize\arabic{CodelineNo}}%
   \else
     \def\theCodelineNo{\reset@font\scriptsize\arabic{CodelineNo}}%
   \fi}
  {}
       \tolerance=1000\relax
{ \catcode`\"=12
  \global\mathcode`\\="705C \global\mathcode`\@="7040 }
\@ifundefined{DocstyleParms}{}{\DocstyleParms}
 \let\DocstyleParms\relax
\@ifundefined{AmSTeX}
   {\def\AmSTeX{\leavevmode\hbox{$\mathcal A\kern-.2em\lower.376ex%
        \hbox{$\mathcal M$}\kern-.2em\mathcal S$-\TeX}}}{}
\@ifundefined{BibTeX}
   {\def\BibTeX{{\rmfamily B\kern-.05em%
    \textsc{i\kern-.025em b}\kern-.08em%
    T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}}{}
\@ifundefined{SliTeX}
   {\def\SliTeX{{\rmfamily S\kern-.06emL\kern-.18em\raise.32ex\hbox
                {\scshape i}\kern -.03em\TeX}}}{}
\@ifundefined{PlainTeX}{\def\PlainTeX{\textsc{Plain}\kern2pt\TeX}}{}
\@ifundefined{Web}{\def\Web{\textsc{Web}}}{}
\def\MakePercentIgnore{\catcode`\%9\relax}
\def\MakePercentComment{\catcode`\%14\relax}
\def\DocInput#1{\MakePercentIgnore\input{#1}\MakePercentComment}
\def\GetFileInfo#1{%
  \def\filename{#1}%
  \def\@tempb##1 ##2 ##3\relax##4\relax{%
    \def\filedate{##1}%
    \def\fileversion{##2}%
    \def\fileinfo{##3}}%
  \edef\@tempa{\csname ver@#1\endcsname}%
  \expandafter\@tempb\@tempa\relax? ? \relax\relax}

\AddToHook{begindocument/before}[doc/hyperref]{%
 \ifdoc@hyperref
  \expandafter\let\expandafter\doc@eoph@@k\csname doc.sty-h@@k\endcsname
  \RequirePackage{hypdoc}
  \expandafter\let\csname doc.sty-h@@k\endcsname\doc@eoph@@k
  \let\PrintDescribeMacro \@@PrintDescribeMacro
  \let\PrintDescribeEnv \@@PrintDescribeEnv
  \let\PrintMacroName \@@PrintMacroName
  \let\PrintEnvName \@@PrintEnvName
  \let\SpecialUsageIndex \@@SpecialUsageIndex
  \let\SpecialEnvIndex \@@SpecialEnvIndex
  \let\SortIndex \@@SortIndex
  \let\DescribeMacro \@@DescribeMacro
  \let\DescribeEnv \@@DescribeEnv
  \ifx\special@index\@gobble  % do we write index entries at all?
  \else
    \ifcodeline@index
      \let\special@index\HD@codeline@wrindex
    \else
      \let\special@index\HD@page@wrindex
    \fi
  \fi
  \AddToHook{class/amsdtx/after}{%
     \pdfstringdefDisableCommands{\let\env\@empty }}%
  \def\doc@providetarget{\HD@target}%
  \def\doc@handleencap#1{\encapchar hdclindex{\the\c@HD@hypercount}{#1}}%
 \else
  \let\doc@providetarget\@empty
  \def\doc@handleencap#1{\encapchar #1}%
  \def\hdclindex#1#2{\ifx\@nil#2\@nil\else\csname #2\expandafter\endcsname\fi}%
  \def\hdpindex   #1{\ifx\@nil#1\@nil\else\csname #1\expandafter\endcsname\fi}%
\fi
}

\ExplSyntaxOn
\long\def\@doc@env#1#2#3{
  \endgroup
  \clist_map_inline:nn {#3} { \@doc@env@{#1}{#2}{##1} }
}

\ExplSyntaxOff
\long\def\@doc@env@#1#2#3{%
  \topsep\MacroTopsep
  \trivlist
    \edef\saved@macroname{\string#3}%
    \if #1%
      \edef\saved@indexname{\expandafter\@gobble\saved@macroname}%
      \expandafter\ifx
                  \csname Code#2Index\endcsname
                  \CodeMacroIndex
      \else
        \record@index@type@save
          {\saved@indexname}{#2}%
      \fi
    \else
      \let\saved@indexname\saved@macroname
    \fi
    \def\makelabel##1{\llap{##1}}%
    \if@inlabel
      \let\@tempa\@empty
      \count@\macro@cnt
      \loop\ifnum\count@>\z@
        \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne
      \repeat
      \edef\makelabel##1{\llap{\vtop to\baselineskip{\@tempa\hbox{##1}\vss}}}%
      \advance\macro@cnt\@ne
    \else
      \macro@cnt\@ne
    \fi
    \ifdoc@noprint
      \item
    \else
      \edef\@tempa{%
        \noexpand\item[%
        \noexpand\doc@providetarget
        \noexpand\strut
        \noexpand\@nameuse{Print#2Name}{\saved@macroname}]}%
      \@tempa
    \fi
    \ifdoc@noindex\else
      \global\advance\c@CodelineNo\@ne
      \csname SpecialMain#2Index\expandafter\endcsname
        \expandafter{\saved@macroname}\nobreak
      \global\advance\c@CodelineNo\m@ne
    \fi
    \if#1\expandafter\DoNotIndex \expandafter {\saved@macroname}\fi
    \ignorespaces}
\def\doc@env#1#2[#3]{%
  \@nameuse{doc@noprint\doc@noprintdefault}%
  \@nameuse{doc@noindex\doc@noindexdefault}%
  \csname keys_set:nn\endcsname{doc}{#3}%
  \begingroup
    \ifdoc@outer
      \catcode`\\12
    \fi
    \MakePrivateLetters
    \@doc@env{#1}{#2}%
}

\def\@doc@describe#1#2{%
    \ifdoc@noprint\else
      \marginpar{\raggedleft
                 \strut
                 \doc@providetarget
                 \@nameuse{PrintDescribe#1}{#2}}%
    \fi
    \ifdoc@noindex\else
      \@nameuse{Special#1Index}{#2}%
    \fi
  \@esphack
  \endgroup
  \ignorespaces}
\def\doc@describe#1[#2]{%
  \leavevmode\@bsphack
  \csname keys_set:nn\endcsname{doc}{#2}%
  \@doc@describe{#1}}
\@ifundefined{temptokenb}{\newtoks\@temptokenb}{}
\def\doc@createspecialindexes#1#2#3{%
  \@temptokena{\space (#2)}%
  \@temptokenb{#3:}%
  \@nameedef{SpecialMain#1Index}##1{%
    \noexpand\@bsphack
  \ifdoc@toplevel
    \noexpand\special@index{##1\noexpand\actualchar
    {\string\ttfamily\space##1}%
    \ifx\@nil#2\@nil\else \the\@temptokena \fi
    \noexpand\encapchar main}%
  \fi
  \ifx\@nil#3\@nil\else
    \noexpand\special@index{\the\@temptokenb\noexpand\levelchar
      ##1\noexpand\actualchar{\string\ttfamily\space##1}%
      \noexpand\encapchar main}%
  \fi
    \noexpand\@esphack}%
  \@nameedef{Special#1Index}##1{%
    \noexpand\@bsphack
  \ifdoc@toplevel
    \noexpand\doc@providetarget
    \noexpand\index{##1\noexpand\actualchar{\string\ttfamily\space##1}%
    \ifx\@nil#2\@nil\else \the\@temptokena \fi
           \noexpand\doc@handleencap{usage}}%
  \fi
  \ifx\@nil#3\@nil\else
    \noexpand\index{\the\@temptokenb\noexpand\levelchar
       ##1\noexpand\actualchar{\string\ttfamily\space##1}%
           \noexpand\doc@handleencap{usage}}%
  \fi
    \noexpand\@esphack}}
\def\doc@createspecialmacrolikeindexes#1#2#3{%
  \@temptokena{\space (#2)}%
  \@temptokenb{#3:}%
  \@nameedef{Code#1Index}##1##2{%
    \noexpand\@SpecialIndexHelper@##2\noexpand\@nil
    \noexpand\@bsphack
  \noexpand\ifdoc@noindex\noexpand\else
    \ifdoc@toplevel
      \noexpand\special@index{\noexpand\@gtempa\noexpand\actualchar
\string\verb% % to fool emacs highlighting
\noexpand\quotechar*\noexpand\verbatimchar
\noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
\ifx\@nil#2\@nil\else \the\@temptokena \fi
\noexpand\encapchar ##1}%
    \fi
    \ifx\@nil#3\@nil\else
      \noexpand\special@index{\the\@temptokenb\noexpand\levelchar
\noexpand\@gtempa\noexpand\actualchar
\string\verb% % to fool emacs highlighting
\noexpand\quotechar*\noexpand\verbatimchar
\noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
\noexpand\encapchar ##1}%
    \fi
  \noexpand\fi
    \noexpand\@esphack}%
  \@nameedef{SpecialMain#1Index}##1{%
    \expandafter\noexpand\csname Code#1Index\endcsname
        {main}{##1}}%
  \@nameedef{Special#1Index}##1{%
    \noexpand\@SpecialIndexHelper@##1\noexpand\@nil
    \noexpand\@bsphack
  \noexpand\ifdoc@noindex\noexpand\else
    \ifdoc@toplevel
      \noexpand\doc@providetarget
      \noexpand\index{\noexpand\@gtempa\noexpand\actualchar
\string\verb% % to fool emacs highlighting
\noexpand\quotechar*\noexpand\verbatimchar
\noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
\ifx\@nil#2\@nil\else \the\@temptokena \fi
\noexpand\doc@handleencap{usage}}%
    \fi
    \ifx\@nil#3\@nil\else
      \noexpand\index{\the\@temptokenb\noexpand\levelchar
\noexpand\@gtempa\noexpand\actualchar
\string\verb% % to fool emacs highlighting
\noexpand\quotechar*\noexpand\verbatimchar
\noexpand\bslash\noexpand\@gtempa\noexpand\verbatimchar
\noexpand\doc@handleencap{usage}}%
    \fi
  \noexpand\fi
    \noexpand\@esphack}}

\def\doc@createdescribe#1{%
  \@namedef{Describe#1}{%
    \begingroup
      \MakePrivateLetters
      \@ifnextchar[%]
      {\doc@describe{#1}}{\doc@describe{#1}[]}}}
\def\doc@createenv#1#2#3{%
  \@namedef{#3}{%
    \@ifnextchar[%]
    {\doc@env{#1}{#2}}{\doc@env{#1}{#2}[]}}%
  \@namedef{end#3}{\endtrivlist}%
}

\def\@nameedef#1{\expandafter\edef\csname #1\endcsname}


\def\doc@declareerror#1#2{%
   \PackageError{doc}{Doc element '#1/#2' already defined?\@gobble}%
      {There is already a definition for
       '\string\Print#1Name',\MessageBreak
       '\string\PrintDescribe#1'
       or the environment '#2'.\MessageBreak
       Maybe you are overwriting something by mistake!\MessageBreak
       Otherwise use '\string\RenewDocElement' instead.}%
}

\def\doc@notdeclarederror#1#2{%
   \PackageError{doc}{Doc element '#1/#2' unknown}%
      {I expected an existing definition for
       '\string\Print#1Name',\MessageBreak
       '\string\PrintDescribe#1' and
       the environment '#2' but\MessageBreak
       not all of them are defined.\MessageBreak
       Maybe you wanted to use
       '\string\NewDocElement'?}%
}
\newcommand\NewDocElement[3][]{%
  \@ifundefined{Print#2Name}%
      {\@ifundefined{PrintDescribe#2}%
           {\@ifundefined{#3}%
               {\@ifundefined{end#3}%
                    {\@NewDocElement{#1}}%
                    \doc@declareerror
               }\doc@declareerror
           }\doc@declareerror
      }\doc@declareerror
  {#2}{#3}%
}
\newcommand\RenewDocElement[3][]{%
  \@ifundefined{Print#2Name}\doc@notdeclarederror
      {\@ifundefined{PrintDescribe#2}\doc@notdeclarederror
           {\@ifundefined{#3}\doc@notdeclarederror
               {\@ifundefined{end#3}\doc@notdeclarederror
                    {\@NewDocElement{#1}}%
               }%
           }%
      }%
  {#2}{#3}%
}
\def\@NewDocElement#1#2#3{%
  \doc@macrolikefalse
  \doc@topleveltrue
  \def\doc@idxtype{#3}%
  \def\doc@idxgroup{#3s}%
  \let\doc@printtype\@empty
  \csname keys_set:nn\endcsname{doc}{#1}%
  \ifx\doc@printtype\@empty
    \@temptokena{}%
  \else
    \@temptokena\expandafter{\expandafter
         \textnormal\expandafter{\expandafter
         \space\expandafter
         (\doc@printtype)}}%
  \fi
  \@nameedef{Print#2Name}##1{%
     {\noexpand\MacroFont
      \ifdoc@macrolike
         \noexpand\string
      \fi
      ##1%
      \the\@temptokena
     }}%
  \expandafter\let\csname PrintDescribe#2\expandafter\endcsname
                  \csname Print#2Name\endcsname
  \edef\doc@expr{%
     \ifdoc@macrolike
       \noexpand\doc@createspecialmacrolikeindexes
     \else
       \noexpand\doc@createspecialindexes
     \fi
     {#2}%
    }%
   \expandafter\expandafter\expandafter
   \doc@expr
   \expandafter\expandafter\expandafter
     {\expandafter\doc@idxtype\expandafter}\expandafter
     {\doc@idxgroup}%
  \doc@createdescribe{#2}%
    \ifdoc@macrolike
      \doc@createenv{TT}{#2}{#3}%
    \else
      \doc@createenv{TF}{#2}{#3}%
    \fi
}


\NewDocElement[macrolike = true ,
                idxtype   = ,
                idxgroup  = ,
                printtype =
               ]{Macro}{macro}

\def\SpecialMainIndex{\SpecialMainMacroIndex}

\def\SpecialUsageIndex{\SpecialMacroIndex}

\def\SpecialIndex     {\CodeMacroIndex{code}}

\NewDocElement[macrolike = false ,
                idxtype   = env.  ,
                idxgroup  = environments ,
                printtype = \textit{env.}
               ]{Env}{environment}
  \let\@@PrintDescribeMacro \PrintDescribeMacro
  \let\@@PrintDescribeEnv \PrintDescribeEnv
  \let\@@PrintMacroName \PrintMacroName
  \let\@@PrintEnvName \PrintEnvName
  \let\@@SpecialUsageIndex \SpecialUsageIndex
  \let\@@SpecialEnvIndex \SpecialEnvIndex
  \let\@@SortIndex \SortIndex
  \let\@@DescribeMacro \DescribeMacro
  \let\@@DescribeEnv \DescribeEnv

\DeclareRobustCommand\cs[1]{\texttt{\bslash #1}}
\AddToHook{class/amsdtx/after}{%
  \DeclareRobustCommand\cs[1]{%
    \@boxorbreak{%
        \ntt
        \addbslash#1\@empty
        \@xp\@xp\@xp\@indexcs\@xp\@nobslash\string#1\@nil
    }%
  }%
  \def\cn{\cs}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\endinput
%%
%% End of file `doc.sty'.