Fork me on GitHub

source: svn/trunk/paper/CommPhysComp/enumitem.sty@ 621

Last change on this file since 621 was 460, checked in by Xavier Rouby, 15 years ago

update + renumbering of figures according to the editor's scheme

File size: 11.5 KB
Line 
1% +--------------------------------------------------+
2% | Typeset enumitem.tex to get the documentation. |
3% +--------------------------------------------------+
4%
5% Copyright (c) 2003-2004 by Javier Bezos.
6% All Rights Reserved.
7%
8% This file is part of the enumitem distribution release 1.0
9% -----------------------------------------------------------
10%
11% This program can be redistributed and/or modified under the terms
12% of the LaTeX Project Public License Distributed from CTAN
13% archives in directory macros/latex/base/lppl.txt; either
14% version 1 of the License, or any later version.
15%
16% Notes
17% ~~~~~
18%
19% The tag enit@ is used through the style
20%
21% Release
22% ~~~~~~~
23
24\NeedsTeXFormat{LaTeX2e}
25\ProvidesPackage{enumitem}[2004/07/19 v1.0 Customized lists]
26
27% Reponer \lableindent a 0 siempre
28
29\@ifundefined{define@key}{\RequirePackage{keyval}}{}%
30
31\newlength{\labelindent}
32
33% Vertical spacing
34
35\define@key{enumitem}{topsep}{%
36 \setlength{\topsep}{#1}}
37
38\define@key{enumitem}{itemsep}{%
39 \setlength{\itemsep}{#1}}
40
41\define@key{enumitem}{parsep}{%
42 \setlength{\parsep}{#1}}
43
44\define@key{enumitem}{partopsep}{%
45 \setlength{\partopsep}{#1}}
46
47% Horizontal spacing
48
49\define@key{enumitem}{itemindent}{%
50 \setlength{\itemindent}{#1}}
51
52\define@key{enumitem}{listparindent}{%
53 \setlength{\listparindent}{#1}}
54
55\define@key{enumitem}{labelwidth}{%
56 \setlength{\labelwidth}{#1}}
57
58\define@key{enumitem}{labelindent}{%
59 \setlength{\labelindent}{#1}}
60
61\define@key{enumitem}{rightmargin}{%
62 \setlength{\rightmargin}{#1}}
63
64\define@key{enumitem}{leftmargin}{%
65 \if*#1%
66 \def\enit@calcleft{%
67 \enit@calclabel
68 \leftmargin\labelwidth
69 \advance\leftmargin\labelsep
70 \advance\leftmargin\labelindent
71 \advance\labelindent-\itemindent}%
72 \else
73 \setlength{\leftmargin}{#1}%
74 \fi}
75
76\define@key{enumitem}{labelsep}{%
77 \if*#1%
78 \def\enit@calcleft{%
79 \advance\labelindent-\itemindent
80 \enit@calclabel
81 \labelsep\leftmargin
82 \advance\labelsep-\labelwidth
83 \advance\labelsep-\labelindent}%
84 \else
85 \setlength{\labelsep}{#1}%
86 \fi}
87
88\define@key{enumitem}{widest}{%
89 \expandafter\def
90 \csname enit@widest\@enumctr\endcsname{#1}}
91
92\def\enit@calclabel{%
93 \begingroup
94 \enit@calcdef\@arabic\enit@arabic{0}%
95 \enit@calcdef\@alph\enit@alph{m}%
96 \enit@calcdef\@Alph\enit@Alph{M}%
97 \enit@calcdef\@roman\enit@roman{viii}%
98 \enit@calcdef\@Roman\enit@Roman{VIII}%
99 \settowidth\labelwidth{\@itemlabel}%
100 \xdef\enit@a{\labelwidth\the\labelwidth\relax}%
101 \endgroup
102 \enit@a}
103
104% Used below to gobble \c@ from the internal representation
105% of counters.
106
107\def\@gobblethree#1#2#3{}
108
109\def\enit@calcdef#1#2#3{%
110 \let#2#1%
111 \def#1##1{%
112 \@ifundefined{enit@widest\expandafter\@gobblethree\string##1}% if no widest key
113 {#3}%
114 {\csname enit@widest\expandafter\@gobblethree\string##1\endcsname}}}
115
116% Resume and start
117
118\define@key{enumitem}{resume}[]{%
119 \enit@resume\relax}
120
121\define@key{enumitem}{start}[\@ne]{%
122 \csname c@\@listctr\endcsname#1\relax
123 \advance\csname c@\@listctr\endcsname\m@ne}
124
125% How the label is aligned
126
127\let\enit@alignright\@empty
128\def\enit@alignleft{%
129 \def\makelabel##1{\rlap{##1}\hss}}
130
131\define@key{enumitem}{align}{%
132 \csname enit@align#1\endcsname}
133
134% Penalties
135
136\define@key{enumitem}{beginpenalty}{%
137 \@beginparpenalty#1\relax}
138
139\define@key{enumitem}{midpenalty}{%
140 \@itempenalty#1\relax}
141
142\define@key{enumitem}{endpenalty}{%
143 \@endparpenalty#1\relax}
144
145
146% description specific keys
147
148\define@key{enumitem}{font}[]{%
149 \def\makelabel##1{\hskip\labelsep\normalfont#1##1}}
150
151\define@key{enumitem}{style}[normal]{%
152 \edef\enit@descstyle{%
153 \expandafter\noexpand\csname enit@#1style\endcsname}}
154
155\let\enit@normalstyle\@firstofone
156
157% Labels and refs
158
159\define@key{enumitem}{label}{%
160 \enit@normlabel{#1}% Returns \enit@a
161 \expandafter\let\@itemlabel\enit@a
162%ie, redefine \labelenumX or \labelitemX.
163 \ifx\enit@ref\relax\enit@reflabel{#1}\fi}
164%ie, only if there is not a previous ref=
165% Normalization is done twice. Not good.
166
167\define@key{enumitem}{ref}{%
168 \enit@reflabel{#1}}
169
170%\expandafter\def\csname c@*\endcsname{\csname c@\@enumctr\endcsname}
171
172\def\enit@normlabel#1{%
173 \begingroup
174 \enit@refstar\arabic
175 \enit@refstar\alph
176 \enit@refstar\Alph
177 \enit@refstar\roman
178 \enit@refstar\Roman
179 \enit@refstar\value
180 \enit@refstar\@arabic
181 \enit@refstar\@alph
182 \enit@refstar\@Alph
183 \enit@refstar\@roman
184 \enit@refstar\@Roman
185 \protected@xdef\enit@a{#1}%
186 \endgroup}
187
188\def\enit@reflabel#1{%
189 \def\enit@ref{%
190 \ifnum\@enumdepth=\@ne\else % no level 0
191 \advance\@enumdepth\@ne
192 \@namedef{p@\@enumctr}{}% Don't accumulate labels
193 \advance\@enumdepth\m@ne
194 \fi
195 \enit@normlabel{#1}% Returns \enit@a
196 \expandafter
197 \let\csname the\@enumctr\endcsname\enit@a}}
198
199\def\enit@refstar#1{%
200 \def#1##1{%
201 \if*##1\@empty
202 \noexpand#1{enum\romannumeral\@enumdepth}%
203 \else
204 \noexpand#1{##1}%
205 \fi}}
206
207\def\enit@setkeys#1{%
208 \@ifundefined{#1}{}%
209 {\toks@\expandafter\expandafter\expandafter
210 {\csname#1\endcsname}%
211 \edef\enit@a{%
212 \noexpand\setkeys{enumitem}{\the\toks@}}%
213 \enit@a
214 \ifx\enit@ref\relax\else % Not a logical place, grrr
215 \let\enit@saveref\enit@ref
216 \let\enit@ref\relax
217 \fi}}
218
219% And now, the three environments are redefined.
220% First, code shared by enumerate and itemize.
221
222\newdimen\enit@outerparindent
223
224\def\enit@preset{%
225 \def\makelabel##1{\hss\llap{##1}}%
226 \let\enit@calcleft\relax
227 \let\enit@widest\@empty
228 \labelindent\z@skip
229 \ifnum\@listdepth=\@ne
230 \enit@outerparindent\parindent
231 \else
232 \parindent\enit@outerparindent
233 \fi
234 \enit@setkeys
235 {enit@list}%
236 \enit@setkeys
237 {enit@list\romannumeral\@listdepth}}
238
239\def\enit@enumerate#1{%
240 \ifnum \@enumdepth >\thr@@
241 \@toodeep
242 \else
243 \advance\@enumdepth\@ne
244 \edef\@enumctr{enum\romannumeral\@enumdepth}%
245 \expandafter
246 \list
247 \csname label\@enumctr\endcsname
248 {\usecounter\@enumctr
249 \let\enit@ref\relax
250 \let\enit@saveref\relax
251 \enit@normlabel{\@itemlabel}% Returns \enit@a
252 \expandafter\let\@itemlabel\enit@a
253 \enit@preset
254 \enit@setkeys
255 {enit@enum}%
256 \enit@setkeys
257 {enit@\@enumctr}%
258 \setkeys{enumitem}{#1}%
259 \enit@calcleft
260 \ifx\enit@ref\relax
261 \enit@saveref
262 \else
263 \enit@ref
264 \fi}%
265 \fi}
266
267\def\enit@endenumerate{%
268 \endlist
269 \xdef\enit@resume{%
270 \csname c@\@listctr\endcsname
271 \the\csname c@\@listctr\endcsname}}
272
273\renewenvironment{enumerate}[1][]
274 {\enit@enumerate{#1}}
275 {\enit@endenumerate}
276
277\def\enit@itemize#1{%
278 \ifnum \@itemdepth >\thr@@
279 \@toodeep
280 \else
281 \advance\@itemdepth\@ne
282 \edef\@itemitem{labelitem\romannumeral\@itemdepth}%
283 \expandafter
284 \list
285 \csname\@itemitem\endcsname
286 {\enit@preset
287 \enit@setkeys
288 {enit@item}%
289 \enit@setkeys
290 {enit@item\romannumeral\@itemdepth}%
291 \setkeys{enumitem}{#1}%
292 \enit@calcleft}%
293 \fi}
294
295\let\enit@enditemize\itemize
296
297\renewcommand{\itemize}[1][]{\enit@itemize{#1}}
298
299\renewcommand{\description}[1][]{%
300 \list{}%
301 {\labelwidth\z@
302 \let\makelabel\descriptionlabel
303 \let\enit@descstyle\enit@normalstyle
304 \labelindent\z@skip
305 \enit@setkeys
306 {enit@list}%
307 \enit@setkeys
308 {enit@list\romannumeral\@listdepth}%
309 \enit@setkeys
310 {enit@desc}%
311 \setkeys{enumitem}{#1}%
312 \itemindent-\leftmargin
313 \advance\itemindent\labelindent
314 \let\enit@makelabel\makelabel
315 \def\makelabel##1{%
316 \enit@descstyle{\enit@makelabel{##1}}}}}
317
318% Option ignoredisplayed (see below).
319
320\def\enit@trivlist{%
321 \parsep\parskip
322 \csname @list\romannumeral\the\@listdepth\endcsname
323 \@nmbrlistfalse
324 \enit@setkeys
325 {enit@triv}%
326 \enit@setkeys
327 {enit@triv\romannumeral\@listdepth}%
328 \@trivlist
329 \labelwidth\z@
330 \leftmargin\z@
331 \itemindent\z@
332 \let\@itemlabel\@empty
333 \def\makelabel##1{##1}}
334
335% description styles
336
337% the next definition is somewhat tricky because
338% labels are boxed. That's fine when the label is
339% just placed at the begining of a line of text,
340% but when the box is placed whithout horizontal
341% material, leading is killed. Therefore,
342% solutions based on the LaTeX Companion are wrong.
343% Here, the \everypar in \@item is overriden
344% and the label is printed directly, without
345% boxing it.
346
347\def\enit@nextlinestyle#1{%
348 \hskip-\itemindent % quick & dirty --what's happening?
349 \global\everypar{%
350 \@minipagefalse
351 \global\@newlistfalse
352 \if@inlabel
353 \global\@inlabelfalse
354 {\setbox\z@\lastbox
355 \ifvoid\z@
356 \kern-\itemindent
357 \fi
358 \sbox\z@{\hskip\labelindent#1\hskip\labelsep}%
359 \ifdim\wd\z@>\leftmargin
360 {\advance\leftskip-\leftmargin
361 \advance\leftskip\labelindent
362 \hskip-\labelsep
363 #1%
364 \vskip-\parskip}%
365 \else
366 \hskip-\leftmargin\hskip-\labelsep\hskip\labelindent
367 \rlap{#1}%
368 \hskip\leftmargin\hskip\labelsep\hskip-\labelindent
369 \fi}%
370 \fi
371 \if@nobreak
372 \@nobreakfalse
373 \clubpenalty \@M
374 \else
375 \clubpenalty \@clubpenalty
376 \everypar{}%
377 \fi}}
378
379\def\enit@multilinestyle#1{%
380 \dimen@\leftmargin
381 \advance\dimen@-\labelsep
382 \advance\dimen@-\labelindent
383 \sbox\z@{%
384 \parbox[t]\dimen@{%
385 \raggedright\hskip-\labelsep#1}}%
386 \dp\z@\z@
387 \hskip\labelsep\box\z@
388 \hfil}
389
390\def\enit@unboxedstyle#1{%
391 \hskip-\itemindent
392 \global\everypar{%
393 \@minipagefalse
394 \global\@newlistfalse
395 \if@inlabel
396 \global\@inlabelfalse
397 {\setbox\z@\lastbox
398 \ifvoid\z@
399 \kern-\itemindent
400 \fi%
401 \hskip-\leftmargin\hskip-\labelsep\hskip\labelindent
402 #1%
403 \hskip\labelsep}%
404 \fi
405 \if@nobreak
406 \@nobreakfalse
407 \clubpenalty \@M
408 \else
409 \clubpenalty \@clubpenalty
410 \global\everypar{}%
411 \fi}}
412
413\def\enit@samelinestyle#1{%
414 \hskip-\itemindent
415 \global\everypar{%
416 \@minipagefalse
417 \global\@newlistfalse
418 \if@inlabel
419 \global\@inlabelfalse
420 {\setbox\z@\lastbox
421 \ifvoid\z@
422 \kern-\itemindent
423 \fi
424 \sbox\z@{\hskip\labelindent#1\hskip\labelsep}%
425 \ifdim\wd\z@>\leftmargin
426 \hskip-\leftmargin
427 \hskip-\labelsep
428 \hskip\labelindent
429 #1%
430 \hskip\labelsep
431 \else
432 \hskip-\leftmargin
433 \hskip-\labelsep
434 \hskip\labelindent
435 \rlap{#1}%
436 \hskip\leftmargin
437 \hskip\labelsep
438 \hskip-\labelindent
439 \fi}%
440 \fi
441 \if@nobreak
442 \@nobreakfalse
443 \clubpenalty \@M
444 \else
445 \clubpenalty \@clubpenalty
446 \everypar{}%
447 \fi}}
448
449% Formatting lists globally
450
451\newcommand\setenumerate[1][0]{%
452 \expandafter\def\csname enit@enum\romannumeral#1\endcsname}
453
454\newcommand\setitemize[1][0]{%
455 \expandafter\def\csname enit@item\romannumeral#1\endcsname}
456
457\def\setdescription{\def\enit@desc}
458
459\newcommand\setlist[1][0]{%
460 \expandafter\def\csname enit@list\romannumeral#1\endcsname}
461
462\newcommand\setdisplayed[1][0]{%
463 \expandafter\def\csname enit@triv\romannumeral#1\endcsname}
464
465% A few useful predefined keys
466
467\define@key{enumitem}{nolistsep}[true]{%
468 \partopsep=\z@skip
469 \topsep=\z@ plus .1pt
470 \itemsep=\z@skip
471 \parsep=\z@skip}
472
473\define@key{enumitem}{noitemsep}[true]{%
474 \itemsep=\z@skip
475 \parsep=\z@skip}
476
477\define@key{enumitem}{fullwidth}[true]{%
478 \leftmargin\z@
479 \labelwidth\z@
480 \def\makelabel##1{%
481 \hskip\labelsep##1}}
482
483% And options
484
485\DeclareOption{ignoredisplayed}{\let\enit@trivlist\trivlist}
486
487\ProcessOptions
488
489\let\trivlist\enit@trivlist
490
491\endinput
Note: See TracBrowser for help on using the repository browser.