source: doc/LaTeXmacros/enumitem/enumitem.sty @ 03bb816

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 03bb816 was 9724df0, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

update latex macros, and user and refrat manuals

  • Property mode set to 100644
File size: 41.7 KB
Line 
1% +--------------------------------------------------+
2% | Typeset enumitem.tex to get the documentation.   |
3% +--------------------------------------------------+
4%
5% Copyright (c) 2003-2011 by Javier Bezos.
6% All Rights Reserved.
7%
8% This file is part of the enumitem distribution release 3.5.2
9% -----------------------------------------------------------
10%
11% It may be distributed and/or modified under the
12% conditions of the LaTeX Project Public License, either version 1.3
13% of this license or (at your option) any later version.
14% The latest version of this license is in
15%   http://www.latex-project.org/lppl.txt
16% and version 1.3 or later is part of all distributions of LaTeX
17% version 2003/12/01 or later.
18%
19% This work has the LPPL maintenance status "maintained".
20%
21% The Current Maintainer of this work is Javier Bezos.
22%
23% Notes
24% ~~~~~
25%
26% The tag enit@ is used through the style
27%
28% To do:
29% ~~~~~~
30% - ref*, for adding stuff in the same fashion as label*
31% - option ams, to force upshape, but I have to investigate
32% how to do it.
33% - labelled descriptions (ie, label, title, body)
34% - A true nextline (far from trivial and perhaps solved with
35%   labelled descriptions).
36% - Improved \AddEnumerateCounter
37% - Compatibility with interfaces and zref-enumitem
38% - "Pausing" somehow inline boxed text.
39% - \@enumctr <-> \@listctr?
40% - Define keys with values
41% - Revise @nobreak
42%
43% Release
44% ~~~~~~~
45
46\NeedsTeXFormat{LaTeX2e}
47\ProvidesPackage{enumitem}[2011/09/28 v3.5.2 Customized lists]
48
49% +=============================+
50% |      EMULATING KEYVAL       |
51% +=============================+
52%
53% "Thanks" to xkeyval, which use the same macros names as
54% keyval :-(, the latter has to be replicated in full here
55% to ensure it works as intended. The original work if by
56% David Carlisle, under license LPPL. Once the code is here,
57% it could be optimized by adpting it to the specific needs
58% of titlesec (to do).
59
60\def\enitkv@setkeys#1#2{%
61  \def\enitkv@prefix{enitkv@#1@}%
62  \let\@tempc\relax
63  \enitkv@do#2,\relax,}
64
65\def\enitkv@do#1,{%
66 \ifx\relax#1\empty\else
67  \enitkv@split#1==\relax
68  \expandafter\enitkv@do\fi}
69
70\def\enitkv@split#1=#2=#3\relax{%
71  \enitkv@@sp@def\@tempa{#1}%
72  \ifx\@tempa\@empty\else
73    \expandafter\let\expandafter\@tempc
74      \csname\enitkv@prefix\@tempa\endcsname
75    \ifx\@tempc\relax
76      \enitkv@errx{\@tempa\space undefined}%
77    \else
78      \ifx\@empty#3\@empty
79        \enitkv@default
80      \else
81        \enitkv@@sp@def\@tempb{#2}%
82        \expandafter\@tempc\expandafter{\@tempb}\relax
83      \fi
84    \fi
85  \fi}
86
87\def\enitkv@default{%
88  \expandafter\let\expandafter\@tempb
89    \csname\enitkv@prefix\@tempa @default\endcsname
90  \ifx\@tempb\relax
91    \enitkv@err{No value specified for \@tempa}%
92  \else
93    \@tempb\relax
94  \fi}
95
96\def\enitkv@errx#1{\enit@error{#1}\@ehc}
97
98\let\enitkv@err\enitkv@errx
99
100\def\@tempa#1{%
101  \def\enitkv@@sp@def##1##2{%
102    \futurelet\enitkv@tempa\enitkv@@sp@d##2\@nil\@nil#1\@nil\relax##1}%
103  \def\enitkv@@sp@d{%
104    \ifx\enitkv@tempa\@sptoken
105      \expandafter\enitkv@@sp@b
106    \else
107      \expandafter\enitkv@@sp@b\expandafter#1%
108    \fi}%
109  \def\enitkv@@sp@b#1##1 \@nil{\enitkv@@sp@c##1}}
110
111\@tempa{ }
112
113\def\enitkv@@sp@c#1\@nil#2\relax#3{\enitkv@toks@{#1}\edef#3{\the\enitkv@toks@}}
114
115\@ifundefined{KV@toks@}
116   {\newtoks\enitkv@toks@}
117   {\let\enitkv@toks@\KV@toks@}
118
119\def\enitkv@key#1#2{%
120  \@ifnextchar[{\enitkv@def{#1}{#2}}{\@namedef{enitkv@#1@#2}####1}}
121
122\def\enitkv@def#1#2[#3]{%
123  \@namedef{enitkv@#1@#2@default\expandafter}\expandafter
124    {\csname enitkv@#1@#2\endcsname{#3}}%
125  \@namedef{enitkv@#1@#2}##1}
126
127% +=============================+
128% |        DEFINITIONS          |
129% +=============================+
130%
131% (1) The package uses a token register very often. To be on the
132%   safe side, instead of \toks@, etc., a new one is declared.
133% (2) \enit@inbox is the box storing the items in boxed inline
134%   lists.
135% (3) \enit@outerparindent is used to save the outer parindent
136%   so that it can be used in the key parindent
137% (4) \enit@type has three values: 0 = enum, 1 = item, 2 = desc.
138% (5) \enit@calc stores which dimen is to be computed:
139%   0=labelindent, 1=labelwidth, 2=labelsep, 3=leftmargin,
140%   4=itemindent
141% (6) \enit@resuming has four values: 0 = none, 1 = series,
142%   2 = resume* series (computed in group enumitem-resume),
143%   3 = resume* list (ie, with no value).
144
145\chardef  \enit@iv=4
146\newlength\labelindent
147\newdimen \enit@outerparindent
148\newtoks  \enit@toks
149\newbox   \enit@inbox
150
151\newif\ifenit@boxmode
152\newif\ifenit@sepfrommargin
153\newif\ifenit@lblfrommargin
154\newif\ifenit@calcwidest
155\newif\ifenit@nextline
156\newif\ifenit@boxdesc
157
158% An alias (calc-savvy):
159
160\let\c@enit@cnt\@tempcnta
161
162\def\enit@meaning{\expandafter\strip@prefix\meaning}
163\def\enit@noexcs#1{\expandafter\noexpand\csname#1\endcsname}
164
165% Miscelaneous errors
166% ===================
167
168\def\enit@error{\PackageError{enumitem}}
169 
170\def\enit@checkerror#1#2{%
171  \enit@error{Unknown value `#2' for key `#1'}%
172      {See the manual for valid values}} 
173
174\def\enit@itemerror{%
175  \enit@error{Misplaced \string\item}%
176      {Either there is some text before the first\MessageBreak
177       item or the last item has no text}} 
178
179\def\enit@noserieserror#1{%
180  \enit@error{Series `#1' not started}%
181      {You are trying to continue a series\MessageBreak
182       which has not been started with series}} 
183
184\def\enit@checkseries#1{%
185  \ifcase\enit@resuming
186    \enit@error{Misplaced key `#1'}%
187      {`series' and `resume*' must be used\MessageBreak
188       in the optional argument of lists}%
189  \fi}
190
191\def\enit@checkseries@m{%
192  \ifcase\enit@resuming\else
193    \enit@error{Uncompatible series settings}%
194      {`series' and `resume*' must not be used\MessageBreak
195       at the same time}%
196  \fi}
197
198\let\enit@toodeep\@toodeep
199
200\def\@toodeep{%
201  \ifnum\@listdepth>\enit@listdepth\relax
202    \enit@toodeep
203  \else
204    \count@\@listdepth
205    \global\advance\@listdepth\@ne
206    \@ifundefined{@list\romannumeral\the\@listdepth}%
207      {\expandafter\let
208         \csname @list\romannumeral\the\@listdepth\expandafter\endcsname
209         \csname @list\romannumeral\the\count@\endcsname}{}%
210  \fi}
211
212
213% +=============================+
214% |            KEYS             |
215% +=============================+
216%
217% Including code executed by keys.
218%
219% There are 2 keyval groups: enumitem, and enumitem-delayed.
220% The latter is used to make sure a prioritary key is the
221% latest one; eg, ref, so that the ref format set by label
222% is overriden. So, when this key is found in enumitem,
223% nothing is done, except the key/value is moved to
224% enumitem-delayed.
225%
226% A further group (enumitem-resume) catches resume* and
227% series in optional arguments in lists.
228%
229% Vertical spacing
230% ================
231
232\enitkv@key{enumitem}{topsep}{%
233  \setlength\topsep{#1}}
234
235\enitkv@key{enumitem}{itemsep}{%
236  \setlength\itemsep{#1}}
237
238\enitkv@key{enumitem}{parsep}{%
239  \setlength\parsep{#1}}
240
241\enitkv@key{enumitem}{partopsep}{%
242  \setlength\partopsep{#1}}
243
244% Horizontal spacing
245% ==================
246%
247% There are 3 cases: *, ! and a value. The latter also
248% cancels widest with the sequence key=* ... key=value
249% \string is used, just in case some package changes the
250% catcodes.
251
252\def\enit@calcset#1#2#3{%
253  \if\string*\string#3%
254    \enit@calcwidesttrue
255    \let\enit@calc#2%
256  \else\if\string!\string#3%
257    \enit@calcwidestfalse
258    \let\enit@calc#2%
259  \else
260    \ifnum\enit@calc=#2%
261      \enit@calcwidestfalse
262      \let\enit@calc\z@
263    \fi
264    \setlength#1{#3}%
265  \fi\fi}
266
267\def\enitkv@enumitem@widest#1{%
268  \expandafter\let\csname enit@cw@\@enumctr\endcsname\relax
269  \@namedef{enit@widest@\@enumctr}##1{#1}}
270
271\def\enitkv@enumitem@widest@default{%
272  \expandafter\let\csname enit@cw@\@enumctr\endcsname\relax
273  \expandafter\let\csname enit@widest@\@enumctr\endcsname\relax}
274
275\enitkv@key{enumitem}{widest*}{%
276  \setcounter{enit@cnt}{#1}%
277  \expandafter\edef\csname enit@cw@\@enumctr\endcsname
278    {\the\c@enit@cnt}%
279  \expandafter\edef\csname enit@widest@\@enumctr\endcsname##1%
280    {##1{\the\c@enit@cnt}}}
281
282\enitkv@key{enumitem}{labelindent*}{%
283  \enit@lblfrommargintrue
284  \ifnum\enit@calc=\z@
285    \enit@calcwidestfalse
286  \fi
287  \setlength\labelindent{#1}%
288  \advance\labelindent\leftmargin}
289
290\enitkv@key{enumitem}{labelindent}{%
291  \enit@lblfrommarginfalse
292  \enit@calcset\labelindent\z@{#1}}
293
294\enitkv@key{enumitem}{labelwidth}{%
295  \enit@calcset\labelwidth\@ne{#1}}
296
297\enitkv@key{enumitem}{leftmargin}{%
298  \edef\enit@c{\the\leftmargin}%
299  \enit@calcset\leftmargin\thr@@{#1}%
300  \ifenit@lblfrommargin
301    \advance\labelindent-\enit@c\relax
302    \advance\labelindent\leftmargin
303  \fi}
304
305\enitkv@key{enumitem}{itemindent}{%
306  \edef\enit@c{\the\itemindent}%
307  \enit@calcset\itemindent\enit@iv{#1}%
308  \ifenit@sepfrommargin
309    \advance\labelsep-\enit@c\relax
310    \advance\labelsep\itemindent
311  \fi}
312
313\enitkv@key{enumitem}{listparindent}{%
314  \setlength\listparindent{#1}}
315
316\enitkv@key{enumitem}{rightmargin}{%
317  \setlength\rightmargin{#1}}
318
319% labelsep, from itemindent; labelsep*, from leftmargin
320
321\enitkv@key{enumitem}{labelsep*}{%
322  \enit@sepfrommargintrue
323  \ifnum\enit@calc=\tw@
324    \enit@calcwidestfalse
325    \let\enit@calc\z@
326  \fi
327  \setlength\labelsep{#1}%
328  \advance\labelsep\itemindent}
329
330\enitkv@key{enumitem}{labelsep}{%
331  \enit@sepfrommarginfalse
332  \enit@calcset\labelsep\tw@{#1}}
333
334% Series, resume and start
335% ========================
336
337\enitkv@key{enumitem-resume}{series}{%
338  \enit@checkseries@m
339  \let\enit@resuming\@ne
340  \@ifundefined{enitkv@enumitem@#1}{}%
341    {\enit@error{Invalid series name `#1'}%
342       {Do not name a series with an existing key}}%
343  \def\enit@series{#1}}
344
345\enitkv@key{enumitem}{series}{%
346  \enit@checkseries{series}}
347
348\def\enitkv@enumitem@resume#1{%
349  \edef\enit@series{#1}%
350  \@nameuse{enit@resume@series@#1}\relax}
351
352\def\enitkv@enumitem@resume@default{%
353  \@nameuse{enit@resume@\@currenvir}\relax}
354 
355\@namedef{enitkv@enumitem-resume@resume*}#1{%
356  \enit@checkseries@m
357  \let\enit@resuming\tw@
358  \edef\enit@series{#1}%
359  \@ifundefined{enit@resumekeys@series@#1}%
360    {\enit@noserieserror{#1}}%
361    {\expandafter\let\expandafter\enit@resumekeys
362         \csname enit@resumekeys@series@#1\endcsname}}
363
364\@namedef{enitkv@enumitem-resume@resume*@default}{%
365  \let\enit@resuming\thr@@
366  \expandafter\let\expandafter\enit@resumekeys
367    \csname enit@resumekeys@\@currenvir\endcsname
368  \@nameuse{enit@resume@\@currenvir}\relax}
369
370\enitkv@key{enumitem}{resume*}[]{%
371  \enit@checkseries{resume*}}
372
373\newcommand\restartlist[1]{%
374  \@ifundefined{end#1}%
375    {\enit@error{Undefined list `#1'}%
376      {No list has been defined with that name.}}%
377    {\expandafter\let
378     \csname enit@resume@#1\endcsname\@empty}}
379
380\enitkv@key{enumitem}{start}[\@ne]{%
381  \setcounter{\@listctr}{#1}%
382  \advance\@nameuse{c@\@listctr}\m@ne}
383
384% Penalties
385% =========
386 
387\enitkv@key{enumitem}{beginpenalty}{%
388  \@beginparpenalty#1\relax}
389 
390\enitkv@key{enumitem}{midpenalty}{%
391  \@itempenalty#1\relax}
392
393\enitkv@key{enumitem}{endpenalty}{%
394  \@endparpenalty#1\relax}
395   
396% Font/Format
397% ===========
398
399\enitkv@key{enumitem}{format}{%
400  \def\enit@format{#1}}
401
402\enitkv@key{enumitem}{font}{%
403  \def\enit@format{#1}}
404
405% Description styles
406% ==================
407
408\enitkv@key{enumitem}{style}[normal]{%
409  \@ifundefined{enit@style@#1}%
410    {\enit@checkerror{style}{#1}}%
411    {\enit@nextlinefalse
412     \enit@boxdescfalse
413     \@nameuse{enit@style@#1}%
414     \edef\enit@descstyle{\enit@noexcs{enit@#1style}}}}
415
416\def\enit@style@standard{%
417  \enit@boxdesctrue
418  \enit@calcset\itemindent\enit@iv!}
419
420\let\enit@style@normal\enit@style@standard
421
422\def\enit@style@unboxed{%
423  \enit@calcset\itemindent\enit@iv!}
424
425\def\enit@style@sameline{%
426  \enit@calcset\labelwidth\@ne!}
427
428\def\enit@style@multiline{%
429  \enit@align@parleft
430  \enit@calcset\labelwidth\@ne!}
431
432\def\enit@style@nextline{%
433  \enit@nextlinetrue
434  \enit@calcset\labelwidth\@ne!}
435
436% Labels and refs
437% ===============
438
439% Aligment
440% --------
441
442\enitkv@key{enumitem}{align}{%
443  \@ifundefined{enit@align@#1}%
444    {\enit@checkerror{align}{#1}}%
445    {\csname enit@align@#1\endcsname}}
446
447% \nobreak for unboxed label with color. See below.
448
449\newcommand\SetLabelAlign[2]{%
450  \enit@toks{#2}%
451  \expandafter\edef\csname enit@align@#1\endcsname
452    {\def\noexpand\enit@align####1{\nobreak\the\enit@toks}}}
453
454\def\enit@align@right{%
455  \def\enit@align##1{\nobreak\hss\llap{##1}}}
456
457\def\enit@align@left{%
458  \def\enit@align##1{\nobreak##1\hfil}}
459
460\def\enit@align@parleft{%
461  \def\enit@align##1{%
462    \nobreak
463    \strut\smash{\parbox[t]\labelwidth{\raggedright##1}}}}
464
465% \enit@ref has three possible definitions:
466% (1) \relax, if there is neither label nor ref (ie, use
467%   LaTeX settings).
468% (2) set ref to @itemlabel, if there is label but not ref
469% (3) set ref to ref, if there is ref (with or without label)
470
471\enitkv@key{enumitem}{label}{%
472  \expandafter\def\@itemlabel{#1}%
473  \def\enit@ref{\expandafter\enit@reflabel\@itemlabel\z@}}
474
475\enitkv@key{enumitem}{label*}{%
476  \ifnum\enit@depth=\@ne
477    \expandafter\def\@itemlabel{#1}%
478  \else % no level 0
479    \advance\enit@depth\m@ne
480    \enit@toks{#1}%
481    \expandafter\edef\@itemlabel{%
482      \enit@noexcs{label\enit@prevlabel}%
483      \the\enit@toks}%
484    \advance\enit@depth\@ne 
485  \fi
486  \def\enit@ref{\expandafter\enit@reflabel\@itemlabel\z@}}
487
488% ref is set by label, except if there is an explicit ref
489% in the same hierarchy level. Explicit refs above the
490% current hierarchy level are overriden by label (besides ref),
491% too. Since an explicit ref has preference, it's delayed.
492 
493\enitkv@key{enumitem}{ref}{%
494  \g@addto@macro\enit@delayedkeys{,ref=#1}}
495
496\enitkv@key{enumitem-delayed}{ref}{%
497  \def\enit@ref{\enit@reflabel{#1}\@ne}}
498
499% #2=0 don't "normalize" (ie, already normalized)
500%   =1 "normalize" (in key ref)
501% Used thru \enit@ref
502
503\def\enit@reflabel#1#2{%
504  \ifnum\enit@depth=\@ne\else % no level 0
505    \advance\enit@depth\@ne
506    \@namedef{p@\@enumctr}{}% Don't accumulate labels
507    \advance\enit@depth\m@ne
508  \fi
509  \ifcase#2%
510    \@namedef{the\@enumctr}{{#1}}%
511  \else
512    \enit@normlabel{\csname the\@enumctr\endcsname}{#1}%
513  \fi}
514
515% \xxx* in counters (refstar) and widest (calcdef)
516% ------------------------------------------------
517% \enit@labellist contains a list of
518% \enit@elt{widest}\count\@count\enit@sc@@count
519% \enit@elt is either \enit@getwidth or \enit@refstar, defined
520% below
521% The current implementation is sub-optimal -- labels are stored in
522% labellist, counters defined again when processing labels, and
523% modifying it is almost impossible.
524
525\let\enit@labellist\@empty
526
527\newcommand\AddEnumerateCounter{%
528  \@ifstar\enit@addcounter@s\enit@addcounter}
529
530\def\enit@addcounter#1#2#3{%
531  \enit@toks\expandafter{%
532    \enit@labellist
533    \enit@elt{#3}}%
534  \edef\enit@labellist{%
535    \the\enit@toks
536    \enit@noexcs{\expandafter\@gobble\string#1}%
537    \enit@noexcs{\expandafter\@gobble\string#2}%
538    \enit@noexcs{enit@sc@\expandafter\@gobble\string#2}}}
539
540\def\enit@addcounter@s#1#2#3{%
541  \enit@addcounter{#1}{#2}%
542    {\@nameuse{enit@sc@\expandafter\@gobble\string#2}{#3}}}
543
544% The 5 basic counters:
545
546\AddEnumerateCounter\arabic\@arabic{0}
547\AddEnumerateCounter\alph\@alph{m}
548\AddEnumerateCounter\Alph\@Alph{M}
549\AddEnumerateCounter\roman\@roman{viii}
550\AddEnumerateCounter\Roman\@Roman{VIII}
551
552% Inline lists
553% ============
554%
555% Labels
556% ------
557
558\enitkv@key{enumitem}{itemjoin}{%
559  \def\enit@itemjoin{#1}}
560
561\enitkv@key{enumitem}{itemjoin*}{%
562  \def\enit@itemjoin@s{#1}}
563
564\enitkv@key{enumitem}{afterlabel}{%
565  \def\enit@afterlabel{#1}}
566
567% Mode
568% ----
569
570\enitkv@key{enumitem}{mode}{%
571  \@ifundefined{enit@mode#1}%
572    {\enit@checkerror{mode}{#1}}%
573    {\csname enit@mode#1\endcsname}}
574
575\let\enit@modeboxed\enit@boxmodetrue
576\let\enit@modeunboxed\enit@boxmodefalse
577
578% Short Labels
579% ============
580
581\let\enit@marklist\@empty
582
583% shorthand, expansion:
584
585\newcommand\SetEnumerateShortLabel[2]{%
586  \let\enit@a\@empty
587  \def\enit@elt##1##2{%
588    \def\enit@b{#1}\def\enit@c{##1}%
589    \ifx\enit@b\enit@c\else
590      \expandafter\def\expandafter\enit@a\expandafter{%
591        \enit@a
592        \enit@elt{##1}{##2}}%
593    \fi}%
594  \enit@marklist
595  \expandafter\def\expandafter\enit@a\expandafter{%
596    \enit@a
597    \enit@elt{#1}{#2}}%
598  \let\enit@marklist\enit@a}
599
600\SetEnumerateShortLabel{a}{\alph*}
601\SetEnumerateShortLabel{A}{\Alph*}
602\SetEnumerateShortLabel{i}{\roman*}
603\SetEnumerateShortLabel{I}{\Roman*}
604\SetEnumerateShortLabel{1}{\arabic*}
605
606% This is called \enit@first one,two,three,\@nil\@@nil. If there
607% are just one element #2 is \@nil, otherwise we have to remove
608% the trailing ,\@nil with enit@first@x
609% Called with the keys in \enit@c
610% Returns enit@toks
611
612\def\enit@first#1,#2\@@nil{%
613  \in@{=}{#1}% Quick test, if contains =, it's key=value
614  \ifin@\else
615    \enitkv@@sp@def\enit@a{#1}%
616    \@ifundefined{enitkv@enumitem@\enit@meaning\enit@a}%
617      {\ifnum\enit@type=\z@
618         \def\enit@elt{\enit@replace\enit@a}%
619         \enit@marklist % Returns \enit@toks
620       \else
621         \enit@toks{#1}%
622       \fi
623       \ifx\@nil#2%
624         \ifx,#1,\else
625           \edef\enit@c{label=\the\enit@toks}%
626         \fi
627       \else
628         \@temptokena\expandafter{\enit@first@x#2}%
629         \edef\enit@c{label=\the\enit@toks,\the\@temptokena}%
630       \fi}%
631     {}%
632  \fi
633  \enit@toks\expandafter{\enit@c}}
634
635\def\enit@first@x#1,\@nil{#1}
636
637\def\enit@replace#1#2#3{%
638  \enit@toks{}%
639  \def\enit@b##1#2##2\@@nil{%
640    \ifx\@nil##2%
641      \addto@hook\enit@toks{##1}%
642    \else
643      \edef\enit@a{\the\enit@toks}%
644      \ifx\enit@a\@empty\else
645        \enit@error{Extra short label ignored}%
646           {There are more than one short label}%
647      \fi
648      \addto@hook\enit@toks{##1#3}%
649      \enit@b##2\@@nil
650    \fi}%
651  \expandafter\enit@b#1#2\@nil\@@nil
652  \edef#1{\the\enit@toks}}
653
654% Pre and post code
655% =================
656
657\enitkv@key{enumitem}{before}{%
658  \def\enit@before{#1}}
659
660\enitkv@key{enumitem}{after}{%
661  \def\enit@after{#1}}
662
663\enitkv@key{enumitem}{before*}{%
664  \expandafter\def\expandafter\enit@before\expandafter
665    {\enit@before#1}}
666
667\enitkv@key{enumitem}{after*}{%
668  \expandafter\def\expandafter\enit@after\expandafter
669    {\enit@after#1}}
670
671% Miscelaneous keys
672% ================
673 
674\enitkv@key{enumitem}{nolistsep}[true]{%
675  \partopsep=\z@skip
676  \topsep=\z@ plus .1pt
677  \itemsep=\z@skip
678  \parsep=\z@skip}
679
680\enitkv@key{enumitem}{nosep}[true]{%
681  \partopsep=\z@skip
682  \topsep=\z@skip
683  \itemsep=\z@skip
684  \parsep=\z@skip}
685
686
687\enitkv@key{enumitem}{noitemsep}[true]{%
688  \itemsep=\z@skip
689  \parsep=\z@skip}
690
691\enitkv@key{enumitem}{wide}[\parindent]{%
692  \enit@align@left
693  \leftmargin\z@
694  \labelwidth\z@
695  \setlength\labelindent{#1}%
696  \listparindent\labelindent
697  \enit@calcset\itemindent\enit@iv!}
698
699% The following is deprecated in favour of wide:
700
701\enitkv@key{enumitem}{fullwidth}[true]{%
702  \leftmargin\z@
703  \labelwidth\z@
704  \def\enit@align##1{\hskip\labelsep##1}}
705
706% "Abstract" layer
707% ================
708%
709% Named values
710% ------------
711
712\newcommand\SetEnumitemValue[2]{% Implicit #3
713  \@ifundefined{enit@enitkv@#1}%
714    {\@ifundefined{enitkv@enumitem@#1}%
715       {\enit@error{Wrong key `#1' in \string\SetEnumitemValue}%
716          {Perhaps you have misspelled it}}{}%
717     \expandafter\let\csname enit@enitkv@#1\expandafter\endcsname
718       \csname enitkv@enumitem@#1\endcsname}{}%
719  \@namedef{enitkv@enumitem@#1}##1{%
720    \def\enit@a{##1}%
721    \@ifundefined{enit@enitkv@#1@\enit@meaning\enit@a}%
722      {\@nameuse{enit@enitkv@#1}{##1}}%
723      {\@nameuse{enit@enitkv@#1\expandafter\expandafter\expandafter}%
724         \expandafter\expandafter\expandafter
725         {\csname enit@enitkv@#1@##1\endcsname}}{}}%
726  \@namedef{enit@enitkv@#1@#2}}
727
728% Defining keys
729% -------------
730
731\newcommand\SetEnumitemKey[2]{%
732  \@ifundefined{enitkv@enumitem@#1}%
733    {\enitkv@key{enumitem}{#1}[]{\enitkv@setkeys{enumitem}{#2}}}%
734    {\enit@error{Duplicated key `#1' in \string\SetEnumitemKey}%
735       {There already exists a key with that name}}}
736
737% +=============================+
738% |       PROCESSING KEYS       |
739% +=============================+
740%
741% Set keys
742% ========
743
744\def\enit@setkeys#1{%
745  \@ifundefined{enit@@#1}{}%
746    {\expandafter\expandafter\expandafter
747     \enit@setkeys@i\csname enit@@#1\endcsname\@@}}
748
749% The following is used directly in resumeset:
750
751\def\enit@setkeys@i#1\@@{%
752  \let\enit@delayedkeys\@empty
753  \enit@shl{#1}% is or returns \enit@toks
754  \expandafter\enit@setkeys@ii\the\enit@toks\@@}
755
756\def\enit@setkeys@ii#1\@@{%
757  \enitkv@setkeys{enumitem}{#1}%
758  \enit@toks\expandafter{\enit@delayedkeys}%
759  \edef\enit@a{%
760    \noexpand\enitkv@setkeys{enumitem-delayed}{\the\enit@toks}}%
761  \enit@a}
762
763% Handling * and ! values
764% =======================
765%
766% \@gobbletwo removes \c from \c@counter.
767
768\def\enit@getwidth#1#2#3#4{%
769  \let#4#3%
770  \def#3##1{%
771    \@ifundefined{enit@widest\expandafter\@gobbletwo\string##1}% if no widest=key
772      {#1}%
773      {\csname enit@widest\expandafter\@gobbletwo\string##1\endcsname{#4}}}}
774
775\def\enit@valueerror#1{\z@ % if after an assignment, but doesn't catch \ifnum
776   \enit@error{No default \string\value\space for `#1'}%
777     {You can provide one with widest*}}%
778
779\let\enit@values\@empty
780
781\def\enit@calcwidth{%
782  \ifenit@calcwidest
783    \ifnum\enit@type=\z@ % ie, enum
784      \@ifundefined{enit@cw@\@enumctr}%
785        {\@namedef{enit@cv@\@enumctr}{\enit@valueerror\@enumctr}}%
786        {\edef\enit@values{%
787           \enit@values
788           \@nameuse{c@\@enumctr}\@nameuse{enit@cw@\@enumctr}\relax}%
789         \expandafter
790         \edef\csname enit@cv@\@enumctr\endcsname
791           {\@nameuse{c@\@enumctr}}}%
792    \fi
793    \begingroup
794      \enit@values
795      \def\value##1{\csname enit@cv@##1\endcsname}%
796      \let\enit@elt\enit@getwidth
797      \enit@labellist
798      \settowidth\labelwidth{\@itemlabel}%
799      \xdef\enit@a{\labelwidth\the\labelwidth\relax}%
800    \endgroup
801    \enit@a
802  \fi
803  \advance\dimen@-\labelwidth}
804
805\def\enit@calcleft{%
806  \dimen@\leftmargin
807  \advance\dimen@\itemindent
808  \advance\dimen@-\labelsep
809  \advance\dimen@-\labelindent
810  \ifcase\enit@calc % = 0 = labelindent
811    \enit@calcwidth
812    \advance\labelindent\dimen@
813  \or % = 1 = labelwidth, so no \enit@calcwidth
814    \labelwidth\dimen@
815  \or % = 2 = labelsep
816    \enit@calcwidth
817    \advance\labelsep\dimen@
818  \or % = 3 = leftmargin
819    \enit@calcwidth
820    \advance\leftmargin-\dimen@
821  \or % = 4 =itemindent
822    \enit@calcwidth
823    \advance\itemindent-\dimen@
824  \fi}
825
826% "Normalizing" labels
827% ====================
828%
829% Replaces \counter* by \counter{level} (those in \enit@labellist).
830%
831% #1 is either \csname...\endcsmame or the container \@itemlabel --
832% hence \expandafter
833
834\def\enit@refstar@i#1#2{%
835  \if*#2\@empty
836    \noexpand#1{\@enumctr}%
837  \else
838    \noexpand#1{#2}%
839  \fi}%
840
841\def\enit@refstar#1#2#3#4{%
842  \def#2{\enit@refstar@i#2}%
843  \def#3{\enit@refstar@i#3}}
844
845\def\enit@normlabel#1#2{%
846  \begingroup
847    \def\value{\enit@refstar@i\value}%
848    \let\enit@elt\enit@refstar
849    \enit@labellist
850    \protected@xdef\enit@a{{#2}}% Added braces as \ref is in the
851  \endgroup
852  \expandafter\let#1\enit@a}                    % global scope.
853
854% Preliminary settings and default values
855% =======================================
856
857\def\enit@prelist#1#2#3{%
858  \let\enit@type#1%
859  \def\enit@depth{#2}%
860  \edef\enit@prevlabel{#3\romannumeral#2}%
861  \advance#2\@ne}
862     
863\def\enit@preset#1#2#3{%
864   \enit@sepfrommarginfalse
865   \enit@calcwidestfalse
866   \let\enit@resuming\z@
867   \let\enit@series\relax
868   \enit@boxmodetrue
869   \def\enit@itemjoin{ }%
870   \let\enit@itemjoin@s\relax
871   \let\enit@afterlabel\nobreakspace
872   \let\enit@before\@empty
873   \let\enit@after\@empty
874   \let\enit@format\@firstofone % and NOT empty
875   \let\enit@ref\relax
876   \labelindent\z@skip
877   \ifnum\@listdepth=\@ne
878     \enit@outerparindent\parindent
879   \else
880     \parindent\enit@outerparindent
881   \fi
882   \enit@setkeys{list}%
883   \enit@setkeys{list\romannumeral\@listdepth}%
884   \enit@setkeys{#1}%
885   \enit@setkeys{#1\romannumeral#2}%
886   \enit@setresume{#3}}
887
888% keyval "error" in enumitem-resume: all undefined keys (ie, all
889% except resume*) are ignored, but <series> is treated like
890% resume*=<series>
891
892\def\enitkv@err@a#1{%
893   \@ifundefined{enit@resumekeys@series@\@tempa}{}%
894     {\@nameuse{enitkv@enumitem-resume@resume*\expandafter}%
895        \expandafter{\@tempa}}}
896
897% keyval "error" in the optional argument: all undefined keys are
898% passed to the keyval error, but <series> is ignored (already
899% processed in enumitem-resume
900
901\def\enitkv@err@b#1{%
902   \@ifundefined{enit@resumekeys@series@\@tempa}%
903     {\enit@savekverr{#1}}%
904     {}}
905
906% Process keys in optional argument:
907
908\def\enit@setresume#1{%
909  \enit@shl{#1}% Returns enit@toks
910  \edef\enit@savekeys{\the\enit@toks}%
911  \let\enit@savekverr\enitkv@errx
912  \let\enitkv@errx\enitkv@err@a
913  \edef\enit@b{%
914    \noexpand\enitkv@setkeys{enumitem-resume}{\the\enit@toks}}%
915  \enit@b
916  \let\enitkv@errx\enitkv@err@b
917  \ifcase\enit@resuming\or\or % = 2
918    \expandafter
919    \enit@setkeys@i\enit@resumekeys,resume=\enit@series\@@
920  \or % = 3
921    \expandafter
922    \enit@setkeys@i\enit@resumekeys,resume\@@
923  \fi
924  \expandafter\enit@setkeys@i\enit@savekeys\@@
925  \let\enitkv@errx\enit@savekverr}
926
927% +=============================+
928% |         LIST TYPES          |
929% +=============================+
930%
931% Displayed lists
932% ===============
933% #1 #2 implicit
934
935\def\enit@dylist{%
936  \enit@align@right
937  \list}
938
939\def\enit@endlist{%
940  \enit@after
941  \endlist
942  \ifx\enit@series\relax\else % discards resume*, too
943    \ifnum\enit@resuming=\@ne % ie, series=
944      \enit@setresumekeys{series@\enit@series}\global\global
945    \else % ie, resume=, resume*= (save count, but not keys)
946      \enit@setresumekeys{series@\enit@series}\@gobblefour\global
947    \fi
948    \enit@afterlist
949  \fi
950  \ifnum\enit@resuming=\thr@@ % ie, resume* list (save count only)
951    \enit@setresumekeys\@currenvir\@gobblefour\global
952  \else
953    \enit@setresumekeys\@currenvir\@empty\@empty
954  \fi
955  \aftergroup\enit@afterlist}
956
957% #1 = either \@currenvir or series@<series>
958% #2(keys) #3(counter) are \global, \@gobblefour or \@empty
959
960\def\enit@setresumekeys#1#2#3{%
961  \enit@toks\expandafter{\enit@savekeys}%
962  \xdef\enit@afterlist{%
963    #2\def\enit@noexcs{enit@resumekeys@#1}{\the\enit@toks}%
964    \ifnum\enit@type=\z@ % ie, enum
965      #3\def\enit@noexcs{enit@resume@#1}{%
966        \csname c@\@listctr\endcsname
967        \the\csname c@\@listctr\endcsname}%
968    \fi}}
969
970% Inline lists
971% ============
972
973% Definition of \@trivlist inside inline lists.  So, when
974% \@trivlist is found in any displayed list (including quote,
975% center, verbatim...) the default \@item is restored.
976
977\def\enit@intrivlist{%
978  \enit@changed@itemfalse
979  \let\@item\enit@outer@item
980  \let\par\@@par
981  \let\@trivlist\enit@outer@triv
982  \@trivlist}
983
984% Keep track of \@item and \item changes
985
986\newif\ifenit@changed@item
987\enit@changed@itemfalse
988
989\newif\ifenit@changeditem
990\enit@changeditemfalse
991
992% List
993% ----
994
995% Arguments, as before:
996% \enitdp@<name>, <name>, <max-depth>, <format>
997% About @newlist, see @initem.
998
999\def\enit@inlist#1#2{%
1000  \ifnum\@listdepth>\enit@listdepth\relax
1001    \@toodeep
1002  \else
1003    \global\advance\@listdepth\@ne
1004  \fi
1005  \let\enit@align\@firstofone
1006  \def\@itemlabel{#1}%
1007  \@nmbrlistfalse
1008  \ifenit@changed@item\else
1009    \enit@changed@itemtrue
1010    \let\enit@outer@triv\@trivlist
1011    \let\@trivlist\enit@intrivlist
1012    \@setpar\@empty
1013    \let\enit@outer@item\@item
1014  \fi
1015  #2\relax
1016  \global\@newlisttrue
1017  \ifenit@boxmode
1018    \ifenit@changeditem\else
1019      \enit@changeditemtrue
1020      \let\enit@outeritem\item
1021    \fi
1022    \let\@item\enit@boxitem
1023  \else
1024    \let\@item\enit@noboxitem
1025    \ifx\enit@itemjoin@s\relax\else
1026      \PackageWarning{enumitem}%
1027         {itemjoin* discarded in mode unboxed\MessageBreak}%
1028    \fi
1029  \fi
1030  \let\enit@calcleft\relax
1031  \let\enit@afteritem\relax
1032  \ifenit@boxmode
1033    \global\setbox\enit@inbox\hbox\bgroup\color@begingroup
1034      \let\item\enit@endinbox
1035  \fi
1036  \ignorespaces}
1037
1038\def\enit@endinlist{%
1039  \ifenit@boxmode
1040      \unskip
1041      \xdef\enit@afteritem{%
1042        \ifhmode\spacefactor\the\spacefactor\relax\fi}%
1043      \color@endgroup
1044    \egroup
1045    \ifdim\wd\enit@inbox=\z@
1046      \enit@itemerror
1047    \else
1048      \ifenit@noinitem\else
1049        \ifhmode\unskip\fi
1050        \@ifundefined{enit@itemjoin@s}%
1051          {\enit@itemjoin}%
1052          {\enit@itemjoin@s}%
1053      \fi
1054      \unhbox\@labels
1055      \enit@afterlabel
1056      \unhbox\enit@inbox
1057      \enit@afteritem
1058    \fi
1059  \else
1060    \unskip
1061    \if@newlist
1062      \enit@itemerror
1063    \fi
1064  \fi
1065  \enit@after
1066  \global\advance\@listdepth\m@ne
1067  \global\@inlabelfalse
1068  \if@newlist
1069    \global\@newlistfalse
1070    \@noitemerr
1071  \fi
1072  \ifx\enit@series\relax\else % discards resume* list, too
1073    \ifnum\enit@resuming=\@ne % ie, series
1074      \enit@setresumekeys{series@\enit@series}\global\global
1075    \else % ie, resume, resume* (save count, but not keys)
1076      \enit@setresumekeys{series@\enit@series}\@gobblefour\global
1077    \fi
1078    \enit@afterlist
1079  \fi
1080  \ifnum\enit@resuming=\thr@@ % ie, resume* list (save count only)
1081    \enit@setresumekeys\@currenvir\@gobblefour\global
1082  \else
1083    \enit@setresumekeys\@currenvir\@empty\@empty
1084  \fi
1085  \aftergroup\enit@afterlist}
1086
1087% \@item: unboxed
1088% ---------------
1089
1090\def\enit@noboxitem[#1]{%
1091  \if@newlist
1092    \leavevmode % ships pending labels out
1093    \global\@newlistfalse
1094  \else
1095    \ifhmode
1096      \unskip
1097      \enit@itemjoin
1098    \else
1099      \noindent
1100    \fi
1101  \fi
1102  \if@noitemarg
1103    \@noitemargfalse
1104    \if@nmbrlist
1105      \refstepcounter{\@listctr}% after \unskip (hyperref)
1106    \fi
1107  \fi
1108  \mbox{\makelabel{#1}}%
1109  \enit@afterlabel
1110  \ignorespaces}
1111
1112% \@item: boxed
1113% ------------
1114%
1115% We don't want \item to be executed locally, because it sets a flag
1116% (and hyperref adds another flag, too).  So, we redefine it inside
1117% the box to \enit@endinbox which ends the box and then use the actual
1118% (outer) \item.  labels are stored in another box, to detect empty
1119% boxes, ie, misplaced \item's.  Note the 2nd \item ends collecting
1120% the 1st item and ships it out, while the 3rd \item ends collecting
1121% the 2nd item, puts the itemjoin and then ships the 2nd item out.
1122% The flag enit@noinitem keeps track of that.
1123
1124\newif\ifenit@noinitem
1125
1126\def\enit@endinbox{%
1127    \unskip
1128    \xdef\enit@afteritem{%
1129      \ifhmode\spacefactor\the\spacefactor\relax\fi}%
1130    \color@endgroup
1131  \egroup
1132  \enit@outeritem}
1133
1134\def\enit@boxitem[#1]{%
1135  \if@newlist
1136    \global\@newlistfalse
1137    \ifdim\wd\enit@inbox>\z@
1138       \enit@itemerror
1139    \fi
1140    \enit@noinitemtrue
1141    \leavevmode % ships pending labels out
1142  \else
1143    \ifdim\wd\enit@inbox=\z@
1144      \enit@itemerror
1145    \else
1146      \ifenit@noinitem
1147        \enit@noinitemfalse
1148      \else
1149        \ifhmode\unskip\fi
1150        \enit@itemjoin
1151      \fi
1152      \unhbox\@labels
1153      \enit@afterlabel
1154      \unhbox\enit@inbox
1155      \enit@afteritem
1156    \fi
1157  \fi
1158  \if@noitemarg
1159    \@noitemargfalse
1160    \if@nmbrlist
1161      \refstepcounter{\@listctr}%
1162    \fi
1163  \fi
1164  \sbox\@labels{\makelabel{#1}}%
1165  \let\enit@afteritem\relax
1166  \setbox\enit@inbox\hbox\bgroup\color@begingroup
1167    \let\item\enit@endinbox
1168    \hskip1sp % in case the first thing is \label
1169    \ignorespaces} 
1170
1171% Pause item
1172% ----------
1173%
1174% To do.
1175%
1176% The three types
1177% ===============
1178%
1179% enumerate and enumerate*
1180% ------------------------
1181%
1182% The following has 4 arguments, which in enumerate are:
1183% \@enumdepth, enum, \thr@@, <format>.
1184% In user defined environments they are:
1185% \enitdp@<name>, <name>, <max-depth>, <format>
1186
1187\def\enit@enumerate{%
1188  \let\enit@list\enit@dylist
1189  \enit@enumerate@i}
1190
1191\@namedef{enit@enumerate*}{%
1192  \let\enit@list\enit@inlist
1193  \enit@enumerate@i}
1194
1195\def\enit@enumerate@i#1#2#3#4{%
1196  \ifnum#1>#3\relax
1197    \enit@toodeep
1198  \else
1199    \enit@prelist\z@{#1}{#2}%
1200    \edef\@enumctr{#2\romannumeral#1}%
1201    \expandafter
1202    \enit@list
1203      \csname label\@enumctr\endcsname
1204      {\usecounter\@enumctr
1205       \let\enit@calc\z@
1206       \def\makelabel##1{\enit@align{\enit@format{##1}}}%
1207       \enit@preset{#2}{#1}{#4}%
1208       \enit@normlabel\@itemlabel\@itemlabel
1209       \enit@ref
1210       \enit@calcleft
1211       \enit@before}%
1212  \fi}
1213
1214\let\enit@endenumerate\enit@endlist
1215\@namedef{enit@endenumerate*}{\enit@endinlist}
1216
1217% itemize and itemize*
1218% --------------------
1219%
1220% The following has 4 arguments, which in itemize are:
1221% \@itemdepth, item, \thr@@, <format>.
1222% In user defined environments they are:
1223% \enitdp@<name>, <name>, <max-depth>, <format>
1224
1225\def\enit@itemize{%
1226  \let\enit@list\enit@dylist
1227  \enit@itemize@i}
1228
1229\@namedef{enit@itemize*}{%
1230  \let\enit@list\enit@inlist
1231  \enit@itemize@i}
1232 
1233\def\enit@itemize@i#1#2#3#4{%
1234  \ifnum#1>#3\relax
1235    \enit@toodeep
1236  \else
1237    \enit@prelist\@ne{#1}{#2}%
1238    \edef\@itemitem{label#2\romannumeral#1}%
1239    \expandafter
1240    \enit@list
1241      \csname\@itemitem\endcsname
1242       {\let\enit@calc\z@
1243        \def\makelabel##1{\enit@align{\enit@format{##1}}}%
1244        \enit@preset{#2}{#1}{#4}%
1245        \enit@calcleft
1246        \enit@before}%
1247  \fi}
1248
1249\let\enit@enditemize\enit@endlist
1250\@namedef{enit@enditemize*}{\enit@endinlist}
1251
1252% description and description*
1253% ----------------------------
1254%
1255% Make sure \descriptionlabel exists:
1256
1257\providecommand*\descriptionlabel[1]{%
1258  \hspace\labelsep
1259  \normalfont\bfseries#1}
1260
1261\@namedef{enit@description*}{%
1262  \let\enit@list\enit@inlist
1263  \enit@description@i}
1264
1265\def\enit@description{%
1266  \let\enit@list\enit@dylist
1267  \enit@description@i}
1268
1269\def\enit@description@i#1#2#3#4{%
1270  \ifnum#1>#3\relax
1271    \enit@toodeep
1272  \else
1273    \enit@list{}%
1274      {\let\enit@type\tw@
1275       \advance#1\@ne
1276       \labelwidth\z@
1277       \enit@align@left
1278       \let\makelabel\descriptionlabel
1279       \enit@style@standard
1280       \enit@preset{#2}{#1}{#4}%
1281       \enit@calcleft
1282       \let\enit@svlabel\makelabel
1283       \def\makelabel##1{%
1284         \labelsep\z@
1285         \ifenit@boxdesc
1286           \enit@svlabel{\enit@align{\enit@format{##1}}}%
1287         \else
1288           \nobreak
1289           \enit@svlabel{\enit@format{##1}}%
1290           \aftergroup\enit@postlabel
1291         \fi}%
1292       \enit@before}%
1293  \fi}
1294
1295\let\enit@enddescription\enit@endlist
1296\@namedef{enit@enddescription*}{\enit@endinlist}
1297
1298% trivlist
1299% ========
1300
1301\def\enit@trivlist{%
1302  \let\enit@type\tw@
1303  \parsep\parskip
1304  \csname @list\romannumeral\the\@listdepth\endcsname
1305  \@nmbrlistfalse
1306  \enit@setkeys{trivlist}%
1307  \enit@setkeys{trivlist\romannumeral\@listdepth}%
1308  \@trivlist
1309  \labelwidth\z@
1310  \leftmargin\z@
1311  \itemindent\z@
1312  \let\@itemlabel\@empty
1313  \def\makelabel##1{##1}}
1314
1315% Description styles
1316% ==================
1317%
1318% the next definition is somewhat tricky because labels are boxed.
1319% That's fine when the label is just placed at the begining of a line
1320% of text, but when the box is placed without horizontal material,
1321% leading is killed.  So, we need change somehow \box to \unhbox, but
1322% I don't want to modify \@item.  The code below presumes \@item has
1323% not been changed and arguments gobble the part setting \@labels,
1324% which is replaced by a new one.
1325%
1326% The default value in description is itemindent=!, but some styles
1327% (those whose item text begin at a fixed place, ie, nextline,
1328% multiline and sameline) change it to labelwidth=!.
1329%
1330% We must be careful with the group and the whatsit added by color to
1331% boxes.  Alignment is applied here and some adjustments in skips are
1332% necessary to get proper line breaks (including a \nobreak at the
1333% beginning of \enit@align, ie, after the first whatsit, see above).
1334% To "pass" the inner group added by color to the box, \enit@postlabel
1335% ckecks if the following is }.  ie, \egroup -- if not, the box has
1336% not reached yet its end.
1337
1338\def\enit@postlabel{%
1339  \@ifnextchar\egroup
1340    {\aftergroup\enit@postlabel}%
1341    {\enit@postlabel@i}}
1342
1343\def\enit@postlabel@i#1#2#3#4#5{%
1344  \def\enit@lblpenalty{\penalty\z@\hskip\skip@}%
1345  \ifenit@nextline
1346    \ifdim\wd\@tempboxa>\labelwidth
1347      \def\enit@lblpenalty{\newline\@nobreaktrue}%
1348    \fi
1349  \fi
1350  \everypar{%
1351    \@minipagefalse
1352    \global\@newlistfalse
1353    \if@inlabel
1354      \global\@inlabelfalse
1355      {\setbox\z@\lastbox
1356       \ifvoid\z@
1357         \kern-\itemindent
1358       \fi}%
1359      \unhbox\@labels
1360      \skip@\lastskip % Save last \labelsep
1361      \unskip % Remove it
1362      \enit@lblpenalty % Restore it, after penalty
1363    \fi
1364    \if@nobreak
1365      \@nobreakfalse
1366      \clubpenalty\@M
1367    \else
1368      \clubpenalty\@clubpenalty
1369      \everypar{}%
1370    \fi}%
1371  \def\enit@a{#1#2#3#4}%
1372  \def\enit@b{\global\setbox\@labels\hbox}%
1373  \ifx\enit@a\enit@b\else
1374    \enit@error{Non standard \string\item}%
1375      {A class or a package has redefined \string\item\MessageBreak
1376       and I do not know how to continue}%
1377  \fi
1378  \global\setbox\@labels\hbox{%
1379    \unhbox\@labels
1380    \hskip\itemindent
1381    \hskip-\labelwidth
1382    \hskip-\labelsep
1383    \ifdim\wd\@tempboxa>\labelwidth
1384      \enit@align{\unhbox\@tempboxa}\unskip % Removes (typically) \hfil
1385    \else
1386      \leavevmode\hbox to\labelwidth{\enit@align{\unhbox\@tempboxa}}%
1387    \fi
1388    \hskip\labelsep}}
1389
1390% +=============================+
1391% |     (RE)DEFINING LISTS      |
1392% +=============================+
1393%
1394% Set keys/values
1395% ===============
1396% Remember \romannumeral0 expands to nothing.
1397% #1 = list name, #2 = level, #3 = flag if star, #4 = keys/values
1398
1399\def\enit@saveset#1#2#3#4{%
1400  \setcounter{enit@cnt}{#2}%
1401  \ifcase#3%
1402    \expandafter
1403    \def\csname enit@@#1\romannumeral\c@enit@cnt\endcsname{#4}%
1404  \or
1405    \expandafter\let\expandafter\enit@b
1406      \csname enit@@#1\romannumeral\c@enit@cnt\endcsname
1407    \ifx\enit@b\relax
1408      \let\enit@b\@empty
1409    \fi
1410    \expandafter\def
1411      \csname enit@@#1\romannumeral\c@enit@cnt\expandafter\endcsname
1412      \expandafter{\enit@b,#4}%
1413  \fi}
1414
1415% To do: more robust tests (catch wrong names, but not easy)
1416
1417% Internally, LaTeX uses a short name for enumerate (enum)
1418% and itemize (item). To be consistent with this convention,
1419% a couple of macros provide a "translation". I'm not very
1420% happy with the current implementation.
1421
1422\def\enit@shortenumerate{enum}
1423\def\enit@shortitemize{item}
1424
1425\newcommand\setlist{%
1426  \@ifstar{\enit@setlist\@ne}{\enit@setlist\z@}}
1427
1428\def\enit@setlist#1{%
1429  \@ifnextchar[{\enit@setlist@x#1}{\enit@setlist@i#1\@empty}}
1430
1431% Let's accept \setlist[]*{}, too, because an error in <=3.5.1
1432
1433\def\enit@setlist@x#1[#2]{%
1434  \@ifstar{\enit@setlist@i\@ne{#2}}{\enit@setlist@i#1{#2}}}
1435
1436% #1 list names/levels, #2 keys/values
1437
1438% #1 star flag, #2 list names/levels, #3 keys/values
1439
1440\def\enit@setlist@i#1#2#3{%
1441  \let\enit@eltnames\relax
1442  \let\enit@b\@empty
1443  \let\enit@eltlevels\relax
1444  \let\enit@c\@empty
1445  \protected@edef\enit@a{#2}%
1446  \@for\enit@a:=\enit@a\do{% the 2nd enit@a is first expanded
1447    \@ifundefined{enitdp@\enit@meaning\enit@a}%
1448      {\edef\enit@c{\enit@c\enit@eltlevels{\enit@a}}}%
1449      {\@ifundefined{enit@short\enit@meaning\enit@a}%
1450         \@empty
1451         {\edef\enit@a{\@nameuse{enit@short\enit@a}}}%
1452       \edef\enit@b{\enit@b\enit@eltnames{\enit@a}}}}%
1453  \ifx\enit@b\@empty
1454     \def\enit@b{\enit@eltnames{list}}%
1455  \fi
1456  \ifx\enit@c\@empty
1457     \def\enit@c{\enit@eltlevels{0}}%
1458  \fi
1459  \def\enit@eltnames##1{%
1460    \def\enit@a{##1}%
1461    \enit@c}%
1462  \def\enit@eltlevels##1{%
1463    \enit@saveset\enit@a{##1}#1{#3}}%
1464  \enit@b}%
1465
1466% Deprecated:
1467
1468\newcommand\setdisplayed[1][0]{\setlist[trivlist,#1]}
1469\let\enitdp@trivlist\@empty % dummy, let know it exists
1470\newcommand\setenumerate[1][0]{\setlist[enumerate,#1]}
1471\newcommand\setitemize[1][0]{\setlist[itemize,#1]}
1472\newcommand\setdescription[1][0]{\setlist[description,#1]}
1473
1474% New lists
1475% =========
1476
1477% When defining a list, \label... and counters must be defined
1478% for each level, too:
1479
1480\def\enit@xset@itemize{%
1481  \@namedef{label\enit@c\romannumeral\count@}{%
1482    \enit@error{Undefined label}%
1483      {You have defined a list, but labels have
1484       not been setup.\MessageBreak
1485       You can set the label field with \string\setlist.}}}
1486\@namedef{enit@xset@itemize*}{\enit@xset@itemize}
1487
1488\def\enit@xset@enumerate{%
1489  \enit@xset@itemize
1490  \@ifundefined{c@\enit@c\romannumeral\count@}%
1491    {\@definecounter{\enit@c\romannumeral\count@}}{}}
1492\@namedef{enit@xset@enumerate*}{\enit@xset@enumerate}
1493
1494\let\enit@xset@description\@empty
1495\@namedef{enit@xset@description*}{\enit@xset@description}
1496
1497\newcommand\newlist{\enit@newlist\newenvironment}
1498\newcommand\renewlist{\enit@newlist\renewenvironment}
1499
1500% <new/renew>, <name>, <type>, <max-depth>
1501
1502\def\enit@newlist#1#2#3#4{%
1503  \@ifundefined{enit@xset@#3}%
1504    {\enit@error{Unknown list type `#3')}%
1505          {Valid types are:
1506           enumerate, itemize, description,\messageBreak
1507           enumerate*, itemize*, description*}}%
1508    {}%
1509  \setcounter{enit@cnt}{#4}%
1510  \count@\@ne
1511  \@ifundefined{enit@short#2}%
1512    {\def\enit@c{#2}}%
1513    {\edef\enit@c{\csname enit@short#2\endcsname}}%
1514  \loop
1515    \@nameuse{enit@xset@#3}% Uses \enit@c
1516    \ifnum\count@<\c@enit@cnt
1517    \advance\count@\@ne
1518  \repeat
1519  \@ifundefined{enitdp@#2}%
1520    {\expandafter\newcount\csname enitdp@#2\endcsname}{}%
1521  \csname enitdp@#2\endcsname\z@
1522  \advance\c@enit@cnt\m@ne
1523  \edef\enit@a{%
1524    \noexpand#1{#2}[1][]%
1525      {\enit@noexcs{enit@#3}%
1526       \enit@noexcs{enitdp@#2}%
1527       {\enit@c}%
1528       {\the\c@enit@cnt}%
1529       {####1}}%
1530      {\enit@noexcs{enit@end#3}}}%
1531  \enit@a}
1532
1533% Changing the default nesting limit
1534% ----------------------------------
1535
1536\newcommand\setlistdepth{\def\enit@listdepth}
1537\setlistdepth{5}
1538
1539% +=============================+
1540% |       PACKAGE OPTIONS       |
1541% +=============================+
1542
1543\newif\ifenit@loadonly
1544
1545\DeclareOption{ignoredisplayed}{\let\enit@trivlist\trivlist}
1546\DeclareOption{loadonly}{\enit@loadonlytrue}
1547\DeclareOption{shortlabels}
1548  {\def\enit@shl#1{%
1549     \ifnum\enit@type=\tw@
1550       \enit@toks{#1}%
1551     \else
1552       \def\enit@c{#1}%
1553       \enit@first#1,\@nil\@@nil % Returns enit@toks
1554    \fi}}
1555\DeclareOption{inline}
1556  {\newenvironment{enumerate*}[1][]%
1557     {\@nameuse{enit@enumerate*}\enitdp@enumerate{enum}\thr@@{#1}}
1558     {\@nameuse{enit@endenumerate*}}
1559   \newenvironment{itemize*}[1][]%
1560     {\@nameuse{enit@itemize*}\enitdp@itemize{item}\thr@@{#1}}
1561     {\@nameuse{enit@enditemize*}}
1562   \newenvironment{description*}[1][]%
1563     {\@nameuse{enit@description*}\enitdp@description{description}\@M{#1}}
1564     {\@nameuse{enit@enddescription*}}}
1565
1566\let\enit@shl\enit@toks
1567
1568\ProcessOptions
1569
1570\let\trivlist\enit@trivlist
1571
1572% If there is no loadonly, redefine the basic lists:
1573
1574\ifenit@loadonly\else
1575
1576\let\enitdp@enumerate\@enumdepth
1577\renewenvironment{enumerate}[1][]
1578  {\enit@enumerate\enitdp@enumerate{enum}\thr@@{#1}}
1579  {\enit@endenumerate}
1580
1581\let\enitdp@itemize\@itemdepth
1582\renewenvironment{itemize}[1][]
1583  {\enit@itemize\enitdp@itemize{item}\thr@@{#1}}
1584  {\enit@enditemize}
1585
1586\newcount\enitdp@description
1587\renewenvironment{description}[1][]
1588  {\enit@description\enitdp@description{description}\@M{#1}}
1589  {\enit@enddescription}
1590
1591\fi
1592
1593\endinput
Note: See TracBrowser for help on using the repository browser.