summaryrefslogtreecommitdiff
path: root/macros/latex/base/ltlists.dtx
blob: 653e4e2edd280e4dbd719f93d67f115282e865f5 (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
% \iffalse meta-comment
%
% Copyright (C) 1993-2020
% The LaTeX3 Project and any individual authors listed elsewhere
% in this file.
%
% This file is part 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".
%
% 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.
%
% \fi
% \iffalse
%%% From File: ltlists.dtx
%<*driver>
% \fi
\ProvidesFile{ltlists.dtx}
             [2020/04/24 v1.0t LaTeX Kernel (List Environments)]
% \iffalse
\documentclass{ltxdoc}
\GetFileInfo{ltlists.dtx}
\title{\filename}
\date{\filedate}
 \author{%
  Johannes Braams\and
  David Carlisle\and
  Alan Jeffrey\and
  Leslie Lamport\and
  Frank Mittelbach\and
  Tobias Oetiker\thanks{Tobi has converted the documentation to
    doc.sty standard}\and
  Chris Rowley\and
  Rainer Sch\"opf}

\begin{document}
 \MaintainedByLaTeXTeam{latex}
 \maketitle
 \DocInput{\filename}
\end{document}
%</driver>
% \fi
%
%
% \changes{v1.0b}{1994/03/28}{Improve documentation}
% \changes{v1.0f}{1994/05/21}{Use new error commands}
% \changes{v1.0f}{1995/05/21}{Moved to doc.sty standard}
%
% \section{List, and related environments}
%
% The generic commands for creating an indented environment --
% |enumerate|, |itemize|, |quote|, etc -- are:
% \begin{quote}
%        |\list|\marg{LABEL}\marg{COMMANDS} ... |\endlist|
% \end{quote}
%
% which can be invoked by the user as the list environment.  The LABEL
% argument specifies item labeling.  COMMANDS contains commands for
% changing the horizontal and vertical spacing parameters.
%
% Each item of the environment is begun by the command
% |\item[|ITEMLABEL|]|
% which produces an item labeled by ITEMLABEL.  If the argument is
% missing, then the LABEL argument of the |\list| command is used as the
% item label.
%
% The label is formed by putting |\makelabel|\marg{ITEMLABEL} in an hbox
% whose width is either its natural width or else |\labelwidth|,
% whichever is larger.  The |\list| command defines |\makelabel| to have
% the default  definition:
% \begin{quote}
%     |\makelabel|\marg{ARG} == BEGIN |\hfil| ARG END
% \end{quote}
% which, for a label of width less than |\labelwidth|, puts the label
% flushright, |\labelsep| to the left of the item's text.  However,
% |\makelabel| can be |\let| to another command by the |\list|'s
% COMMANDS argument.
%
% A |\usecounter|\marg{foo} command in the second argument causes the
% counter \emph{foo} to be initialized to zero, and stepped by every
% |\item| command without an argument.  (|\label| commands within the
% list refer to this counter.)
%
% When you leave a list environment, returning either to an enclosing
% list or normal text mode, LaTeX begins a new paragraph if and only if
% you leave a blank line after the |\end| command.  This is accomplished
% by the |\@endparenv| command.
%
% Blank lines are ignored every other reasonable place--i.e.:
% \begin{itemize}
%  \item  Between the |\begin{list}| and the first |\item|,
%  \item  Between the |\item| and the text of that item.
%  \item Between the end of the last item and the |\end{list}|.
% \end{itemize}
%
% For an environment like quotation, in which items are not labeled,
% the entire environment is a single item.  It is defined by
% letting |\quotation| == |\list{}{...}\item\relax|.  (Note the
% |\relax|, there in case the first character in the environment is a
% '['.)  The spacing parameters provide a great deal of flexability in
% designing the format, including the ability to let the indentation of
% the first paragraph be different from that of the subsequent ones.
%
% The trivlist environment is equivalent to a list environment
% whose second argument sets the following parameter values:
% \begin{description}
% \item[\cs{leftmargin} = 0:] causes no indentation of left margin
% \item[\cs{labelwidth} = 0:] see below for precise effect this has.
% \item[\cs{itemindent} = 0:] with a null label, makes first paragraph
%        have no indentation.  Succeeding paragraphs have |\parindent|
%        indentation.  To give first paragraph same indentation, set
%        |\itemindent| = |\parindent| before the |\item[]|.
% \end{description}
%
% Every |\item| in a trivlist environment must have an argument---in
% many cases, this will be the null argument (|\item[]|).  The trivlist
% environment is mainly used for paragraphing environments, like
% verbatim, in which there is no margin change.  It provides the same
% vertical spacing as the list environment, and works reasonably well
% when it occurs immediately after an |\item| command in an enclosing
% list.
%
% \StopEventually{}
%
%
% \changes{v1.0a}{1994/03/07}{Initial version, split from latex.dtx}
% \changes{v1.0a}{1994/03/07}{Long lines wrapped to 72 columns}
%
%
% \subsection{List and Trivlist}
%
%
% The following variables are used inside a list environment:
% \begin{description}
% \item[\cs{@totalleftmargin}] The distance that the prevailing left
%     margin is indented from the outermost left margin,
% \item[\cs{linewidth}] The width of the current line.  Must be
%     initialized to |\hsize|.
% \item[\cs{@listdepth}] A count for holding current list nesting depth.
% \item[\cs{makelabel}] A macro with a single argument, used to
%   generate the label from the argument (given or implied)
%   of the |\item| command. Initialized to |\@mklab| by the |\list|
%   command.  This command must produce  some stretch---i.e., an
%   |\hfil|.
% \item[\cs{@inlabel}] A switch that is false except between the time
%   an |\item| is encountered and the time that \TeX{}
%   actually enters horizontal mode.  Should be tested by commands
%   that can be messed up by the list environment's use of |\everypar|.
% \item[\cs{box}\cs{@labels}] When |@inlabel = true|, it holds the labels
%   to be put out by |\everypar|.
% \item[\texttt{@noparitem}] A switch set by |\list| when
%   |@inlabel = true|.
%   Handles the case of a |\list| being the first thing in an item.
% \item[\texttt{@noparlist}] A switch set true for a list that begins an
%   item.  No |\topsep| space is added before or after |\item|'s such a
%   list.
% \item[\texttt{@newlist}] Set true by |\list|, set false by the first
%   text (by |\everypar|).
% \item[\texttt{@noitemarg}]  Set true when executing an |\item| with no
%   explicit argument.  Used to save space. To save time, make two
%   separate  |\@item| commands.
% \item[\texttt{@nmbrlist}] Set true by |\usecounter| command, causes
%   list to be numbered.
% \item[\cs{@listctr}] |\def|'ed by |\usecounter| to name of counter.
% \item[\cs{@noskipsec}] A switch set true by a sectioning command when
%    it is creating an in-text heading with |\everypar|.
% \end{description}
%
% Throughout a list environment, |\hsize| is the width of the current
% line, measured from the outermost left margin to the outermost right
% margin.  Environments like tabbing should use |\linewidth| instead of
% |\hsize|.
%
% Here are the parameters of a list that can be set by commands in
% the |\list|'s COMMANDS argument.  These parameters are all TeX
% skips or dimensions (defined by |\newskip| or |\newdimen|), so the
% usual \TeX\ or \LaTeX\ commands can be used to set them.  The
% commands will be executed in vmode if and only if the |\list| was
% preceded by a |\par| (or something like an |\end{list}|), so the
% spacing parameters can be set according to whether the list is
% inside a paragraph or is its own paragraph.
%
%
% \subsection{Vertical Spacing (skips)}
% \begin{description}
% \item[\cs{topsep}:]  Space between first item and preceding paragraph.
% \item[\cs{partopsep}:] Extra space added to \cs{topsep} when
%        environment starts a new paragraph (is called in vmode).
% \item[\cs{itemsep}:] Space between successive items.
% \item[\cs{parsep}:] Space between paragraphs within an item -- the
%                 \cs{parskip} for this environment.
% \end{description}
%
% \subsection{Penalties}
% \begin{description}
%
% \item[\cs{@beginparpenalty}:] put at the beginning of a list
% \item[\cs{@endparpenalty}:] put at end of list
%  \item[\cs{@itempenalty}:] put between items.
%  \end{description}
%
% \subsection{Horizontal Spacing (dimens)}
% \begin{description}
% \item[\cs{leftmargin}:] space between left margin of enclosing
%   environment (or of page if top level list) and left margin of
%                     this list.  Must be nonnegative.
%  \item[\cs{rightmargin}:] analogous.
%  \item[\cs{listparindent}:] extra indentation at beginning of every
%     paragraph of a list except the one started by the \cs{item}
%                      command.  May be negative!  Usually, labeled
%                       lists have \cs{listparindent} equal to zero.
%   \item[\cs{itemindent}:] extra indentation added right BEFORE an item
%                      label.
%  \item[\cs{labelwidth}:] nominal width of box that contains the label.
%                      If the natural width of the
%                         label $< =$ \cs{labelwidth},
%                      then the label is flushed right inside a box
%                      of width \cs{labelwidth} (with an \cs{hfil}).
%                      Otherwise,
%                      a box of the natural width is employed, which
%                       causes an indentation of the text on that line.
%     \item[\cs{labelsep}:] space between end of label box and text of
%                      first item.
%  \end{description}
% \subsection{Default Values}
%      Defaults for the list environment are set as follows.
%      First, \cs{rightmargin}, \cs{listparindent} and \cs{itemindent}
%      are set
%      to 0pt.  Then, one of the commands
%      \cs{@listi}, \cs{@listii}, ... , \cs{@listvi}
%      is called, depending upon the current level of the list.
%      The \cs{@list} \ldots commands should be defined by the document
%      style.  A convention that the document style should follow is
%      to set \cs{leftmargin} to
%      \cs{leftmargini},\ldots, \cs{leftmarginvi} for
%      the appropriate level.  Items that aren't changed may be left
%      alone, but everything that could possibly be changed must be
%      reset.
%  \begin{oldcomments}
%  \list{LABEL}{COMMANDS} ==
%   BEGIN
%     if \@listdepth > 5
%       then LaTeX error: 'Too deeply nested'
%       else \@listdepth :=G \@listdepth + 1
%     fi
%     \rightmargin     := 0pt
%     \listparindent   := 0pt
%     \itemindent      := 0pt
%     \eval(@list \romannumeral\the\@listdepth)  %% Set default values:
%     \@itemlabel      :=L LABEL
%     \makelabel       == \@mklab
%     @nmbrlist        :=L false
%     COMMANDS
%
%     \@trivlist                % commands common to \list and \trivlist
%
%     \parskip          :=L \parsep
%     \parindent        :=L \listparindent
%     \linewidth        :=L \linewidth - \rightmargin -\leftmargin
%     \@totalleftmargin :=L \@totalleftmargin + \leftmargin
%     \parshape 1 \@totalleftmargin \linewidth
%     \ignorespaces                    % gobble space up to \item
%    END
%
% \endlist == BEGIN \@listdepth :=G \@listdepth -1
%                   \endtrivlist
%             END
%
% \@trivlist ==
%  BEGIN
%     if @newlist = T then \@noitemerr fi
%                     %% This command removed for some forgotten reason.
%     \@topsepadd :=L \topsep
%     if @noskipsec then leave vertical mode fi  %% Added 11 Jun 85
%     if vertical mode
%       then \@topsepadd :=L \@topsepadd + \partopsep
%       else \unskip \par            % remove glue from end of last line
%     fi
%     if @inlabel = true
%        then @noparitem :=L true
%             @noparlist :=L true
%        else @noparlist :=L false
%             \@topsep   :=L \@topsepadd
%     fi
%     \@topsep         :=L \@topsep + \parskip  %% Change 4 Sep 85
%     \leftskip        :=L 0pt         % Restore paragraphing parameters
%     \rightskip       :=L \@rightskip
%     \parfillskip     :=L 0pt + 1fil
%
%   NOTE: \@setpar called on every \list in case \par has been
%   temporarily  munged before the \list command.
%     \@setpar{if @newlist = false then {\@@par} fi}
%     \@newlist         :=G T
%     \@outerparskip    :=L \parskip
% END
%
% \trivlist  ==
% BEGIN
%  \parsep     := \parskip
%  @nmbrlist := F
%  \@trivlist
%  \labelwidth := 0
%  \leftmargin := 0
%  \itemindent := \parindent
%  \@itemlabel :=L "empty"          %% added 93/12/13
%  \makelabel{LABEL} == LABEL
% END
%
% \endtrivlist ==
%   BEGIN
%     if @inlabel = T then \indent fi
%     if horizontal mode then \unskip \par fi
%     if @noparlist = true
%       else if \lastskip > 0
%               then \@tempskipa := \lastskip
%                    \vskip - \lastskip
%                    \vskip \@tempskipa -\@outerparskip + \parskip
%            fi
%            \@endparenv
%     fi
%   END
%
% \@endparenv ==
%   BEGIN
%    \addpenalty{@endparpenalty}
%    \addvspace{\@topsepadd}
%    \endgroup    %% ends the \begin command's \begingroup
%    \par  ==  BEGIN
%                \@restorepar
%                \everypar{}
%                \par
%              END
%    \everypar == BEGIN remove \lastbox \everypar{} END
%    \begingroup  %% to match the \end commands \endgroup
%   END
%
% \item == BEGIN if math mode then WARNING fi
%                  if  next char = [
%                  then  \@item
%                  else  @noitemarg := true
%                        \@item[@itemlabel]
%          END
%
% \@item[LAB] ==
%    BEGIN
%     if @noparitem = true
%       then @noparitem := false
%                % NOTE: then clause  hardly every taken,
%                %  so made a macro \@donoparitem
%            \box\@labels :=G \hbox{\hskip -\leftmargin
%                                   \box\@labels
%                                   \hskip \leftmargin }
%            if @minipage = false then
%               \@tempskipa := \lastskip
%               \vskip -\lastskip
%               \vskip \@tempskipa + \@outerparskip - \parskip
%            fi
%       else if @inlabel = true
%              then \indent \par   % previous item empty.
%            fi
%            if hmode then 2 \unskip's
%                           % To remove any space at end of prev.
%                           % paragraph that could cause a blank line.
%                     \par
%            fi
%            if @newlist = T
%               then if @nobreak = T   % Kludge if list follows \section
%                      then \addvspace{\@outerparskip - \parskip}
%                      else \addpenalty{\@beginparpenalty}
%                           \addvspace{\@topsep}
%                           \addvspace{-\parskip}   %% added 4 Sep 85
%                    fi
%               else \addpenalty{\@itempenalty}
%                    \addvspace{\itemsep}
%            fi
%            @inlabel :=G true
%     fi
%
%     \everypar{ @minipage :=G F
%                @newlist :=G F
%                if  @inlabel = true
%                  then @inlabel :=G false
%                       \hskip -\parindent
%                       \box\@labels
%                       \penalty 0
%                             %% 3 Oct 85  -- allow line break here
%                       \box\@labels :=G null
%                fi
%                \everypar{} }
%     @nobreak :=G false
%     if  @noitemarg = true
%       then @noitemarg := false
%            if @nmbrlist
%              then \refstepcounter{\@listctr}
%     fi     fi
%     \@tempboxa   :=L \hbox{\makelabel{LAB}}
%     \box\@labels :=G \@labels \hskip \itemindent
%                       \hskip - (\labelwidth + \labelsep)
%                       if \wd \@tempboxa > \labelwidth
%                          then \box\@tempboxa
%                          else \hbox to \labelwidth {\unhbox\@tempboxa}
%                       fi
%                       \hskip\labelsep
%     \ignorespaces                        %gobble space up to text
%   END
%
%   \makelabel{LABEL} == ERROR   %% default to catch lonely \item
%
%
%   \usecounter{CTR} == BEGIN  @nmbrlist :=L true
%                              \@listctr == CTR
%                              \setcounter{CTR}{0}
%                       END
%
% DEFINE \dimen's and \count
% \end{oldcomments}
% \begin{macro}{\topskip}
% \begin{macro}{\partopsep}
% \begin{macro}{\itemsep}
% \begin{macro}{\parsep}
% \begin{macro}{\@topsep}
% \begin{macro}{\@topsepadd}
% \begin{macro}{\outerparskip}
%    \begin{macrocode}
%<*2ekernel>
\newskip\topsep
\newskip\partopsep
\newskip\itemsep
\newskip\parsep
\newskip\@topsep
\newskip\@topsepadd
\newskip\@outerparskip
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
% \end{macro}
% \begin{macro}{\leftmargin}\begin{macro}{\rightmargin}
% \begin{macro}{\listparindent}\begin{macro}{\itemindent}
% \begin{macro}{\labelwidth}\begin{macro}{\labelsep}
% \begin{macro}{\@totalleftmargin}
%    \begin{macrocode}
\newdimen\leftmargin
\newdimen\rightmargin
\newdimen\listparindent
\newdimen\itemindent
\newdimen\labelwidth
\newdimen\labelsep
\newdimen\linewidth
\newdimen\@totalleftmargin \@totalleftmargin=\z@
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
% \end{macro}\end{macro}
%
% \begin{macro}{\leftmargini}
% \begin{macro}{\leftmarginii}
% \begin{macro}{\leftmarginiii}
% \begin{macro}{\leftmarginiv}
% \begin{macro}{\leftmarginv}
% \begin{macro}{\leftmarginvi}
%    \begin{macrocode}
\newdimen\leftmargini
\newdimen\leftmarginii
\newdimen\leftmarginiii
\newdimen\leftmarginiv
\newdimen\leftmarginv
\newdimen\leftmarginvi
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
% \end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\@listdepth}\begin{macro}{\@itempenalty}
% \begin{macro}{\@beginparpenalty}\begin{macro}{\@endparpenalty}
%    \begin{macrocode}
\newcount\@listdepth \@listdepth=0
\newcount\@itempenalty
\newcount\@beginparpenalty
\newcount\@endparpenalty
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\@labels}
%    \begin{macrocode}
\newbox\@labels
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\if@inlabel}
% \begin{macro}{\@inlabelfalse}
% \begin{macro}{\@inlabeltrue}
%    \begin{macrocode}
\newif\if@inlabel \@inlabelfalse
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\if@newlist}
% \begin{macro}{\@newlistfalse}
% \begin{macro}{\@newlisttrue}
%    \begin{macrocode}
\newif\if@newlist   \@newlistfalse
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\if@noparitem}
% \begin{macro}{\@noparitemfalse}
% \begin{macro}{\@noparitemtrue}
%    \begin{macrocode}
\newif\if@noparitem \@noparitemfalse
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\if@noparlist}
% \begin{macro}{\@noparlistfalse}
% \begin{macro}{\@noparlisttrue}
%    \begin{macrocode}
\newif\if@noparlist \@noparlistfalse
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\if@noitemarg}
% \begin{macro}{\@noitemargfalse}
% \begin{macro}{\@noitemargtrue}
%    \begin{macrocode}
\newif\if@noitemarg \@noitemargfalse
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\if@newlist}
% \begin{macro}{\@newlistfalse}
% \begin{macro}{\@newlisttrue}
%    \begin{macrocode}
\newif\if@nmbrlist  \@nmbrlistfalse
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
% \begin{environment}{list}
% \begin{macro}{\list}
%    \begin{macrocode}
\def\list#1#2{%
  \ifnum \@listdepth >5\relax
    \@toodeep
  \else
    \global\advance\@listdepth\@ne
  \fi
  \rightmargin\z@
  \listparindent\z@
  \itemindent\z@
  \csname @list\romannumeral\the\@listdepth\endcsname
  \def\@itemlabel{#1}%
  \let\makelabel\@mklab
  \@nmbrlistfalse
  #2\relax
  \@trivlist
  \parskip\parsep
  \parindent\listparindent
  \advance\linewidth -\rightmargin
  \advance\linewidth -\leftmargin
  \advance\@totalleftmargin \leftmargin
  \parshape \@ne \@totalleftmargin \linewidth
  \ignorespaces}
