forked from katyhuff/CV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
enumitem.sty
1593 lines (1359 loc) · 41.7 KB
/
enumitem.sty
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
% +--------------------------------------------------+
% | Typeset enumitem.tex to get the documentation. |
% +--------------------------------------------------+
%
% Copyright (c) 2003-2011 by Javier Bezos.
% All Rights Reserved.
%
% This file is part of the enumitem distribution release 3.5.2
% -----------------------------------------------------------
%
% It may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2003/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work is Javier Bezos.
%
% Notes
% ~~~~~
%
% The tag enit@ is used through the style
%
% To do:
% ~~~~~~
% - ref*, for adding stuff in the same fashion as label*
% - option ams, to force upshape, but I have to investigate
% how to do it.
% - labelled descriptions (ie, label, title, body)
% - A true nextline (far from trivial and perhaps solved with
% labelled descriptions).
% - Improved \AddEnumerateCounter
% - Compatibility with interfaces and zref-enumitem
% - "Pausing" somehow inline boxed text.
% - \@enumctr <-> \@listctr?
% - Define keys with values
% - Revise @nobreak
%
% Release
% ~~~~~~~
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{enumitem}[2011/09/28 v3.5.2 Customized lists]
% +=============================+
% | EMULATING KEYVAL |
% +=============================+
%
% "Thanks" to xkeyval, which use the same macros names as
% keyval :-(, the latter has to be replicated in full here
% to ensure it works as intended. The original work if by
% David Carlisle, under license LPPL. Once the code is here,
% it could be optimized by adpting it to the specific needs
% of titlesec (to do).
\def\enitkv@setkeys#1#2{%
\def\enitkv@prefix{enitkv@#1@}%
\let\@tempc\relax
\enitkv@do#2,\relax,}
\def\enitkv@do#1,{%
\ifx\relax#1\empty\else
\enitkv@split#1==\relax
\expandafter\enitkv@do\fi}
\def\enitkv@split#1=#2=#3\relax{%
\enitkv@@sp@def\@tempa{#1}%
\ifx\@tempa\@empty\else
\expandafter\let\expandafter\@tempc
\csname\enitkv@prefix\@tempa\endcsname
\ifx\@tempc\relax
\enitkv@errx{\@tempa\space undefined}%
\else
\ifx\@empty#3\@empty
\enitkv@default
\else
\enitkv@@sp@def\@tempb{#2}%
\expandafter\@tempc\expandafter{\@tempb}\relax
\fi
\fi
\fi}
\def\enitkv@default{%
\expandafter\let\expandafter\@tempb
\csname\enitkv@prefix\@tempa @default\endcsname
\ifx\@tempb\relax
\enitkv@err{No value specified for \@tempa}%
\else
\@tempb\relax
\fi}
\def\enitkv@errx#1{\enit@error{#1}\@ehc}
\let\enitkv@err\enitkv@errx
\def\@tempa#1{%
\def\enitkv@@sp@def##1##2{%
\futurelet\enitkv@tempa\enitkv@@sp@d##2\@nil\@nil#1\@nil\relax##1}%
\def\enitkv@@sp@d{%
\ifx\enitkv@tempa\@sptoken
\expandafter\enitkv@@sp@b
\else
\expandafter\enitkv@@sp@b\expandafter#1%
\fi}%
\def\enitkv@@sp@b#1##1 \@nil{\enitkv@@sp@c##1}}
\@tempa{ }
\def\enitkv@@sp@c#1\@nil#2\relax#3{\enitkv@toks@{#1}\edef#3{\the\enitkv@toks@}}
\@ifundefined{KV@toks@}
{\newtoks\enitkv@toks@}
{\let\enitkv@toks@\KV@toks@}
\def\enitkv@key#1#2{%
\@ifnextchar[{\enitkv@def{#1}{#2}}{\@namedef{enitkv@#1@#2}####1}}
\def\enitkv@def#1#2[#3]{%
\@namedef{enitkv@#1@#2@default\expandafter}\expandafter
{\csname enitkv@#1@#2\endcsname{#3}}%
\@namedef{enitkv@#1@#2}##1}
% +=============================+
% | DEFINITIONS |
% +=============================+
%
% (1) The package uses a token register very often. To be on the
% safe side, instead of \toks@, etc., a new one is declared.
% (2) \enit@inbox is the box storing the items in boxed inline
% lists.
% (3) \enit@outerparindent is used to save the outer parindent
% so that it can be used in the key parindent
% (4) \enit@type has three values: 0 = enum, 1 = item, 2 = desc.
% (5) \enit@calc stores which dimen is to be computed:
% 0=labelindent, 1=labelwidth, 2=labelsep, 3=leftmargin,
% 4=itemindent
% (6) \enit@resuming has four values: 0 = none, 1 = series,
% 2 = resume* series (computed in group enumitem-resume),
% 3 = resume* list (ie, with no value).
\chardef \enit@iv=4
\newlength\labelindent
\newdimen \enit@outerparindent
\newtoks \enit@toks
\newbox \enit@inbox
\newif\ifenit@boxmode
\newif\ifenit@sepfrommargin
\newif\ifenit@lblfrommargin
\newif\ifenit@calcwidest
\newif\ifenit@nextline
\newif\ifenit@boxdesc
% An alias (calc-savvy):
\let\c@enit@cnt\@tempcnta
\def\enit@meaning{\expandafter\strip@prefix\meaning}
\def\enit@noexcs#1{\expandafter\noexpand\csname#1\endcsname}
% Miscelaneous errors
% ===================
\def\enit@error{\PackageError{enumitem}}
\def\enit@checkerror#1#2{%
\enit@error{Unknown value `#2' for key `#1'}%
{See the manual for valid values}}
\def\enit@itemerror{%
\enit@error{Misplaced \string\item}%
{Either there is some text before the first\MessageBreak
item or the last item has no text}}
\def\enit@noserieserror#1{%
\enit@error{Series `#1' not started}%
{You are trying to continue a series\MessageBreak
which has not been started with series}}
\def\enit@checkseries#1{%
\ifcase\enit@resuming
\enit@error{Misplaced key `#1'}%
{`series' and `resume*' must be used\MessageBreak
in the optional argument of lists}%
\fi}
\def\enit@checkseries@m{%
\ifcase\enit@resuming\else
\enit@error{Uncompatible series settings}%
{`series' and `resume*' must not be used\MessageBreak
at the same time}%
\fi}
\let\enit@toodeep\@toodeep
\def\@toodeep{%
\ifnum\@listdepth>\enit@listdepth\relax
\enit@toodeep
\else
\count@\@listdepth
\global\advance\@listdepth\@ne
\@ifundefined{@list\romannumeral\the\@listdepth}%
{\expandafter\let
\csname @list\romannumeral\the\@listdepth\expandafter\endcsname
\csname @list\romannumeral\the\count@\endcsname}{}%
\fi}
% +=============================+
% | KEYS |
% +=============================+
%
% Including code executed by keys.
%
% There are 2 keyval groups: enumitem, and enumitem-delayed.
% The latter is used to make sure a prioritary key is the
% latest one; eg, ref, so that the ref format set by label
% is overriden. So, when this key is found in enumitem,
% nothing is done, except the key/value is moved to
% enumitem-delayed.
%
% A further group (enumitem-resume) catches resume* and
% series in optional arguments in lists.
%
% Vertical spacing
% ================
\enitkv@key{enumitem}{topsep}{%
\setlength\topsep{#1}}
\enitkv@key{enumitem}{itemsep}{%
\setlength\itemsep{#1}}
\enitkv@key{enumitem}{parsep}{%
\setlength\parsep{#1}}
\enitkv@key{enumitem}{partopsep}{%
\setlength\partopsep{#1}}
% Horizontal spacing
% ==================
%
% There are 3 cases: *, ! and a value. The latter also
% cancels widest with the sequence key=* ... key=value
% \string is used, just in case some package changes the
% catcodes.
\def\enit@calcset#1#2#3{%
\if\string*\string#3%
\enit@calcwidesttrue
\let\enit@calc#2%
\else\if\string!\string#3%
\enit@calcwidestfalse
\let\enit@calc#2%
\else
\ifnum\enit@calc=#2%
\enit@calcwidestfalse
\let\enit@calc\z@
\fi
\setlength#1{#3}%
\fi\fi}
\def\enitkv@enumitem@widest#1{%
\expandafter\let\csname enit@cw@\@enumctr\endcsname\relax
\@namedef{enit@widest@\@enumctr}##1{#1}}
\def\enitkv@enumitem@widest@default{%
\expandafter\let\csname enit@cw@\@enumctr\endcsname\relax
\expandafter\let\csname enit@widest@\@enumctr\endcsname\relax}
\enitkv@key{enumitem}{widest*}{%
\setcounter{enit@cnt}{#1}%
\expandafter\edef\csname enit@cw@\@enumctr\endcsname
{\the\c@enit@cnt}%
\expandafter\edef\csname enit@widest@\@enumctr\endcsname##1%
{##1{\the\c@enit@cnt}}}
\enitkv@key{enumitem}{labelindent*}{%
\enit@lblfrommargintrue
\ifnum\enit@calc=\z@
\enit@calcwidestfalse
\fi
\setlength\labelindent{#1}%
\advance\labelindent\leftmargin}
\enitkv@key{enumitem}{labelindent}{%
\enit@lblfrommarginfalse
\enit@calcset\labelindent\z@{#1}}
\enitkv@key{enumitem}{labelwidth}{%
\enit@calcset\labelwidth\@ne{#1}}
\enitkv@key{enumitem}{leftmargin}{%
\edef\enit@c{\the\leftmargin}%
\enit@calcset\leftmargin\thr@@{#1}%
\ifenit@lblfrommargin
\advance\labelindent-\enit@c\relax
\advance\labelindent\leftmargin
\fi}
\enitkv@key{enumitem}{itemindent}{%
\edef\enit@c{\the\itemindent}%
\enit@calcset\itemindent\enit@iv{#1}%
\ifenit@sepfrommargin
\advance\labelsep-\enit@c\relax
\advance\labelsep\itemindent
\fi}
\enitkv@key{enumitem}{listparindent}{%
\setlength\listparindent{#1}}
\enitkv@key{enumitem}{rightmargin}{%
\setlength\rightmargin{#1}}
% labelsep, from itemindent; labelsep*, from leftmargin
\enitkv@key{enumitem}{labelsep*}{%
\enit@sepfrommargintrue
\ifnum\enit@calc=\tw@
\enit@calcwidestfalse
\let\enit@calc\z@
\fi
\setlength\labelsep{#1}%
\advance\labelsep\itemindent}
\enitkv@key{enumitem}{labelsep}{%
\enit@sepfrommarginfalse
\enit@calcset\labelsep\tw@{#1}}
% Series, resume and start
% ========================
\enitkv@key{enumitem-resume}{series}{%
\enit@checkseries@m
\let\enit@resuming\@ne
\@ifundefined{enitkv@enumitem@#1}{}%
{\enit@error{Invalid series name `#1'}%
{Do not name a series with an existing key}}%
\def\enit@series{#1}}
\enitkv@key{enumitem}{series}{%
\enit@checkseries{series}}
\def\enitkv@enumitem@resume#1{%
\edef\enit@series{#1}%
\@nameuse{enit@resume@series@#1}\relax}
\def\enitkv@enumitem@resume@default{%
\@nameuse{enit@resume@\@currenvir}\relax}
\@namedef{enitkv@enumitem-resume@resume*}#1{%
\enit@checkseries@m
\let\enit@resuming\tw@
\edef\enit@series{#1}%
\@ifundefined{enit@resumekeys@series@#1}%
{\enit@noserieserror{#1}}%
{\expandafter\let\expandafter\enit@resumekeys
\csname enit@resumekeys@series@#1\endcsname}}
\@namedef{enitkv@enumitem-resume@resume*@default}{%
\let\enit@resuming\thr@@
\expandafter\let\expandafter\enit@resumekeys
\csname enit@resumekeys@\@currenvir\endcsname
\@nameuse{enit@resume@\@currenvir}\relax}
\enitkv@key{enumitem}{resume*}[]{%
\enit@checkseries{resume*}}
\newcommand\restartlist[1]{%
\@ifundefined{end#1}%
{\enit@error{Undefined list `#1'}%
{No list has been defined with that name.}}%
{\expandafter\let
\csname enit@resume@#1\endcsname\@empty}}
\enitkv@key{enumitem}{start}[\@ne]{%
\setcounter{\@listctr}{#1}%
\advance\@nameuse{c@\@listctr}\m@ne}
% Penalties
% =========
\enitkv@key{enumitem}{beginpenalty}{%
\@beginparpenalty#1\relax}
\enitkv@key{enumitem}{midpenalty}{%
\@itempenalty#1\relax}
\enitkv@key{enumitem}{endpenalty}{%
\@endparpenalty#1\relax}
% Font/Format
% ===========
\enitkv@key{enumitem}{format}{%
\def\enit@format{#1}}
\enitkv@key{enumitem}{font}{%
\def\enit@format{#1}}
% Description styles
% ==================
\enitkv@key{enumitem}{style}[normal]{%
\@ifundefined{enit@style@#1}%
{\enit@checkerror{style}{#1}}%
{\enit@nextlinefalse
\enit@boxdescfalse
\@nameuse{enit@style@#1}%
\edef\enit@descstyle{\enit@noexcs{enit@#1style}}}}
\def\enit@style@standard{%
\enit@boxdesctrue
\enit@calcset\itemindent\enit@iv!}
\let\enit@style@normal\enit@style@standard
\def\enit@style@unboxed{%
\enit@calcset\itemindent\enit@iv!}
\def\enit@style@sameline{%
\enit@calcset\labelwidth\@ne!}
\def\enit@style@multiline{%
\enit@align@parleft
\enit@calcset\labelwidth\@ne!}
\def\enit@style@nextline{%
\enit@nextlinetrue
\enit@calcset\labelwidth\@ne!}
% Labels and refs
% ===============
% Aligment
% --------
\enitkv@key{enumitem}{align}{%
\@ifundefined{enit@align@#1}%
{\enit@checkerror{align}{#1}}%
{\csname enit@align@#1\endcsname}}
% \nobreak for unboxed label with color. See below.
\newcommand\SetLabelAlign[2]{%
\enit@toks{#2}%
\expandafter\edef\csname enit@align@#1\endcsname
{\def\noexpand\enit@align####1{\nobreak\the\enit@toks}}}
\def\enit@align@right{%
\def\enit@align##1{\nobreak\hss\llap{##1}}}
\def\enit@align@left{%
\def\enit@align##1{\nobreak##1\hfil}}
\def\enit@align@parleft{%
\def\enit@align##1{%
\nobreak
\strut\smash{\parbox[t]\labelwidth{\raggedright##1}}}}
% \enit@ref has three possible definitions:
% (1) \relax, if there is neither label nor ref (ie, use
% LaTeX settings).
% (2) set ref to @itemlabel, if there is label but not ref
% (3) set ref to ref, if there is ref (with or without label)
\enitkv@key{enumitem}{label}{%
\expandafter\def\@itemlabel{#1}%
\def\enit@ref{\expandafter\enit@reflabel\@itemlabel\z@}}
\enitkv@key{enumitem}{label*}{%
\ifnum\enit@depth=\@ne
\expandafter\def\@itemlabel{#1}%
\else % no level 0
\advance\enit@depth\m@ne
\enit@toks{#1}%
\expandafter\edef\@itemlabel{%
\enit@noexcs{label\enit@prevlabel}%
\the\enit@toks}%
\advance\enit@depth\@ne
\fi
\def\enit@ref{\expandafter\enit@reflabel\@itemlabel\z@}}
% ref is set by label, except if there is an explicit ref
% in the same hierarchy level. Explicit refs above the
% current hierarchy level are overriden by label (besides ref),
% too. Since an explicit ref has preference, it's delayed.
\enitkv@key{enumitem}{ref}{%
\g@addto@macro\enit@delayedkeys{,ref=#1}}
\enitkv@key{enumitem-delayed}{ref}{%
\def\enit@ref{\enit@reflabel{#1}\@ne}}
% #2=0 don't "normalize" (ie, already normalized)
% =1 "normalize" (in key ref)
% Used thru \enit@ref
\def\enit@reflabel#1#2{%
\ifnum\enit@depth=\@ne\else % no level 0
\advance\enit@depth\@ne
\@namedef{p@\@enumctr}{}% Don't accumulate labels
\advance\enit@depth\m@ne
\fi
\ifcase#2%
\@namedef{the\@enumctr}{{#1}}%
\else
\enit@normlabel{\csname the\@enumctr\endcsname}{#1}%
\fi}
% \xxx* in counters (refstar) and widest (calcdef)
% ------------------------------------------------
% \enit@labellist contains a list of
% \enit@elt{widest}\count\@count\enit@sc@@count
% \enit@elt is either \enit@getwidth or \enit@refstar, defined
% below
% The current implementation is sub-optimal -- labels are stored in
% labellist, counters defined again when processing labels, and
% modifying it is almost impossible.
\let\enit@labellist\@empty
\newcommand\AddEnumerateCounter{%
\@ifstar\enit@addcounter@s\enit@addcounter}
\def\enit@addcounter#1#2#3{%
\enit@toks\expandafter{%
\enit@labellist
\enit@elt{#3}}%
\edef\enit@labellist{%
\the\enit@toks
\enit@noexcs{\expandafter\@gobble\string#1}%
\enit@noexcs{\expandafter\@gobble\string#2}%
\enit@noexcs{enit@sc@\expandafter\@gobble\string#2}}}
\def\enit@addcounter@s#1#2#3{%
\enit@addcounter{#1}{#2}%
{\@nameuse{enit@sc@\expandafter\@gobble\string#2}{#3}}}
% The 5 basic counters:
\AddEnumerateCounter\arabic\@arabic{0}
\AddEnumerateCounter\alph\@alph{m}
\AddEnumerateCounter\Alph\@Alph{M}
\AddEnumerateCounter\roman\@roman{viii}
\AddEnumerateCounter\Roman\@Roman{VIII}
% Inline lists
% ============
%
% Labels
% ------
\enitkv@key{enumitem}{itemjoin}{%
\def\enit@itemjoin{#1}}
\enitkv@key{enumitem}{itemjoin*}{%
\def\enit@itemjoin@s{#1}}
\enitkv@key{enumitem}{afterlabel}{%
\def\enit@afterlabel{#1}}
% Mode
% ----
\enitkv@key{enumitem}{mode}{%
\@ifundefined{enit@mode#1}%
{\enit@checkerror{mode}{#1}}%
{\csname enit@mode#1\endcsname}}
\let\enit@modeboxed\enit@boxmodetrue
\let\enit@modeunboxed\enit@boxmodefalse
% Short Labels
% ============
\let\enit@marklist\@empty
% shorthand, expansion:
\newcommand\SetEnumerateShortLabel[2]{%
\let\enit@a\@empty
\def\enit@elt##1##2{%
\def\enit@b{#1}\def\enit@c{##1}%
\ifx\enit@b\enit@c\else
\expandafter\def\expandafter\enit@a\expandafter{%
\enit@a
\enit@elt{##1}{##2}}%
\fi}%
\enit@marklist
\expandafter\def\expandafter\enit@a\expandafter{%
\enit@a
\enit@elt{#1}{#2}}%
\let\enit@marklist\enit@a}
\SetEnumerateShortLabel{a}{\alph*}
\SetEnumerateShortLabel{A}{\Alph*}
\SetEnumerateShortLabel{i}{\roman*}
\SetEnumerateShortLabel{I}{\Roman*}
\SetEnumerateShortLabel{1}{\arabic*}
% This is called \enit@first one,two,three,\@nil\@@nil. If there
% are just one element #2 is \@nil, otherwise we have to remove
% the trailing ,\@nil with enit@first@x
% Called with the keys in \enit@c
% Returns enit@toks
\def\enit@first#1,#2\@@nil{%
\in@{=}{#1}% Quick test, if contains =, it's key=value
\ifin@\else
\enitkv@@sp@def\enit@a{#1}%
\@ifundefined{enitkv@enumitem@\enit@meaning\enit@a}%
{\ifnum\enit@type=\z@
\def\enit@elt{\enit@replace\enit@a}%
\enit@marklist % Returns \enit@toks
\else
\enit@toks{#1}%
\fi
\ifx\@nil#2%
\ifx,#1,\else
\edef\enit@c{label=\the\enit@toks}%
\fi
\else
\@temptokena\expandafter{\enit@first@x#2}%
\edef\enit@c{label=\the\enit@toks,\the\@temptokena}%
\fi}%
{}%
\fi
\enit@toks\expandafter{\enit@c}}
\def\enit@first@x#1,\@nil{#1}
\def\enit@replace#1#2#3{%
\enit@toks{}%
\def\enit@b##1#2##2\@@nil{%
\ifx\@nil##2%
\addto@hook\enit@toks{##1}%
\else
\edef\enit@a{\the\enit@toks}%
\ifx\enit@a\@empty\else
\enit@error{Extra short label ignored}%
{There are more than one short label}%
\fi
\addto@hook\enit@toks{##1#3}%
\enit@b##2\@@nil
\fi}%
\expandafter\enit@b#1#2\@nil\@@nil
\edef#1{\the\enit@toks}}
% Pre and post code
% =================
\enitkv@key{enumitem}{before}{%
\def\enit@before{#1}}
\enitkv@key{enumitem}{after}{%
\def\enit@after{#1}}
\enitkv@key{enumitem}{before*}{%
\expandafter\def\expandafter\enit@before\expandafter
{\enit@before#1}}
\enitkv@key{enumitem}{after*}{%
\expandafter\def\expandafter\enit@after\expandafter
{\enit@after#1}}
% Miscelaneous keys
% ================
\enitkv@key{enumitem}{nolistsep}[true]{%
\partopsep=\z@skip
\topsep=\z@ plus .1pt
\itemsep=\z@skip
\parsep=\z@skip}
\enitkv@key{enumitem}{nosep}[true]{%
\partopsep=\z@skip
\topsep=\z@skip
\itemsep=\z@skip
\parsep=\z@skip}
\enitkv@key{enumitem}{noitemsep}[true]{%
\itemsep=\z@skip
\parsep=\z@skip}
\enitkv@key{enumitem}{wide}[\parindent]{%
\enit@align@left
\leftmargin\z@
\labelwidth\z@
\setlength\labelindent{#1}%
\listparindent\labelindent
\enit@calcset\itemindent\enit@iv!}
% The following is deprecated in favour of wide:
\enitkv@key{enumitem}{fullwidth}[true]{%
\leftmargin\z@
\labelwidth\z@
\def\enit@align##1{\hskip\labelsep##1}}
% "Abstract" layer
% ================
%
% Named values
% ------------
\newcommand\SetEnumitemValue[2]{% Implicit #3
\@ifundefined{enit@enitkv@#1}%
{\@ifundefined{enitkv@enumitem@#1}%
{\enit@error{Wrong key `#1' in \string\SetEnumitemValue}%
{Perhaps you have misspelled it}}{}%
\expandafter\let\csname enit@enitkv@#1\expandafter\endcsname
\csname enitkv@enumitem@#1\endcsname}{}%
\@namedef{enitkv@enumitem@#1}##1{%
\def\enit@a{##1}%
\@ifundefined{enit@enitkv@#1@\enit@meaning\enit@a}%
{\@nameuse{enit@enitkv@#1}{##1}}%
{\@nameuse{enit@enitkv@#1\expandafter\expandafter\expandafter}%
\expandafter\expandafter\expandafter
{\csname enit@enitkv@#1@##1\endcsname}}{}}%
\@namedef{enit@enitkv@#1@#2}}
% Defining keys
% -------------
\newcommand\SetEnumitemKey[2]{%
\@ifundefined{enitkv@enumitem@#1}%
{\enitkv@key{enumitem}{#1}[]{\enitkv@setkeys{enumitem}{#2}}}%
{\enit@error{Duplicated key `#1' in \string\SetEnumitemKey}%
{There already exists a key with that name}}}
% +=============================+
% | PROCESSING KEYS |
% +=============================+
%
% Set keys
% ========
\def\enit@setkeys#1{%
\@ifundefined{enit@@#1}{}%
{\expandafter\expandafter\expandafter
\enit@setkeys@i\csname enit@@#1\endcsname\@@}}
% The following is used directly in resumeset:
\def\enit@setkeys@i#1\@@{%
\let\enit@delayedkeys\@empty
\enit@shl{#1}% is or returns \enit@toks
\expandafter\enit@setkeys@ii\the\enit@toks\@@}
\def\enit@setkeys@ii#1\@@{%
\enitkv@setkeys{enumitem}{#1}%
\enit@toks\expandafter{\enit@delayedkeys}%
\edef\enit@a{%
\noexpand\enitkv@setkeys{enumitem-delayed}{\the\enit@toks}}%
\enit@a}
% Handling * and ! values
% =======================
%
% \@gobbletwo removes \c from \c@counter.
\def\enit@getwidth#1#2#3#4{%
\let#4#3%
\def#3##1{%
\@ifundefined{enit@widest\expandafter\@gobbletwo\string##1}% if no widest=key
{#1}%
{\csname enit@widest\expandafter\@gobbletwo\string##1\endcsname{#4}}}}
\def\enit@valueerror#1{\z@ % if after an assignment, but doesn't catch \ifnum
\enit@error{No default \string\value\space for `#1'}%
{You can provide one with widest*}}%
\let\enit@values\@empty
\def\enit@calcwidth{%
\ifenit@calcwidest
\ifnum\enit@type=\z@ % ie, enum
\@ifundefined{enit@cw@\@enumctr}%
{\@namedef{enit@cv@\@enumctr}{\enit@valueerror\@enumctr}}%
{\edef\enit@values{%
\enit@values
\@nameuse{c@\@enumctr}\@nameuse{enit@cw@\@enumctr}\relax}%
\expandafter
\edef\csname enit@cv@\@enumctr\endcsname
{\@nameuse{c@\@enumctr}}}%
\fi
\begingroup
\enit@values
\def\value##1{\csname enit@cv@##1\endcsname}%
\let\enit@elt\enit@getwidth
\enit@labellist
\settowidth\labelwidth{\@itemlabel}%
\xdef\enit@a{\labelwidth\the\labelwidth\relax}%
\endgroup
\enit@a
\fi
\advance\dimen@-\labelwidth}
\def\enit@calcleft{%
\dimen@\leftmargin
\advance\dimen@\itemindent
\advance\dimen@-\labelsep
\advance\dimen@-\labelindent
\ifcase\enit@calc % = 0 = labelindent
\enit@calcwidth
\advance\labelindent\dimen@
\or % = 1 = labelwidth, so no \enit@calcwidth
\labelwidth\dimen@
\or % = 2 = labelsep
\enit@calcwidth
\advance\labelsep\dimen@
\or % = 3 = leftmargin
\enit@calcwidth
\advance\leftmargin-\dimen@
\or % = 4 =itemindent
\enit@calcwidth
\advance\itemindent-\dimen@
\fi}
% "Normalizing" labels
% ====================
%
% Replaces \counter* by \counter{level} (those in \enit@labellist).
%
% #1 is either \csname...\endcsmame or the container \@itemlabel --
% hence \expandafter
\def\enit@refstar@i#1#2{%
\if*#2\@empty
\noexpand#1{\@enumctr}%
\else
\noexpand#1{#2}%
\fi}%
\def\enit@refstar#1#2#3#4{%
\def#2{\enit@refstar@i#2}%
\def#3{\enit@refstar@i#3}}
\def\enit@normlabel#1#2{%
\begingroup
\def\value{\enit@refstar@i\value}%
\let\enit@elt\enit@refstar
\enit@labellist
\protected@xdef\enit@a{{#2}}% Added braces as \ref is in the
\endgroup
\expandafter\let#1\enit@a} % global scope.
% Preliminary settings and default values
% =======================================
\def\enit@prelist#1#2#3{%
\let\enit@type#1%
\def\enit@depth{#2}%
\edef\enit@prevlabel{#3\romannumeral#2}%
\advance#2\@ne}
\def\enit@preset#1#2#3{%
\enit@sepfrommarginfalse
\enit@calcwidestfalse
\let\enit@resuming\z@
\let\enit@series\relax
\enit@boxmodetrue
\def\enit@itemjoin{ }%
\let\enit@itemjoin@s\relax
\let\enit@afterlabel\nobreakspace
\let\enit@before\@empty
\let\enit@after\@empty
\let\enit@format\@firstofone % and NOT empty
\let\enit@ref\relax
\labelindent\z@skip
\ifnum\@listdepth=\@ne
\enit@outerparindent\parindent
\else
\parindent\enit@outerparindent
\fi
\enit@setkeys{list}%
\enit@setkeys{list\romannumeral\@listdepth}%
\enit@setkeys{#1}%
\enit@setkeys{#1\romannumeral#2}%
\enit@setresume{#3}}
% keyval "error" in enumitem-resume: all undefined keys (ie, all
% except resume*) are ignored, but <series> is treated like
% resume*=<series>
\def\enitkv@err@a#1{%
\@ifundefined{enit@resumekeys@series@\@tempa}{}%
{\@nameuse{enitkv@enumitem-resume@resume*\expandafter}%
\expandafter{\@tempa}}}
% keyval "error" in the optional argument: all undefined keys are
% passed to the keyval error, but <series> is ignored (already
% processed in enumitem-resume
\def\enitkv@err@b#1{%
\@ifundefined{enit@resumekeys@series@\@tempa}%
{\enit@savekverr{#1}}%
{}}
% Process keys in optional argument:
\def\enit@setresume#1{%
\enit@shl{#1}% Returns enit@toks
\edef\enit@savekeys{\the\enit@toks}%
\let\enit@savekverr\enitkv@errx
\let\enitkv@errx\enitkv@err@a
\edef\enit@b{%
\noexpand\enitkv@setkeys{enumitem-resume}{\the\enit@toks}}%
\enit@b
\let\enitkv@errx\enitkv@err@b
\ifcase\enit@resuming\or\or % = 2
\expandafter
\enit@setkeys@i\enit@resumekeys,resume=\enit@series\@@
\or % = 3
\expandafter
\enit@setkeys@i\enit@resumekeys,resume\@@
\fi
\expandafter\enit@setkeys@i\enit@savekeys\@@
\let\enitkv@errx\enit@savekverr}
% +=============================+
% | LIST TYPES |
% +=============================+
%
% Displayed lists
% ===============
% #1 #2 implicit
\def\enit@dylist{%
\enit@align@right
\list}
\def\enit@endlist{%
\enit@after
\endlist
\ifx\enit@series\relax\else % discards resume*, too
\ifnum\enit@resuming=\@ne % ie, series=
\enit@setresumekeys{series@\enit@series}\global\global
\else % ie, resume=, resume*= (save count, but not keys)
\enit@setresumekeys{series@\enit@series}\@gobblefour\global
\fi
\enit@afterlist
\fi
\ifnum\enit@resuming=\thr@@ % ie, resume* list (save count only)
\enit@setresumekeys\@currenvir\@gobblefour\global
\else
\enit@setresumekeys\@currenvir\@empty\@empty
\fi
\aftergroup\enit@afterlist}
% #1 = either \@currenvir or series@<series>
% #2(keys) #3(counter) are \global, \@gobblefour or \@empty
\def\enit@setresumekeys#1#2#3{%
\enit@toks\expandafter{\enit@savekeys}%
\xdef\enit@afterlist{%
#2\def\enit@noexcs{enit@resumekeys@#1}{\the\enit@toks}%
\ifnum\enit@type=\z@ % ie, enum
#3\def\enit@noexcs{enit@resume@#1}{%
\csname c@\@listctr\endcsname
\the\csname c@\@listctr\endcsname}%
\fi}}
% Inline lists
% ============
% Definition of \@trivlist inside inline lists. So, when
% \@trivlist is found in any displayed list (including quote,
% center, verbatim...) the default \@item is restored.
\def\enit@intrivlist{%
\enit@changed@itemfalse
\let\@item\enit@outer@item
\let\par\@@par
\let\@trivlist\enit@outer@triv
\@trivlist}
% Keep track of \@item and \item changes
\newif\ifenit@changed@item
\enit@changed@itemfalse
\newif\ifenit@changeditem
\enit@changeditemfalse
% List
% ----
% Arguments, as before:
% \enitdp@<name>, <name>, <max-depth>, <format>
% About @newlist, see @initem.
\def\enit@inlist#1#2{%
\ifnum\@listdepth>\enit@listdepth\relax