%    \end{macrocode}
% \end{macro}
% \end{environment}
%
% \begin{macro}{\par@deathcycles}
%    \begin{macrocode}
\newcount\par@deathcycles
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@trivlist}
% \changes{v1.0e}{1994/12/02}{RmS: Added check for looping}
% \changes{v1.0p}{1996/10/31}{Added check for missing item in outer
%                             list}
% \changes{v1.0q}{1996/11/04}{Moved check for missing item: only checked
%                 when not inlabel flag is false}
% Because |\par| is sometimes made a no-op it is possible for a missing
% |\item| to produce a loop that does not fill memory and so never gets
% trapped by \TeX.  We thus need to trap this here by seting |\par| to
% count the number of times a paragraph ii is called with no progress
% being made started.
%    \begin{macrocode}
\def\@trivlist{%
  \if@noskipsec \leavevmode \fi
  \@topsepadd \topsep
  \ifvmode
    \advance\@topsepadd \partopsep
  \else
    \unskip \par
  \fi
  \if@inlabel
    \@noparitemtrue
    \@noparlisttrue
  \else
    \if@newlist \@noitemerr \fi
    \@noparlistfalse
    \@topsep \@topsepadd
  \fi
  \advance\@topsep \parskip
  \leftskip \z@skip
  \rightskip \@rightskip
  \parfillskip \@flushglue
  \par@deathcycles \z@
  \@setpar{\if@newlist
             \advance\par@deathcycles \@ne
             \ifnum \par@deathcycles >\@m
               \@noitemerr
               {\@@par}%
             \fi
           \else
             {\@@par}%
           \fi}%
  \global \@newlisttrue
  \@outerparskip \parskip}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{trivlist}
% \begin{macro}{\trivlist}
% \changes{0.0}{1992/03/18}{RmS: added \cs{@nmbrlistfalse}}
%    \begin{macrocode}
\def\trivlist{%
  \parsep\parskip
  \@nmbrlistfalse
  \@trivlist
  \labelwidth\z@
  \leftmargin\z@
  \itemindent\z@
%    \end{macrocode}
%
%    We initialise |\@itemlabel| so that a \texttt{trivlist} with
%    an |\item| not having an optional argument doesn't produce an
%    error message.
% \changes{latex2e}{1993/12/13}{Initialised \cs{@itemlabel}}
%    \begin{macrocode}
  \let\@itemlabel\@empty
  \def\makelabel##1{##1}}
%    \end{macrocode}
% \end{macro}
% \end{environment}
%
% \begin{macro}{\endlist}
%    \begin{macrocode}
\def\endlist{%
  \global\advance\@listdepth\m@ne
  \endtrivlist}
%    \end{macrocode}
% \end{macro}
%
%    The definition of \cs{trivlist} used to be in ltspace.dtx
%    so that other commands could be `let to it'.
%    They now use \cs{def}.
% \begin{macro}{\endtrivlist}
% \changes{v1.2b ltspace}{1994/11/12}{Changed order of tests to make
% \cs{@noitemerror} correct: end of an era.}
% \changes{v1.0i}{1995/05/25}{Macros moved from ltspace.dtx}
% \changes{v1.0n}{1996/10/25}{Change \cs{indent} to \cs{leavevmode}}
% \changes{v1.0n}{1996/10/25}{Reset flags explicitly}
% \changes{v1.0o}{1996/10/26}{Correct typo}
%    \begin{macrocode}
\def\endtrivlist{%
  \if@inlabel
    \leavevmode
    \global \@inlabelfalse
  \fi
  \if@newlist
    \@noitemerr
    \global \@newlistfalse
  \fi
  \ifhmode\unskip \par
%    \end{macrocode}
%    We also check if we are in math mode and issue an error message
%    if so (hoping that |\@currenvir| resolves suitably). Otherwise
%    the usual ``perhaps a missing item'' error will get triggered
%    later which is confusing.
% \changes{v1.0s}{2002/10/28}{Check for math mode (pr/3437)}
%    \begin{macrocode}
  \else
    \@inmatherr{\end{\@currenvir}}%
  \fi
  \if@noparlist \else
    \ifdim\lastskip >\z@
      \@tempskipa\lastskip \vskip -\lastskip
      \advance\@tempskipa\parskip \advance\@tempskipa -\@outerparskip
      \vskip\@tempskipa
    \fi
    \@endparenv
  \fi
}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\@endparenv}
% \begin{macro}{\@doendpe}
% To suppress the paragraph indentation in text immediately following
% a paragraph-making environment, \cs{everypar} is changed to remove the
% space, and \cs{par} is redefined to restore \cs{everypar}.  Instead of
% redefining \cs{par} and \cs{everypar}, \cs{@endparenv} was changed to
% set the @endpe switch, letting \cs{end} redefine \cs{par} and
% \cs{everypar}.
%
% This allows paragraph-making environments to work right when called
% by other environments. (Changed 27 Oct 86)
%    \begin{macrocode}
\def\@endparenv{%
  \addpenalty\@endparpenalty\addvspace\@topsepadd\@endpetrue}
%    \end{macrocode}
%
%    \begin{macrocode}
%<latexrelease>\IncludeInRelease{2015/01/01}{\@doendpe}{clubpenalty fix}%
\def\@doendpe{\@endpetrue
     \def\par{\@restorepar
%    \end{macrocode}
%    If a section heading changes |\clubpenalty| to keep lines
%    after it together then this modification is restored via the
%   |\everypar| mechanism at the start of the next paragraph. As we
%   destroy the contents of this token here we explicity set
%   |\clubpenalty| back to its default.
% \changes{v1.0t}{2015/05/10}{Explicitly reset \cs{clubpenalty} before
%  clearing \cs{everypar}; see also pr/0462 and pr/4065}
%    \begin{macrocode}
              \clubpenalty\@clubpenalty
              \everypar{}\par\@endpefalse}\everypar
%    \end{macrocode}
%
%    Use |\setbox0=\lastbox| instead of   |\hskip -\parindent|
%    so that a \cs{noindent} becomes a no-op when used before
%    a line immediately following a list environment(23 Oct 86).
% \changes{v1.0k}{1995/11/07}{Enclosed \cs{setbox0} assignment by a
% group so that it leaves the contents of box $0$ intact.}
%    \begin{macrocode}
               {{\setbox\z@\lastbox}%
                \everypar{}\@endpefalse}}
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
%
%    \begin{macrocode}
%<latexrelease>\IncludeInRelease{0000/00/00}{\@doendpe}{clubpenalty fix}%
%<latexrelease>\def\@doendpe{\@endpetrue
%<latexrelease>    \def\par{\@restorepar\everypar{}\par\@endpefalse}\everypar
%<latexrelease>               {{\setbox\z@\lastbox}\everypar{}\@endpefalse}}
%<latexrelease>\EndIncludeInRelease
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\if@endpe}
% \begin{macro}{\@endpefalse}
% \begin{macro}{\@endpeltrue}
%    \begin{macrocode}
\newif\if@endpe
\@endpefalse
%    \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
%
% \begin{macro}{\@mklab}
%    \begin{macrocode}
\def\@mklab#1{\hfil #1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\item}
% \changes{LaTeX2.09}{1992/09/18}
%     {(RmS) Added warning if \cs{item} is used in math mode}
% \changes{v1.0c}{1994/04/28}
%     {Replaced \cs{@ltxnomath} by \cs{@inmatherr}}
% \changes{v1.0d}{1994/05/03}
%     {Removed superfluous braces}
%    \begin{macrocode}
\def\item{%
  \@inmatherr\item
  \@ifnextchar [\@item{\@noitemargtrue \@item[\@itemlabel]}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@donoparitem}
%    \begin{macrocode}
\def\@donoparitem{%
  \@noparitemfalse
  \global\setbox\@labels\hbox{\hskip -\leftmargin
                               \unhbox\@labels
                                \hskip \leftmargin}%
  \if@minipage\else
    \@tempskipa\lastskip
    \vskip -\lastskip
    \advance\@tempskipa\@outerparskip
    \advance\@tempskipa -\parskip
    \vskip\@tempskipa
  \fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@item}
% \changes{v1.0l}{1996/07/26}{Remove unecessary \cs{global} before
%                 \cs{@minipage...}}
%    \begin{macrocode}
\def\@item[#1]{%
  \if@noparitem
    \@donoparitem
  \else
    \if@inlabel
      \indent \par
    \fi
    \ifhmode
      \unskip\unskip \par
    \fi
    \if@newlist
      \if@nobreak
        \@nbitem
      \else
        \addpenalty\@beginparpenalty
        \addvspace\@topsep
        \addvspace{-\parskip}%
      \fi
    \else
      \addpenalty\@itempenalty
      \addvspace\itemsep
    \fi
    \global\@inlabeltrue
  \fi
  \everypar{%
    \@minipagefalse
    \global\@newlistfalse
%    \end{macrocode}
%    This |\if@inlabel| check is needed in case an item starts of
%    inside a group so that |\everypar| does not become empty
%    outside that group.
%    \begin{macrocode}
    \if@inlabel
      \global\@inlabelfalse
%    \end{macrocode}
%    The paragraph indent is now removed by using |\setbox...| since
%    this makes |\noindent| a no-op here, as it should be. Thus the
%    following comment is redundant but is left here for the sake of
%    future historians:
%    this next command was changed from an hskip to a kern to avoid
%    a break point after the parindent box: the skip could cause a
%    line-break if a very long label occurs in raggedright setting.
% \changes{v1.0d}{1994/05/03}{\cs{hskip} changed to \cs{kern}}
% \changes{v1.0m}{1996/10/23}{\cs{kern...} changed to \cs{setbox...}}
% \changes{v1.0r}{1997/02/21}
%    {\cs{ifvoid} check added for \cs{noindent}. latex/2414}
% If |\noindent| was used after |\item| want to cancel the |\itemindent|
% skip. This case can be detected as the indentation box will be void.
%    \begin{macrocode}
      {\setbox\z@\lastbox
       \ifvoid\z@
         \kern-\itemindent
       \fi}%
%    \end{macrocode}
%
%    \begin{macrocode}
      \box\@labels
      \penalty\z@
    \fi
%    \end{macrocode}
%    This code is intended to prevent a page break after the first
%    line of an item that comes immediately after a section title. It
%    may be sensible to always forbid a page break after one line of
%    an item?  As with all such settings of |\clubpenalty| it is local
%    so will have no effect if the item starts in a group.
%
%    Only resetting |\@nobreak| when it is true is now
%    essential since now it is sometimes set locally.
% \changes{v1.0m}{1996/10/23}{Added setting of \cs{clubpenalty} and
%    set \cs{@nobreakfalse} only when necessary}
%    \begin{macrocode}
    \if@nobreak
      \@nobreakfalse
      \clubpenalty \@M
    \else
      \clubpenalty \@clubpenalty
      \everypar{}%
    \fi}%
%    \end{macrocode}
% \changes{v1.0l}{1996/07/26}{Remove unecessary \cs{global} before
%                 \cs{@nobreak...}}
% \changes{v1.0m}{1996/10/23}{\cs{@nobreak...} moved into the
%          \cs{everypar} and not executed unconditionally, see above}
%    \begin{macrocode}
  \if@noitemarg
    \@noitemargfalse
    \if@nmbrlist
%    \end{macrocode}
% \changes{v1.0g}{1995/05/17}{Removed surplus braces}
%    \begin{macrocode}
      \refstepcounter\@listctr
    \fi
  \fi
%    \end{macrocode}
%    We use |\sbox| to support colour commands.
% \changes{LaTeX2e}{1993/12/08}{use \cs{sbox} to support colour}
%    \begin{macrocode}
  \sbox\@tempboxa{\makelabel{#1}}%
  \global\setbox\@labels\hbox{%
    \unhbox\@labels
    \hskip \itemindent
    \hskip -\labelwidth
    \hskip -\labelsep
    \ifdim \wd\@tempboxa >\labelwidth
      \box\@tempboxa
%    \end{macrocode}
% \changes{LaTeX2.09}{1991/11/22}
%         {(RmS) Changed second call to \cs{makelabel} to
%           \cs{unhbox}\cs{@tempboxa}.
%          Avoids problems with side effects in \cs{makelabel} and is
%               more efficient.}
%    \begin{macrocode}
    \else
      \hbox to\labelwidth {\unhbox\@tempboxa}%
    \fi
    \hskip \labelsep}%
  \ignorespaces}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\makelabel}
% \changes{LaTeX2.09}{1991/11/04}
%         {(RmS) added default definition for \cs{makelabel},
%               to produce an error message.}
%    \begin{macrocode}
\def\makelabel#1{%
  \@latex@error{Lonely \string\item--perhaps a missing
        list environment}\@ehc}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@nbitem}
% \changes{v1.0g}{1995/05/17}{Removed surplus braces}
%    \begin{macrocode}
\def\@nbitem{%
  \@tempskipa\@outerparskip
  \advance\@tempskipa -\parskip
  \addvspace\@tempskipa}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\usecounter}
%    \begin{macrocode}
\def\usecounter#1{\@nmbrlisttrue\def\@listctr{#1}\setcounter{#1}\z@}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Itemize and Enumerate}
%
%  Enumeration is done with four counters: |enumi|, |enumii|, |enumiii|
%  and |enumiv|, where |enum|N controls the numbering of the Nth level
%  enumeration.  The label is generated by the commands
%  \cs{labelenumi} \ldots{} \cs{labelenumiv}, which should be defined
%  by the document style.
%  Note that \cs{p@enum}N\cs{theenum}N defines the output
%  of a \cs{ref} command.  A typical definition might be:
% \begin{verbatim}
%     \def\theenumii{\alph{enumii}}
%     \def\p@enumii{\theenumi}
%     \def\labelenumii{(\theenumii)}
% \end{verbatim}
% which will print the labels as `(a)', `(b)', \ldots
% and print a \cs{ref} as `3a'.
%
% The item numbers are moved to the right of the label box, so they are
% always a distance of \cs{labelsep} from the item.
%
% \cs{@enumdepth} holds the current enumeration nesting depth.
%
% Itemization is controlled by four commands: \cs{labelitemi},
% \cs{labelitemii},
% \cs{labelitemiii}, and \cs{labelitemiv}.
% To cause the second-level list to be
% bulleted, you just define \cs{labelitemii}
% to be $\bullet$.  \cs{@itemspacing}
% and \cs{@itemdepth} are the analogs of \cs{@enumspacing} and
% \cs{@enumdepth}.
%
% \begin{oldcomments}
% \enumerate ==
%   BEGIN
%     if \@enumdepth > 3
%       then errormessage: ``Too deeply nested''.
%       else \@enumdepth :=L \@enumdepth + 1
%            \@enumctr :=L eval(enum@\romannumeral\the\@enumdepth)
%            \list{\label(\@enumctr)}
%                 {\usecounter{\@enumctr}
%                  \makelabel{LABEL} ==  \hss \llap{LABEL}}
%     fi
%   END
%
% \endenumerate == \endlist
% \end{oldcomments}
%
% \begin{macro}{\@enumdepth}
%    \begin{macrocode}
\newcount\@enumdepth \@enumdepth = 0
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\c@enumi}
% \begin{macro}{\c@enumii}
% \begin{macro}{\c@enumii}
% \begin{macro}{\c@enumiv}
%    \begin{macrocode}
\@definecounter{enumi}
\@definecounter{enumii}
\@definecounter{enumiii}
\@definecounter{enumiv}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{environment}{enumerate}
% \changes{v1.0g}{1995/05/17}{Use \cs{thr@@} and remove surplus braces}
%    \begin{macrocode}
\def\enumerate{%
  \ifnum \@enumdepth >\thr@@\@toodeep\else
    \advance\@enumdepth\@ne
    \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
%    \end{macrocode}
%
% \changes{v1.0j}{1995/07/09}{Use \cs{expandafter}}
%    \begin{macrocode}
      \expandafter
      \list
        \csname label\@enumctr\endcsname
        {\usecounter\@enumctr\def\makelabel##1{\hss\llap{##1}}}%
  \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\let\endenumerate =\endlist
%    \end{macrocode}
% \end{environment}
%
%
% \begin{oldcomments}
%  \itemize ==
%    BEGIN
%      if \@itemdepth > 3
%        then  errormessage: 'Too deeply nested'.
%        else \@itemdepth :=L \@itemdepth + 1
%             \@itemitem  == eval(labelitem\romannumeral\the\@itemdepth)
%             \list{\@nameuse{\@itemitem}}
%                   {\makelabel{LABEL} ==  \hss \llap{LABEL}}
%      fi
%    END
%
%  \enditemize ==  \endlist
%
% \end{oldcomments}
%
% \begin{macro}{\@itemdepth}
%    \begin{macrocode}
\newcount\@itemdepth \@itemdepth = 0
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{itemize}
% \changes{v1.0g}{1995/05/17}{Use \cs{thr@@}}
%    \begin{macrocode}
\def\itemize{%
  \ifnum \@itemdepth >\thr@@\@toodeep\else
    \advance\@itemdepth\@ne
    \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
%    \end{macrocode}
%
% \changes{v1.0j}{1995/07/09}{Use \cs{expandafter}}
%    \begin{macrocode}
    \expandafter
    \list
      \csname\@itemitem\endcsname
      {\def\makelabel##1{\hss\llap{##1}}}%
  \fi}
%    \end{macrocode}
%
%    \begin{macrocode}
\let\enditemize =\endlist
%</2ekernel>
%    \end{macrocode}
% \end{environment}
%
% \Finale
%