├── LICENSE.txt ├── README.md ├── enumitem.pdf ├── enumitem.sty ├── enumitem.tds.zip └── enumitem.tex /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2003-2018 Javier Bezos 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Enumitem 3.11 2 | 3 | This package provides most of the flexibility you may want to customize 4 | the three basic list environments (`enumerate`, `itemize` and 5 | `description`) and to design your own lists, with a `=` 6 | syntax. 7 | 8 | ### Latest changes 9 | 10 | ``` 11 | 3.11 2025-02-06 12 | Revert a fix 13 | 3.10 2025-01-19 14 | - A couple of fixes: \value* in ref=, a more robust resume*. 15 | 3.9 2019-06-20 16 | - \DrawEnumitemLabel rewritten 17 | 3.8 2019-02-04 18 | - Fix - calc stopped working if loaded after. 19 | - Improved \DrawEnumitemLabel 20 | 3.7 2019-01-14 21 | - Option series=override, to overcome some backwards 22 | incompatibilities. 23 | - Extension to \setlist for sizes (\setlist) 24 | - \SetEnumitemSize, for size dependent settings. 25 | - \EnumitemId, with a unique numeric identifier for eash list. 26 | 3.6 2018-11-30 27 | - New key 'left', for fast, tab-like positioning of the label. 28 | - The key 'widest' now works with 'itemize' and 'description'. 29 | - New key 'first', for code at the beginning of the list body. 30 | - \DrawEnumitemLabel, for visual debugging of the label position. 31 | - Extended settings for trivlist, with a new package option 32 | 'includedisplayed'. 33 | - Size dependent lengths (first steps). 34 | - Fix - 'format'/'font' was not taken into account when computing 35 | 'widest'. 36 | ``` 37 | 38 | License: MIT 39 | 40 | Repository: https://github.com/jbezos/enumitem 41 | 42 | ________ 43 | Javier Bezos --- http://www.texnia.com 44 | 45 | 2025/02/06 46 | -------------------------------------------------------------------------------- /enumitem.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jbezos/enumitem/ec9787500280b3c2bd280906093183589338a809/enumitem.pdf -------------------------------------------------------------------------------- /enumitem.sty: -------------------------------------------------------------------------------- 1 | % 2 | % Copyright (C) 2003-2025 Javier Bezos http://www.texnia.com 3 | % 4 | % This file may be distributed and/or modified under the conditions of 5 | % the MIT License. A version can be found at the end of this file. 6 | % 7 | % Repository: https://github.com/jbezos/enumitem 8 | % 9 | % Release 10 | % ~~~~~~~ 11 | 12 | \NeedsTeXFormat{LaTeX2e} 13 | \ProvidesPackage{enumitem}[2025/02/06 v3.11 Customized lists] 14 | 15 | % Notes 16 | % ~~~~~ 17 | % 18 | % The tag enit@ is used through the style 19 | % 20 | % To do: 21 | % ~~~~~~ 22 | % - ref*, for adding stuff in the same fashion as label* 23 | % - labelled descriptions (ie, label, title, body) 24 | % - A true nextline (far from trivial and perhaps solved with 25 | % labelled descriptions). 26 | % - Improved \AddEnumerateCounter 27 | % - Compatibility with interfaces and zref-enumitem 28 | % - "Pausing" somehow inline boxed text. 29 | % - \@enumctr <-> \@listctr? 30 | % - Define keys with values 31 | % - Revise @nobreak 32 | % - bottomsep 33 | % - \SetEnumerateCounter - must define syntax 34 | % - option verbose 35 | % - collect sizes in \SetEnumitemSizes? 36 | % - series=explicit / resume 37 | % - package option inlinenew, to define "new" inline lists 38 | % 39 | % +=============================+ 40 | % | EMULATING KEYVAL | 41 | % +=============================+ 42 | % 43 | % "Thanks" to xkeyval, which uses the same macro names as keyval :-(, 44 | % the latter has to be replicated in full here to ensure it works as 45 | % intended. The original work is by David Carlisle, under license LPPL. 46 | % Once the code is here, it could be optimized by adapting it to the 47 | % specific needs of enumitem (to do). 48 | 49 | \def\enitkv@setkeys#1#2{% 50 | \def\enitkv@prefix{enitkv@#1@}% 51 | \let\@tempc\relax 52 | \enitkv@do#2,\relax,} 53 | 54 | \def\enitkv@do#1,{% 55 | \ifx\relax#1\empty\else 56 | \enitkv@split#1==\relax 57 | \expandafter\enitkv@do\fi} 58 | 59 | \def\enitkv@split#1=#2=#3\relax{% 60 | \enitkv@@sp@def\@tempa{#1}% 61 | \ifx\@tempa\@empty\else 62 | \expandafter\let\expandafter\@tempc 63 | \csname\enitkv@prefix\@tempa\endcsname 64 | \ifx\@tempc\relax 65 | \enitkv@errx{\@tempa\space undefined}% 66 | \else 67 | \ifx\@empty#3\@empty 68 | \enitkv@default 69 | \else 70 | \enitkv@@sp@def\@tempb{#2}% 71 | \expandafter\@tempc\expandafter{\@tempb}\relax 72 | \fi 73 | \fi 74 | \fi} 75 | 76 | \def\enitkv@default{% 77 | \expandafter\let\expandafter\@tempb 78 | \csname\enitkv@prefix\@tempa @default\endcsname 79 | \ifx\@tempb\relax 80 | \enitkv@err{No value specified for \@tempa}% 81 | \else 82 | \@tempb\relax 83 | \fi} 84 | 85 | \def\enitkv@errx#1{\enit@error{#1}\@ehc} 86 | 87 | \let\enitkv@err\enitkv@errx 88 | 89 | \def\@tempa#1{% 90 | \def\enitkv@@sp@def##1##2{% 91 | \futurelet\enitkv@tempa\enitkv@@sp@d##2\@nil\@nil#1\@nil\relax##1}% 92 | \def\enitkv@@sp@d{% 93 | \ifx\enitkv@tempa\@sptoken 94 | \expandafter\enitkv@@sp@b 95 | \else 96 | \expandafter\enitkv@@sp@b\expandafter#1% 97 | \fi}% 98 | \def\enitkv@@sp@b#1##1 \@nil{\enitkv@@sp@c##1}} 99 | 100 | \@tempa{ } 101 | 102 | \def\enitkv@@sp@c#1\@nil#2\relax#3{\enitkv@toks@{#1}\edef#3{\the\enitkv@toks@}} 103 | 104 | \@ifundefined{KV@toks@} 105 | {\newtoks\enitkv@toks@} 106 | {\let\enitkv@toks@\KV@toks@} 107 | 108 | \def\enitkv@key#1#2{% 109 | \@ifnextchar[% 110 | {\enitkv@def{enumitem#1}{#2}}% 111 | {\@namedef{enitkv@enumitem#1@#2}####1}} 112 | 113 | \def\enitkv@def#1#2[#3]{% 114 | \@namedef{enitkv@#1@#2@default\expandafter}\expandafter 115 | {\csname enitkv@#1@#2\endcsname{#3}}% 116 | \@namedef{enitkv@#1@#2}##1} 117 | 118 | % This ends the code copied from keyval (under LPPL). 119 | 120 | % +=============================+ 121 | % | DEFINITIONS | 122 | % +=============================+ 123 | % 124 | % (1) The package uses a token register very often. To be on the 125 | % safe side, instead of \toks@, etc., a new one is declared. 126 | % (2) \enit@inbox is the box storing the items in boxed inline 127 | % lists. 128 | % (3) \enit@outerparindent is used to save the outer parindent 129 | % so that it can be used in the key parindent 130 | % (4) \enit@type has three values: 0 = enum, 1 = item, 2 = desc. 131 | % (5) \enit@calc stores which dimen is to be computed: 132 | % 0=labelindent, 1=labelwidth, 2=labelsep, 3=leftmargin, 133 | % 4=itemindent 134 | % (6) \enit@resuming has four values: 0 = none, 1 = series, 135 | % 2 = resume* series (computed in group enumitem-resume), 136 | % 3 = resume* list (ie, with no value). 137 | 138 | \chardef \enit@iv=4 139 | \newlength\labelindent 140 | \newdimen \enit@outerparindent 141 | \newtoks \enit@toks 142 | \newbox \enit@inbox 143 | 144 | \newif\ifenit@boxmode 145 | \newif\ifenit@sepfrommargin 146 | \newif\ifenit@lblfrommargin 147 | \newif\ifenit@calcwidest 148 | \newif\ifenit@nextline 149 | \newif\ifenit@boxdesc 150 | 151 | % An alias (calc-savvy): 152 | 153 | \let\c@enit@cnt\@tempcnta 154 | 155 | \def\enit@meaning{\expandafter\strip@prefix\meaning} 156 | \def\enit@noexcs#1{\expandafter\noexpand\csname#1\endcsname} 157 | 158 | \long\def\enit@afterelse#1\else#2\fi{\fi#1} 159 | \long\def\enit@afterfi#1\fi{\fi#1} 160 | \def\enit@ifunset#1{% 161 | \expandafter\ifx\csname#1\endcsname\relax 162 | \expandafter\@firstoftwo 163 | \else 164 | \expandafter\@secondoftwo 165 | \fi} 166 | \enit@ifunset{ifcsname}% 167 | {}% 168 | {\def\enit@ifunset#1{% 169 | \ifcsname#1\endcsname 170 | \expandafter\ifx\csname#1\endcsname\relax 171 | \enit@afterelse\expandafter\@firstoftwo 172 | \else 173 | \enit@afterfi\expandafter\@secondoftwo 174 | \fi 175 | \else 176 | \expandafter\@firstoftwo 177 | \fi}} 178 | 179 | % Miscellaneous errors 180 | % =================== 181 | 182 | \def\enit@error{\PackageError{enumitem}} 183 | 184 | \def\enit@checkerror#1#2{% 185 | \enit@error{Unknown value '#2' for key '#1'}% 186 | {See the manual for valid values}} 187 | 188 | \def\enit@itemerror{% 189 | \enit@error{Misplaced \string\item}% 190 | {Either there is some text before the first\MessageBreak 191 | item or the last item has no text}} 192 | 193 | \def\enit@noserieserror#1{% 194 | \enit@error{Series '#1' not started}% 195 | {You are trying to continue a series\MessageBreak 196 | which has not been started with 'series'}} 197 | 198 | \def\enit@checkseries#1{% 199 | \ifcase\enit@resuming 200 | \enit@error{Misplaced key '#1'}% 201 | {'series' and 'resume*' must be used\MessageBreak 202 | in the optional argument of lists}% 203 | \fi} 204 | 205 | \def\enit@checkseries@m{% 206 | \ifcase\enit@resuming\else 207 | \enit@error{Incompatible series settings}% 208 | {'series' and 'resume*' must not be used\MessageBreak 209 | at the same time}% 210 | \fi} 211 | 212 | \let\enit@toodeep\@toodeep 213 | 214 | \def\@toodeep{% 215 | \ifnum\@listdepth>\enit@listdepth\relax 216 | \enit@toodeep 217 | \else 218 | \count@\@listdepth 219 | \global\advance\@listdepth\@ne 220 | \enit@ifunset{@list\romannumeral\the\@listdepth}% 221 | {\expandafter\let 222 | \csname @list\romannumeral\the\@listdepth\expandafter\endcsname 223 | \csname @list\romannumeral\the\count@\endcsname}{}% 224 | \fi} 225 | 226 | % +=============================+ 227 | % | KEYS | 228 | % +=============================+ 229 | % 230 | % Including code executed by keys. 231 | % 232 | % There are 2 keyval groups: enumitem, and enumitem-delayed. 233 | % The latter is used to make sure a prioritary key is the latest one; 234 | % eg, ref, so that the ref format set by label is overridden. So, when 235 | % this key is found in enumitem, nothing is done, except the key/value 236 | % is moved to enumitem-delayed. 237 | % 238 | % A further group (enumitem-resume) catches resume* and series in 239 | % optional arguments in lists. 240 | % 241 | % Vertical spacing 242 | % ================ 243 | 244 | \enitkv@key{}{topsep}{% 245 | \enit@setlength\topsep{#1}} 246 | 247 | \enitkv@key{}{itemsep}{% 248 | \enit@setlength\itemsep{#1}} 249 | 250 | \enitkv@key{}{parsep}{% 251 | \enit@setlength\parsep{#1}} 252 | 253 | \enitkv@key{}{partopsep}{% 254 | \enit@setlength\partopsep{#1}} 255 | 256 | % Horizontal spacing 257 | % ================== 258 | % 259 | % There are 3 cases: *, ! and a value. The latter also 260 | % cancels widest with the sequence key=* ... key=value 261 | % \string is used, just in case some package changes the 262 | % catcodes. 263 | 264 | \def\enit@calcset#1#2#3{% 265 | \if\string*\string#3% 266 | \enit@calcwidesttrue 267 | \let\enit@calc#2% 268 | \else\if\string!\string#3% 269 | \enit@calcwidestfalse 270 | \let\enit@calc#2% 271 | \else 272 | \ifnum\enit@calc=#2% 273 | \enit@calcwidestfalse 274 | \let\enit@calc\z@ 275 | \fi 276 | \enit@setlength#1{#3}% 277 | \fi\fi} 278 | 279 | \def\enitkv@enumitem@widest#1{% 280 | \ifcase\enit@type % enumerate 281 | \expandafter\let\csname enit@cw@\@enumctr\endcsname\relax 282 | \@namedef{enit@widest@\@enumctr}##1{\enit@format{#1}}% 283 | \else % itemize / description 284 | \def\enit@widest@{\enit@format{#1}}% 285 | \fi} 286 | 287 | \def\enitkv@enumitem@widest@default{% 288 | \expandafter\let\csname enit@cw@\@enumctr\endcsname\relax 289 | \expandafter\let\csname enit@widest@\@enumctr\endcsname\relax} 290 | 291 | \enitkv@key{}{widest*}{% 292 | \setcounter{enit@cnt}{#1}% 293 | \expandafter\edef\csname enit@cw@\@enumctr\endcsname 294 | {\the\c@enit@cnt}% 295 | \expandafter\edef\csname enit@widest@\@enumctr\endcsname##1% 296 | {##1{\the\c@enit@cnt}}} 297 | 298 | \enitkv@key{}{labelindent*}{% 299 | \enit@lblfrommargintrue 300 | \ifnum\enit@calc=\z@ 301 | \enit@calcwidestfalse 302 | \fi 303 | \enit@setlength\labelindent{#1}% 304 | \advance\labelindent\leftmargin} 305 | 306 | \enitkv@key{}{labelindent}{% 307 | \enit@lblfrommarginfalse 308 | \enit@calcset\labelindent\z@{#1}} 309 | 310 | \enitkv@key{}{labelwidth}{% 311 | \enit@calcset\labelwidth\@ne{#1}} 312 | 313 | \enitkv@key{}{leftmargin}{% 314 | \edef\enit@c{\the\leftmargin}% 315 | \enit@calcset\leftmargin\thr@@{#1}% 316 | \ifenit@lblfrommargin 317 | \advance\labelindent-\enit@c\relax 318 | \advance\labelindent\leftmargin 319 | \fi} 320 | 321 | \enitkv@key{}{itemindent}{% 322 | \edef\enit@c{\the\itemindent}% 323 | \enit@calcset\itemindent\enit@iv{#1}% 324 | \ifenit@sepfrommargin 325 | \advance\labelsep-\enit@c\relax 326 | \advance\labelsep\itemindent 327 | \fi} 328 | 329 | \enitkv@key{}{listparindent}{% 330 | \enit@setlength\listparindent{#1}} 331 | 332 | \enitkv@key{}{rightmargin}{% 333 | \enit@setlength\rightmargin{#1}} 334 | 335 | % labelsep, from itemindent; labelsep*, from leftmargin 336 | 337 | \enitkv@key{}{labelsep*}{% 338 | \enit@sepfrommargintrue 339 | \ifnum\enit@calc=\tw@ 340 | \enit@calcwidestfalse 341 | \let\enit@calc\z@ 342 | \fi 343 | \enit@setlength\labelsep{#1}% 344 | \advance\labelsep\itemindent} 345 | 346 | \enitkv@key{}{labelsep}{% 347 | \enit@sepfrommarginfalse 348 | \enit@calcset\labelsep\tw@{#1}} 349 | 350 | \enitkv@key{}{left}{% 351 | \enit@setleft#1..\@empty..\@@} 352 | 353 | \def\enit@setleft#1..#2..#3\@@{% 354 | \enit@setlength\labelindent{#1}% 355 | \edef\enit@a{#3}% 356 | \ifx\enit@a\@empty 357 | \enit@calcset\leftmargin\thr@@*% 358 | \else 359 | \enit@setlength\leftmargin{#2}% 360 | \enit@calcset\labelsep\tw@*% 361 | \fi} 362 | 363 | % Series, resume and start 364 | % ======================== 365 | 366 | \enitkv@key{-resume}{series}{% 367 | \enit@checkseries@m 368 | \let\enit@resuming\@ne %%% TODO - default check also \Set..Key 369 | \ifcase\enit@seriesopt 370 | \enit@ifunset{enitkv@enumitem@#1}{}% 371 | {\enit@error 372 | {Invalid series name '#1'}% 373 | {Do not name a series with an existing key}}% 374 | \else % series=override 375 | \global\@namedef{enitkv@enumitem@#1}% with value 376 | {\enit@error 377 | {Key '#1' has been overridden by a series}% 378 | {Change the series name and/or deactivate series=override}}% 379 | \global\@namedef{enitkv@enumitem@#1@default}{}% 380 | \fi 381 | \def\enit@series{#1}} 382 | 383 | \enitkv@key{}{series}{% 384 | \enit@checkseries{series}} 385 | 386 | \def\enitkv@enumitem@resume#1{% 387 | \edef\enit@series{#1}% 388 | \@nameuse{enit@resume@series@#1}\relax} 389 | 390 | \def\enitkv@enumitem@resume@default{% 391 | \@nameuse{enit@resume@\@currenvir}\relax} 392 | 393 | \@namedef{enitkv@enumitem-resume@resume*}#1{% 394 | \enit@checkseries@m 395 | \let\enit@resuming\tw@ 396 | \edef\enit@series{#1}% 397 | \enit@ifunset{enit@resumekeys@series@#1}% 398 | {\enit@noserieserror{#1}}% 399 | {\expandafter\let\expandafter\enit@resumekeys 400 | \csname enit@resumekeys@series@#1\endcsname}} 401 | 402 | \@namedef{enitkv@enumitem-resume@resume*@default}{% 403 | \let\enit@resuming\thr@@ 404 | \expandafter\let\expandafter\enit@resumekeys 405 | \csname enit@resumekeys@\@currenvir\endcsname 406 | \@nameuse{enit@resume@\@currenvir}\relax} 407 | 408 | \@namedef{enitkv@enumitem-resume@resume*@default}{% 409 | \let\enit@resuming\thr@@ 410 | \enit@ifunset{enit@resumekeys@\@currenvir}% 411 | {\PackageWarning{enumitem}{Nothing to resume,}% 412 | \let\enit@resumekeys\@empty} 413 | {\let\enit@resuming\thr@@ 414 | \expandafter\let\expandafter\enit@resumekeys 415 | \csname enit@resumekeys@\@currenvir\endcsname 416 | \@nameuse{enit@resume@\@currenvir}\relax}} 417 | 418 | \enitkv@key{}{resume*}[]{% 419 | \enit@checkseries{resume*}} 420 | 421 | \newcommand\restartlist[1]{% 422 | \enit@ifunset{end#1}% 423 | {\enit@error{Undefined list '#1'}% 424 | {No list has been defined with that name.}}% 425 | {\expandafter\let 426 | \csname enit@resume@#1\endcsname\@empty}} 427 | 428 | \enitkv@key{}{start}[\@ne]{% 429 | \setcounter{\@listctr}{#1}% 430 | \advance\@nameuse{c@\@listctr}\m@ne} 431 | 432 | % Penalties 433 | % ========= 434 | 435 | \enitkv@key{}{beginpenalty}{% 436 | \@beginparpenalty#1\relax} 437 | 438 | \enitkv@key{}{midpenalty}{% 439 | \@itempenalty#1\relax} 440 | 441 | \enitkv@key{}{endpenalty}{% 442 | \@endparpenalty#1\relax} 443 | 444 | % Font/Format 445 | % =========== 446 | 447 | \enitkv@key{}{format}{% 448 | \def\enit@format{#1}} 449 | 450 | \enitkv@key{}{font}{% 451 | \def\enit@format{#1}} 452 | 453 | % Description styles 454 | % ================== 455 | 456 | \enitkv@key{}{style}[normal]{% 457 | \enit@ifunset{enit@style@#1}% 458 | {\enit@checkerror{style}{#1}}% 459 | {\enit@nextlinefalse 460 | \enit@boxdescfalse 461 | \@nameuse{enit@style@#1}% 462 | \edef\enit@descstyle{\enit@noexcs{enit@#1style}}}} 463 | 464 | \def\enit@style@standard{% 465 | \enit@boxdesctrue 466 | \enit@calcset\itemindent\enit@iv!} 467 | 468 | \let\enit@style@normal\enit@style@standard 469 | 470 | \def\enit@style@unboxed{% 471 | \enit@calcset\itemindent\enit@iv!} 472 | 473 | \def\enit@style@sameline{% 474 | \enit@calcset\labelwidth\@ne!} 475 | 476 | \def\enit@style@multiline{% 477 | \enit@align@parleft 478 | \enit@calcset\labelwidth\@ne!} 479 | 480 | \def\enit@style@nextline{% 481 | \enit@nextlinetrue 482 | \enit@calcset\labelwidth\@ne!} 483 | 484 | % Labels and refs 485 | % =============== 486 | 487 | % Alignment 488 | % -------- 489 | 490 | \enitkv@key{}{align}{% 491 | \enit@ifunset{enit@align@#1}% 492 | {\enit@checkerror{align}{#1}}% 493 | {\csname enit@align@#1\endcsname}} 494 | 495 | % \nobreak for unboxed label with color. See below. 496 | 497 | \newcommand\SetLabelAlign[2]{% 498 | \enit@toks{#2}% 499 | \expandafter\edef\csname enit@align@#1\endcsname 500 | {\def\noexpand\enit@align####1{\nobreak\the\enit@toks}}} 501 | 502 | \def\enit@align@right{% 503 | \def\enit@align##1{\nobreak\hss\llap{##1}}} 504 | 505 | \def\enit@align@left{% 506 | \def\enit@align##1{\nobreak##1\hfil}} 507 | 508 | \def\enit@align@parleft{% 509 | \def\enit@align##1{% 510 | \nobreak 511 | \strut\smash{\parbox[t]\labelwidth{\raggedright##1}}}} 512 | 513 | % \enit@ref has three possible definitions: 514 | % (1) \relax, if there is neither label nor ref (ie, use 515 | % LaTeX settings). 516 | % (2) set ref to @itemlabel, if there is label but not ref 517 | % (3) set ref to ref, if there is ref (with or without label) 518 | 519 | \enitkv@key{}{label}{% 520 | \expandafter\def\@itemlabel{#1}% 521 | \def\enit@ref{\expandafter\enit@reflabel\@itemlabel\z@}} 522 | 523 | \enitkv@key{}{label*}{% 524 | \ifnum\enit@depth=\@ne 525 | \expandafter\def\@itemlabel{#1}% 526 | \else % no level 0 527 | \advance\enit@depth\m@ne 528 | \enit@toks{#1}% 529 | \expandafter\edef\@itemlabel{% 530 | \enit@noexcs{label\enit@prevlabel}% 531 | \the\enit@toks}% 532 | \advance\enit@depth\@ne 533 | \fi 534 | \def\enit@ref{\expandafter\enit@reflabel\@itemlabel\z@}} 535 | 536 | % ref is set by label, except if there is an explicit ref in the same 537 | % hierarchy level. Explicit refs above the current hierarchy level are 538 | % overridden by label (besides ref), too. Since an explicit ref has 539 | % preference, it's delayed. 540 | 541 | \enitkv@key{}{ref}{% 542 | \g@addto@macro\enit@delayedkeys{,ref=#1}} 543 | 544 | \enitkv@key{-delayed}{ref}{% 545 | \def\enit@ref{\enit@reflabel{#1}\@ne}} 546 | 547 | % #2=0 don't "normalize" (ie, already normalized) 548 | % =1 "normalize" (in key ref) 549 | % Used thru \enit@ref 550 | 551 | \def\enit@reflabel#1#2{% 552 | \ifnum\enit@depth=\@ne\else % no level 0 553 | \advance\enit@depth\@ne 554 | \@namedef{p@\@enumctr}{}% Don't accumulate labels 555 | \advance\enit@depth\m@ne 556 | \fi 557 | \ifcase#2% 558 | \@namedef{the\@enumctr}{{#1}}% 559 | \else 560 | \enit@normlabel{\csname the\@enumctr\endcsname}{#1}% 561 | \fi} 562 | 563 | % \xxx* in counters (refstar) and widest (calcdef) 564 | % ------------------------------------------------ 565 | % \enit@labellist contains a list of 566 | % \enit@elt{widest}\count\@count\enit@sc@@count 567 | % \enit@elt is either \enit@getwidth or \enit@refstar, defined 568 | % below 569 | % The current implementation is sub-optimal -- labels are stored in 570 | % labellist, counters defined again when processing labels, and 571 | % modifying it is almost impossible. 572 | 573 | \let\enit@labellist\@empty 574 | 575 | \newcommand\AddEnumerateCounter{% 576 | \@ifstar\enit@addcounter@s\enit@addcounter} 577 | 578 | \def\enit@addcounter#1#2#3{% 579 | \enit@toks\expandafter{% 580 | \enit@labellist 581 | \enit@elt{#3}}% 582 | \edef\enit@labellist{% 583 | \the\enit@toks 584 | \enit@noexcs{\expandafter\@gobble\string#1}% 585 | \enit@noexcs{\expandafter\@gobble\string#2}% 586 | \enit@noexcs{enit@sc@\expandafter\@gobble\string#2}}} 587 | 588 | \def\enit@addcounter@s#1#2#3{% 589 | \enit@addcounter{#1}{#2}% 590 | {\@nameuse{enit@sc@\expandafter\@gobble\string#2}{#3}}} 591 | 592 | % The 5 basic counters: 593 | 594 | \AddEnumerateCounter\arabic\@arabic{0} 595 | \AddEnumerateCounter\alph\@alph{m} 596 | \AddEnumerateCounter\Alph\@Alph{M} 597 | \AddEnumerateCounter\roman\@roman{viii} 598 | \AddEnumerateCounter\Roman\@Roman{VIII} 599 | 600 | % Inline lists 601 | % ============ 602 | % 603 | % Labels 604 | % ------ 605 | 606 | \enitkv@key{}{itemjoin}{% 607 | \def\enit@itemjoin{#1}} 608 | 609 | \enitkv@key{}{itemjoin*}{% 610 | \def\enit@itemjoin@s{#1}} 611 | 612 | \enitkv@key{}{afterlabel}{% 613 | \def\enit@afterlabel{#1}} 614 | 615 | % Mode 616 | % ---- 617 | 618 | \enitkv@key{}{mode}{% 619 | \enit@ifunset{enit@mode#1}% 620 | {\enit@checkerror{mode}{#1}}% 621 | {\csname enit@mode#1\endcsname}} 622 | 623 | \let\enit@modeboxed\enit@boxmodetrue 624 | \let\enit@modeunboxed\enit@boxmodefalse 625 | 626 | % Short Labels 627 | % ============ 628 | 629 | \let\enit@marklist\@empty 630 | 631 | % shorthand, expansion: 632 | 633 | \newcommand\SetEnumerateShortLabel[2]{% 634 | \let\enit@a\@empty 635 | \def\enit@elt##1##2{% 636 | \def\enit@b{#1}\def\enit@c{##1}% 637 | \ifx\enit@b\enit@c\else 638 | \expandafter\def\expandafter\enit@a\expandafter{% 639 | \enit@a 640 | \enit@elt{##1}{##2}}% 641 | \fi}% 642 | \enit@marklist 643 | \expandafter\def\expandafter\enit@a\expandafter{% 644 | \enit@a 645 | \enit@elt{#1}{#2}}% 646 | \let\enit@marklist\enit@a} 647 | 648 | \SetEnumerateShortLabel{a}{\alph*} 649 | \SetEnumerateShortLabel{A}{\Alph*} 650 | \SetEnumerateShortLabel{i}{\roman*} 651 | \SetEnumerateShortLabel{I}{\Roman*} 652 | \SetEnumerateShortLabel{1}{\arabic*} 653 | 654 | % This is called \enit@first one,two,three,\@nil\@@nil. If there 655 | % are just one element #2 is \@nil, otherwise we have to remove 656 | % the trailing ,\@nil with enit@first@x 657 | % Called with the keys in \enit@c 658 | % Returns enit@toks 659 | 660 | \def\enit@first#1,#2\@@nil{% 661 | \in@{=}{#1}% Quick test, if contains =, it's key=value 662 | \ifin@\else 663 | \enitkv@@sp@def\enit@a{#1}% 664 | \enit@ifunset{enitkv@enumitem@\enit@meaning\enit@a}% 665 | {\ifnum\enit@type=\z@ 666 | \def\enit@elt{\enit@replace\enit@a}% 667 | \enit@marklist % Returns \enit@toks 668 | \else 669 | \enit@toks{#1}% 670 | \fi 671 | \ifx\@nil#2% 672 | \ifx,#1,\else 673 | \edef\enit@c{label=\the\enit@toks}% 674 | \fi 675 | \else 676 | \@temptokena\expandafter{\enit@first@x#2}% 677 | \edef\enit@c{label=\the\enit@toks,\the\@temptokena}% 678 | \fi}% 679 | {}% 680 | \fi 681 | \enit@toks\expandafter{\enit@c}} 682 | 683 | \def\enit@first@x#1,\@nil{#1} 684 | 685 | \def\enit@replace#1#2#3{% 686 | \enit@toks{}% 687 | \def\enit@b##1#2##2\@@nil{% 688 | \ifx\@nil##2% 689 | \addto@hook\enit@toks{##1}% 690 | \else 691 | \edef\enit@a{\the\enit@toks}% 692 | \ifx\enit@a\@empty\else 693 | \enit@error{Extra short label ignored}% 694 | {There are more than one short label}% 695 | \fi 696 | \addto@hook\enit@toks{##1#3}% 697 | \enit@b##2\@@nil 698 | \fi}% 699 | \expandafter\enit@b#1#2\@nil\@@nil 700 | \edef#1{\the\enit@toks}} 701 | 702 | % Pre and post code 703 | % ================= 704 | 705 | \enitkv@key{}{before}{% 706 | \def\enit@before{#1}} 707 | 708 | \enitkv@key{}{before*}{% 709 | \expandafter\def\expandafter\enit@before\expandafter 710 | {\enit@before#1}} 711 | 712 | \enitkv@key{}{after}{% 713 | \def\enit@after{#1}} 714 | 715 | \enitkv@key{}{after*}{% 716 | \expandafter\def\expandafter\enit@after\expandafter 717 | {\enit@after#1}} 718 | 719 | \enitkv@key{}{first}{% 720 | \def\enit@keyfirst{#1}} 721 | 722 | \enitkv@key{}{first*}{% 723 | \expandafter\def\expandafter\enit@keyfirst\expandafter 724 | {\enit@keyfirst#1}} 725 | 726 | % Miscellaneous keys 727 | % ================ 728 | 729 | \enitkv@key{}{nolistsep}[true]{% 730 | \partopsep=\z@skip 731 | \topsep=\z@ plus .1pt 732 | \itemsep=\z@skip 733 | \parsep=\z@skip} 734 | 735 | \enitkv@key{}{nosep}[true]{% 736 | \partopsep=\z@skip 737 | \topsep=\z@skip 738 | \itemsep=\z@skip 739 | \parsep=\z@skip} 740 | 741 | \enitkv@key{}{noitemsep}[true]{% 742 | \itemsep=\z@skip 743 | \parsep=\z@skip} 744 | 745 | \enitkv@key{}{wide}[\parindent]{% 746 | \enit@align@left 747 | \leftmargin\z@ 748 | \labelwidth\z@ 749 | \enit@setlength\labelindent{#1}% 750 | \listparindent\labelindent 751 | \enit@calcset\itemindent\enit@iv!} 752 | 753 | % The following is deprecated in favour of wide: 754 | 755 | \enitkv@key{}{fullwidth}[true]{% 756 | \leftmargin\z@ 757 | \labelwidth\z@ 758 | \def\enit@align##1{\hskip\labelsep##1}} 759 | 760 | % "Abstract" layer 761 | % ================ 762 | % 763 | % Named values 764 | % ------------ 765 | 766 | \newcommand\SetEnumitemValue[2]{% Implicit #3 767 | \enit@ifunset{enit@enitkv@#1}% 768 | {\enit@ifunset{enitkv@enumitem@#1}% 769 | {\enit@error{Wrong key '#1' in \string\SetEnumitemValue}% 770 | {Perhaps you have misspelled it}}{}% 771 | \expandafter\let\csname enit@enitkv@#1\expandafter\endcsname 772 | \csname enitkv@enumitem@#1\endcsname}{}% 773 | \@namedef{enitkv@enumitem@#1}##1{% 774 | \def\enit@a{##1}% 775 | \enit@ifunset{enit@enitkv@#1@\enit@meaning\enit@a}% 776 | {\@nameuse{enit@enitkv@#1}{##1}}% 777 | {\@nameuse{enit@enitkv@#1\expandafter\expandafter\expandafter}% 778 | \expandafter\expandafter\expandafter 779 | {\csname enit@enitkv@#1@##1\endcsname}}{}}% 780 | \@namedef{enit@enitkv@#1@#2}} 781 | 782 | % Defining keys 783 | % ------------- 784 | 785 | \newcommand\SetEnumitemKey[2]{% 786 | \enit@ifunset{enitkv@enumitem@#1}% 787 | {\enitkv@key{}{#1}[]{\enitkv@setkeys{enumitem}{#2}}}% 788 | {\enit@error{Duplicated key '#1' in \string\SetEnumitemKey}% 789 | {There already exists a key with that name}}} 790 | 791 | % +=============================+ 792 | % | PROCESSING KEYS | 793 | % +=============================+ 794 | % 795 | % Set keys 796 | % ======== 797 | % 798 | % Default definition. Modified below with package option 'sizes'. 799 | 800 | \def\enit@setkeys#1{% 801 | \enit@ifunset{enit@@#1}{}% 802 | {\expandafter\expandafter\expandafter 803 | \enit@setkeys@i\csname enit@@#1\endcsname\@@}} 804 | 805 | % The following is used directly in resumeset: 806 | 807 | \def\enit@setkeys@i#1\@@{% 808 | \let\enit@delayedkeys\@empty 809 | \enit@shl{#1}% is either \enit@toks or returns it 810 | \expandafter\enit@setkeys@ii\the\enit@toks\@@} 811 | 812 | \def\enit@setkeys@ii#1\@@{% 813 | \enitkv@setkeys{enumitem}{#1}% 814 | \enit@toks\expandafter{\enit@delayedkeys}% 815 | \edef\enit@a{% 816 | \noexpand\enitkv@setkeys{enumitem-delayed}{\the\enit@toks}}% 817 | \enit@a} 818 | 819 | % Handling * and ! values 820 | % ======================= 821 | % 822 | % \@gobbletwo removes \c from \c@counter. 823 | 824 | \def\enit@getwidth#1#2#3#4{% 825 | \let#4#3% 826 | \def#3##1{% 827 | \enit@ifunset{enit@widest\expandafter\@gobbletwo\string##1}% if no widest=key 828 | {#1}% 829 | {\csname enit@widest\expandafter\@gobbletwo\string##1\endcsname{#4}}}} 830 | 831 | \def\enit@valueerror#1{\z@ % if after an assignment, but doesn't catch \ifnum 832 | \enit@error{No default \string\value\space for '#1'}% 833 | {You can provide one with widest*}}% 834 | 835 | \let\enit@values\@empty 836 | 837 | \def\enit@calcwidth{% 838 | \ifenit@calcwidest 839 | \ifcase\enit@type % ie, enum 840 | \enit@ifunset{enit@cw@\@enumctr}% 841 | {\@namedef{enit@cv@\@enumctr}{\enit@valueerror\@enumctr}}% 842 | {\edef\enit@values{% 843 | \enit@values 844 | \@nameuse{c@\@enumctr}\@nameuse{enit@cw@\@enumctr}\relax}% 845 | \expandafter 846 | \edef\csname enit@cv@\@enumctr\endcsname 847 | {\@nameuse{c@\@enumctr}}}% 848 | \begingroup 849 | \enit@values 850 | \def\value##1{\csname enit@cv@##1\endcsname}% 851 | \let\enit@elt\enit@getwidth 852 | \enit@labellist 853 | \settowidth\labelwidth{\@itemlabel}% 854 | \xdef\enit@a{\labelwidth\the\labelwidth\relax}% 855 | \endgroup 856 | \enit@a 857 | \or % ie, item 858 | \ifx\enit@widest@\relax 859 | \settowidth\labelwidth{\@itemlabel}% 860 | \else 861 | \settowidth\labelwidth{\enit@widest@}% 862 | \fi 863 | \else % ie, desc 864 | \ifx\enit@widest@\relax 865 | \settowidth\labelwidth{\@itemlabel}% 866 | \else 867 | \settowidth\labelwidth{\makelabel{\enit@widest@}}% 868 | \fi 869 | \advance\labelwidth-\labelsep 870 | \fi 871 | \fi 872 | \advance\dimen@-\labelwidth} 873 | 874 | \def\enit@calcleft{% 875 | \dimen@\leftmargin 876 | \advance\dimen@\itemindent 877 | \advance\dimen@-\labelsep 878 | \advance\dimen@-\labelindent 879 | \ifcase\enit@calc % = 0 = labelindent 880 | \enit@calcwidth 881 | \advance\labelindent\dimen@ 882 | \or % = 1 = labelwidth, so no \enit@calcwidth 883 | \labelwidth\dimen@ 884 | \or % = 2 = labelsep 885 | \enit@calcwidth 886 | \advance\labelsep\dimen@ 887 | \or % = 3 = leftmargin 888 | \enit@calcwidth 889 | \advance\leftmargin-\dimen@ 890 | \or % = 4 =itemindent 891 | \enit@calcwidth 892 | \advance\itemindent-\dimen@ 893 | \fi} 894 | 895 | \def\enit@negwidth{% 896 | \ifdim\labelwidth<\z@ 897 | \PackageWarning{enumitem}% 898 | {Negative labelwidth. This does not make much\MessageBreak 899 | sense,}% 900 | \fi} 901 | 902 | % "Normalizing" labels 903 | % ==================== 904 | % 905 | % Replaces \counter* by \counter{level} (those in \enit@labellist). 906 | % 907 | % #1 is either \csname...\endcsmame or the container \@itemlabel -- 908 | % hence \expandafter 909 | 910 | \def\enit@refstar@i#1#2{% 911 | \if*#2\@empty 912 | \noexpand#1{\@enumctr}% 913 | \else 914 | \noexpand#1{#2}% 915 | \fi}% 916 | 917 | % Suggested by @muzimuzhi, amended. See Gh36. 918 | 919 | \def\enit@refstar@ii#1#2{% 920 | \if*#2\@empty 921 | \noexpand\the\noexpand#1{\@enumctr}% 922 | \else 923 | \noexpand\the\noexpand#1{#2}% 924 | \fi} 925 | 926 | \def\enit@refstar#1#2#3#4{% 927 | \def#2{\enit@refstar@i#2}% 928 | \def#3{\enit@refstar@i#3}} 929 | 930 | \def\enit@normlabel#1#2{% 931 | \begingroup 932 | \def\value{\enit@refstar@ii\value}% 933 | \let\enit@elt\enit@refstar 934 | \enit@labellist 935 | % Added braces as \ref is in the global scope: 936 | \protected@xdef\enit@a{{#2}}% 937 | \endgroup 938 | \expandafter\let#1\enit@a} 939 | 940 | % Preliminary settings and default values 941 | % ======================================= 942 | 943 | \def\enit@prelist#1#2#3{% 944 | \let\enit@type#1% 945 | \def\enit@depth{#2}% 946 | \edef\enit@prevlabel{#3\romannumeral#2}% 947 | \advance#2\@ne} 948 | 949 | \newcount\enit@count@id 950 | 951 | \def\enit@tagid{% 952 | \global\advance\enit@count@id\@ne 953 | \edef\EnumitemId{\number\enit@count@id}} 954 | 955 | \def\enit@preset#1#2#3{% 956 | \enit@tagid 957 | \enit@sepfrommarginfalse 958 | \enit@calcwidestfalse 959 | \let\enit@widest@\relax 960 | \let\enit@resuming\z@ 961 | \let\enit@series\relax 962 | \enit@boxmodetrue 963 | \def\enit@itemjoin{ }% 964 | \let\enit@itemjoin@s\relax 965 | \let\enit@afterlabel\nobreakspace 966 | \let\enit@before\@empty 967 | \let\enit@after\@empty 968 | \let\enit@keyfirst\@empty 969 | \let\enit@format\@firstofone % and NOT empty 970 | \let\enit@ref\relax 971 | \labelindent\z@skip 972 | \ifnum\@listdepth=\@ne 973 | \enit@outerparindent\parindent 974 | \else 975 | \parindent\enit@outerparindent 976 | \fi 977 | \enit@setkeys{list}% 978 | \enit@setkeys{list\romannumeral\@listdepth}% 979 | \enit@setkeys{#1}% 980 | \enit@setkeys{#1\romannumeral#2}% 981 | \enit@setresume{#3}} 982 | 983 | % keyval "error" in enumitem-resume: all undefined keys (ie, all 984 | % except resume*) are ignored, but is treated like 985 | % resume*= 986 | 987 | \def\enitkv@err@a#1{% 988 | \enit@ifunset{enit@resumekeys@series@\@tempa}{}% 989 | {\@nameuse{enitkv@enumitem-resume@resume*\expandafter}% 990 | \expandafter{\@tempa}}} 991 | 992 | % keyval "error" in the optional argument: all undefined keys are 993 | % passed to the keyval error, but is ignored (already 994 | % processed in enumitem-resume) 995 | 996 | \def\enitkv@err@b#1{% 997 | \enit@ifunset{enit@resumekeys@series@\@tempa}% 998 | {\enit@savekverr{#1}}% 999 | {}} 1000 | 1001 | % Process keys in optional argument: 1002 | 1003 | \def\enit@setresume#1{% 1004 | \enit@shl{#1}% Returns enit@toks 1005 | \edef\enit@savekeys{\the\enit@toks}% 1006 | \let\enit@savekverr\enitkv@errx 1007 | \let\enitkv@errx\enitkv@err@a 1008 | \edef\enit@b{% 1009 | \noexpand\enitkv@setkeys{enumitem-resume}{\the\enit@toks}}% 1010 | \enit@b 1011 | \let\enitkv@errx\enitkv@err@b 1012 | \ifcase\enit@resuming\or\or % = 2, resume* series 1013 | \expandafter 1014 | \enit@setkeys@i\enit@resumekeys,resume=\enit@series\@@ 1015 | \or % = 3 1016 | \expandafter 1017 | \enit@setkeys@i\enit@resumekeys,resume\@@ 1018 | \fi 1019 | \expandafter\enit@setkeys@i\enit@savekeys\@@ 1020 | \let\enitkv@errx\enit@savekverr} 1021 | 1022 | % Handling <> syntax for font sizes 1023 | % ================================ 1024 | % The following code is based on LaTeX (\DeclareFontShape). Only the 1025 | % code for <> is preserved (no functions), and a default value can be 1026 | % set before the first <>. In addition, here single values take 1027 | % precedende over ranges. The original work is by the LaTeX Team, 1028 | % under license LPPL. 1029 | 1030 | \def\enit@ifnot@nil#1{% 1031 | \def\enit@a{#1}% 1032 | \ifx\enit@a\@nnil 1033 | \expandafter\@gobble 1034 | \else 1035 | \expandafter\@firstofone 1036 | \fi} 1037 | 1038 | \def\enit@remove@to@nnil#1\@nnil{} 1039 | \def\enit@remove@angles#1>{\enit@simple@size} 1040 | 1041 | \def\enit@simple@size#1<{% 1042 | \if<#1<% 1043 | \expandafter\enit@remove@angles 1044 | \else 1045 | \def\enit@c{#1}% 1046 | \expandafter\enit@remove@to@nnil 1047 | \fi} 1048 | 1049 | \def\enit@extractrange#1<#2>{% 1050 | \ifx\enit@c\relax 1051 | \def\enit@c{#1}% 1052 | \fi 1053 | \enit@isrange#2->\@nil#2>} 1054 | 1055 | \def\enit@isrange#1-#2\@nil{% 1056 | \if>#2% 1057 | \expandafter\enit@check@single 1058 | \else 1059 | \expandafter\enit@check@range 1060 | \fi} 1061 | 1062 | \def\enit@check@range#1-#2>#3<#4\@nnil{% 1063 | \enit@ifnot@nil{#3}{% 1064 | \def\enit@b{\enit@extractrange<#4\@nnil}% 1065 | \upper@bound=% 1066 | \enit@ifunset{enit@sizefor@#2}{0#2\p@}{\@nameuse{enit@sizefor@#2}\p@}% 1067 | %%% usar count@ 1068 | \ifdim\upper@bound=\z@ \upper@bound\maxdimen \fi 1069 | \ifdim\f@size\p@<\upper@bound 1070 | \lower@bound=% 1071 | \enit@ifunset{enit@sizefor@#1}{0#1\p@}{\@nameuse{enit@sizefor@#1}\p@}% 1072 | \ifdim\f@size\p@<\lower@bound 1073 | \else 1074 | \enit@simple@size#3<#4\@nnil 1075 | \fi 1076 | \fi 1077 | \enit@b}} 1078 | 1079 | \def\enit@check@single#1>#2<#3\@nnil{% 1080 | \def\enit@b{\enit@extractrange<#3\@nnil}% 1081 | \ifdim\f@size\p@= 1082 | \enit@ifunset{enit@sizefor@#1}{0#1\p@}{\@nameuse{enit@sizefor@#1}\p@}% 1083 | \enit@simple@size#2<#3\@nnil 1084 | \let\enit@d\enit@c 1085 | \fi 1086 | \enit@b} 1087 | 1088 | \def\enit@try@size@range#1{% 1089 | \def\enit@a{#1}% 1090 | \let\enit@c\relax % last in range 1091 | \let\enit@d\relax % single 1092 | \expandafter\enit@extractrange\enit@a <-*>\@nil<\@nnil 1093 | \ifx\enit@d\relax\else\let\enit@c\enit@d\fi} 1094 | 1095 | % \enit@setlength is defined in the options section 1096 | 1097 | % This ends the code adapted from latex (under LPPL). 1098 | 1099 | \def\SetEnumitemSize#1#2{% 1100 | {\let\selectfont\relax 1101 | #2% 1102 | \expandafter\xdef\csname enit@sizefor@#1\endcsname{\f@size}}} 1103 | 1104 | \SetEnumitemSize{script}\scriptsize 1105 | \SetEnumitemSize{tiny}\tiny 1106 | \SetEnumitemSize{footnote}\footnotesize 1107 | \SetEnumitemSize{small}\small 1108 | \SetEnumitemSize{normal}\normalsize 1109 | \SetEnumitemSize{large}\large 1110 | \SetEnumitemSize{Large}\Large 1111 | \SetEnumitemSize{LARGE}\LARGE 1112 | \SetEnumitemSize{huge}\huge 1113 | \SetEnumitemSize{Huge}\Huge 1114 | 1115 | % +=============================+ 1116 | % | LIST TYPES | 1117 | % +=============================+ 1118 | % 1119 | % Displayed lists 1120 | % =============== 1121 | % #1 #2 implicit 1122 | 1123 | \def\enit@dylist{% 1124 | \enit@align@right 1125 | \list} 1126 | 1127 | \def\enit@endlist{% 1128 | \enit@after 1129 | \endlist 1130 | \ifx\enit@series\relax\else % discards resume*, too 1131 | \ifnum\enit@resuming=\@ne % ie, series= 1132 | \enit@setresumekeys{series@\enit@series}\global\global 1133 | \else % ie, resume=, resume*= (save count, but not keys) 1134 | \enit@setresumekeys{series@\enit@series}\@gobblefour\global 1135 | \fi 1136 | \enit@afterlist 1137 | \fi 1138 | \ifnum\enit@resuming=\thr@@ % ie, resume* list (save count only) 1139 | \enit@setresumekeys\@currenvir\@gobblefour\@empty 1140 | \else 1141 | \enit@setresumekeys\@currenvir\@empty\@empty 1142 | \fi 1143 | \aftergroup\enit@afterlist} 1144 | 1145 | % #1 = either \@currenvir or series@ 1146 | % #2(keys) #3(counter) are \global, \@gobblefour or \@empty 1147 | 1148 | \def\enit@setresumekeys#1#2#3{% 1149 | \enit@toks\expandafter{\enit@savekeys}% 1150 | \xdef\enit@afterlist{% 1151 | #2\def\enit@noexcs{enit@resumekeys@#1}{\the\enit@toks}% 1152 | \ifnum\enit@type=\z@ % ie, enum 1153 | #3\def\enit@noexcs{enit@resume@#1}{% 1154 | \csname c@\@listctr\endcsname 1155 | \the\csname c@\@listctr\endcsname}% 1156 | \fi}} 1157 | 1158 | % Inline lists 1159 | % ============ 1160 | 1161 | % Definition of \@trivlist inside inline lists. So, when 1162 | % \@trivlist is found in any displayed list (including quote, 1163 | % center, verbatim...) the default \@item is restored. 1164 | 1165 | \def\enit@intrivlist{% 1166 | \enit@changed@itemfalse 1167 | \let\@item\enit@outer@item 1168 | \let\par\@@par 1169 | \let\@trivlist\enit@outer@triv 1170 | \@trivlist} 1171 | 1172 | % Keep track of \@item and \item changes 1173 | 1174 | \newif\ifenit@changed@item 1175 | \enit@changed@itemfalse 1176 | 1177 | \newif\ifenit@changeditem 1178 | \enit@changeditemfalse 1179 | 1180 | % List 1181 | % ---- 1182 | 1183 | % Arguments, as before: 1184 | % \enitdp@, , , 1185 | % About @newlist, see @initem. 1186 | 1187 | \def\enit@inlist#1#2{% 1188 | \ifnum\@listdepth>\enit@listdepth\relax 1189 | \@toodeep 1190 | \else 1191 | \global\advance\@listdepth\@ne 1192 | \fi 1193 | \let\enit@align\@firstofone 1194 | \def\@itemlabel{#1}% 1195 | \@nmbrlistfalse 1196 | \ifenit@changed@item\else 1197 | \enit@changed@itemtrue 1198 | \let\enit@outer@triv\@trivlist 1199 | \let\@trivlist\enit@intrivlist 1200 | \@setpar\@empty 1201 | \let\enit@outer@item\@item 1202 | \fi 1203 | #2\relax 1204 | \global\@newlisttrue 1205 | \ifenit@boxmode 1206 | \ifenit@changeditem\else 1207 | \enit@changeditemtrue 1208 | \let\enit@outeritem\item 1209 | \fi 1210 | \let\@item\enit@boxitem 1211 | \else 1212 | \let\@item\enit@noboxitem 1213 | \ifx\enit@itemjoin@s\relax\else 1214 | \PackageWarning{enumitem}% 1215 | {itemjoin* discarded in mode unboxed\MessageBreak}% 1216 | \fi 1217 | \fi 1218 | \let\enit@calcleft\relax 1219 | \let\enit@afteritem\relax 1220 | \ifenit@boxmode 1221 | \global\setbox\enit@inbox\hbox\bgroup\color@begingroup 1222 | \let\item\enit@endinbox 1223 | \fi 1224 | \ignorespaces} 1225 | 1226 | \def\enit@endinlist{% 1227 | \ifenit@boxmode 1228 | \unskip 1229 | \xdef\enit@afteritem{% 1230 | \ifhmode\spacefactor\the\spacefactor\relax\fi}% 1231 | \color@endgroup 1232 | \egroup 1233 | \ifdim\wd\enit@inbox=\z@ 1234 | \enit@itemerror 1235 | \else 1236 | \ifenit@noinitem\else 1237 | \ifhmode\unskip\fi 1238 | \enit@ifunset{enit@itemjoin@s}% 1239 | {\enit@itemjoin}% 1240 | {\enit@itemjoin@s}% 1241 | \fi 1242 | \unhbox\@labels 1243 | \enit@afterlabel 1244 | \unhbox\enit@inbox 1245 | \enit@afteritem 1246 | \fi 1247 | \else 1248 | \unskip 1249 | \if@newlist 1250 | \enit@itemerror 1251 | \fi 1252 | \fi 1253 | \enit@after 1254 | \global\advance\@listdepth\m@ne 1255 | \global\@inlabelfalse 1256 | \if@newlist 1257 | \global\@newlistfalse 1258 | \@noitemerr 1259 | \fi 1260 | \ifx\enit@series\relax\else % discards resume* list, too 1261 | \ifnum\enit@resuming=\@ne % ie, series 1262 | \enit@setresumekeys{series@\enit@series}\global\global 1263 | \else % ie, resume, resume* (save count, but not keys) 1264 | \enit@setresumekeys{series@\enit@series}\@gobblefour\global 1265 | \fi 1266 | \enit@afterlist 1267 | \fi 1268 | \ifnum\enit@resuming=\thr@@ % ie, resume* list (save count only) 1269 | \enit@setresumekeys\@currenvir\@gobblefour\@empty 1270 | \else 1271 | \enit@setresumekeys\@currenvir\@empty\@empty 1272 | \fi 1273 | \aftergroup\enit@afterlist} 1274 | 1275 | % \@item: unboxed 1276 | % --------------- 1277 | 1278 | \def\enit@noboxitem[#1]{% 1279 | \if@newlist 1280 | \leavevmode % ships pending labels out 1281 | \global\@newlistfalse 1282 | \else 1283 | \ifhmode 1284 | \unskip 1285 | \enit@itemjoin 1286 | \else 1287 | \noindent 1288 | \fi 1289 | \fi 1290 | \if@noitemarg 1291 | \@noitemargfalse 1292 | \if@nmbrlist 1293 | \refstepcounter{\@listctr}% after \unskip (hyperref) 1294 | \fi 1295 | \fi 1296 | \mbox{\makelabel{#1}}% 1297 | \enit@afterlabel 1298 | \ignorespaces} 1299 | 1300 | % \@item: boxed 1301 | % ------------ 1302 | % 1303 | % We don't want \item to be executed locally, because it sets a flag 1304 | % (and hyperref adds another flag, too). So, we redefine it inside 1305 | % the box to \enit@endinbox which ends the box and then use the actual 1306 | % (outer) \item. labels are stored in another box, to detect empty 1307 | % boxes, ie, misplaced \item's. Note the 2nd \item ends collecting 1308 | % the 1st item and ships it out, while the 3rd \item ends collecting 1309 | % the 2nd item, puts the itemjoin and then ships the 2nd item out. 1310 | % The flag enit@noinitem keeps track of that. 1311 | 1312 | \newif\ifenit@noinitem 1313 | 1314 | \def\enit@endinbox{% 1315 | \unskip 1316 | \xdef\enit@afteritem{% 1317 | \ifhmode\spacefactor\the\spacefactor\relax\fi}% 1318 | \color@endgroup 1319 | \egroup 1320 | \enit@outeritem} 1321 | 1322 | \def\enit@boxitem[#1]{% 1323 | \if@newlist 1324 | \global\@newlistfalse 1325 | \ifdim\wd\enit@inbox>\z@ 1326 | \enit@itemerror 1327 | \fi 1328 | \enit@noinitemtrue 1329 | \leavevmode % ships pending labels out 1330 | \else 1331 | \ifdim\wd\enit@inbox=\z@ 1332 | \enit@itemerror 1333 | \else 1334 | \ifenit@noinitem 1335 | \enit@noinitemfalse 1336 | \else 1337 | \ifhmode\unskip\fi 1338 | \enit@itemjoin 1339 | \fi 1340 | \unhbox\@labels 1341 | \enit@afterlabel 1342 | \unhbox\enit@inbox 1343 | \enit@afteritem 1344 | \fi 1345 | \fi 1346 | \if@noitemarg 1347 | \@noitemargfalse 1348 | \if@nmbrlist 1349 | \refstepcounter{\@listctr}% 1350 | \fi 1351 | \fi 1352 | \sbox\@labels{\makelabel{#1}}% 1353 | \let\enit@afteritem\relax 1354 | \setbox\enit@inbox\hbox\bgroup\color@begingroup 1355 | \let\item\enit@endinbox 1356 | \hskip1sp % in case the first thing is \label 1357 | \ignorespaces} 1358 | 1359 | % Pause item 1360 | % ---------- 1361 | % 1362 | % To do. 1363 | % 1364 | % The three types 1365 | % =============== 1366 | % 1367 | % enumerate and enumerate* 1368 | % ------------------------ 1369 | % 1370 | % The following has 4 arguments, which in enumerate are: 1371 | % \@enumdepth, enum, \thr@@, . 1372 | % In user defined environments they are: 1373 | % \enitdp@, , , 1374 | 1375 | \def\enit@enumerate{% 1376 | \let\enit@list\enit@dylist 1377 | \enit@enumerate@i} 1378 | 1379 | \@namedef{enit@enumerate*}{% 1380 | \let\enit@list\enit@inlist 1381 | \enit@enumerate@i} 1382 | 1383 | \def\enit@enumerate@i#1#2#3#4{% 1384 | \ifnum#1>#3\relax 1385 | \enit@toodeep 1386 | \else 1387 | \enit@prelist\z@{#1}{#2}% 1388 | \edef\@enumctr{#2\romannumeral#1}% 1389 | \expandafter 1390 | \enit@list 1391 | \csname label\@enumctr\endcsname 1392 | {\usecounter\@enumctr 1393 | \let\enit@calc\z@ 1394 | \def\makelabel##1{\enit@align{\enit@format{##1}}}% 1395 | \enit@preset{#2}{#1}{#4}% 1396 | \enit@normlabel\@itemlabel\@itemlabel 1397 | \enit@ref 1398 | \enit@calcleft 1399 | \enit@before 1400 | \enit@negwidth}% 1401 | \enit@keyfirst 1402 | \fi} 1403 | 1404 | \let\enit@endenumerate\enit@endlist 1405 | \@namedef{enit@endenumerate*}{\enit@endinlist} 1406 | 1407 | % itemize and itemize* 1408 | % -------------------- 1409 | % 1410 | % The following has 4 arguments, which in itemize are: 1411 | % \@itemdepth, item, \thr@@, . 1412 | % In user defined environments they are: 1413 | % \enitdp@, , , 1414 | 1415 | \def\enit@itemize{% 1416 | \let\enit@list\enit@dylist 1417 | \enit@itemize@i} 1418 | 1419 | \@namedef{enit@itemize*}{% 1420 | \let\enit@list\enit@inlist 1421 | \enit@itemize@i} 1422 | 1423 | \def\enit@itemize@i#1#2#3#4{% 1424 | \ifnum#1>#3\relax 1425 | \enit@toodeep 1426 | \else 1427 | \enit@prelist\@ne{#1}{#2}% 1428 | \edef\@itemitem{label#2\romannumeral#1}% 1429 | \expandafter 1430 | \enit@list 1431 | \csname\@itemitem\endcsname 1432 | {\let\enit@calc\z@ 1433 | \def\makelabel##1{\enit@align{\enit@format{##1}}}% 1434 | \enit@preset{#2}{#1}{#4}% 1435 | \enit@calcleft 1436 | \enit@before 1437 | \enit@negwidth}% 1438 | \enit@keyfirst 1439 | \fi} 1440 | 1441 | \let\enit@enditemize\enit@endlist 1442 | \@namedef{enit@enditemize*}{\enit@endinlist} 1443 | 1444 | % description and description* 1445 | % ---------------------------- 1446 | % 1447 | % Make sure \descriptionlabel exists: 1448 | 1449 | \providecommand*\descriptionlabel[1]{% 1450 | \hspace\labelsep 1451 | \normalfont\bfseries#1} 1452 | 1453 | \@namedef{enit@description*}{% 1454 | \let\enit@list\enit@inlist 1455 | \enit@description@i} 1456 | 1457 | \def\enit@description{% 1458 | \let\enit@list\enit@dylist 1459 | \enit@description@i} 1460 | 1461 | \def\enit@description@i#1#2#3#4{% 1462 | \ifnum#1>#3\relax 1463 | \enit@toodeep 1464 | \else 1465 | \enit@list{}% 1466 | {\let\enit@type\tw@ 1467 | \advance#1\@ne 1468 | \labelwidth\z@ 1469 | \enit@align@left 1470 | \let\makelabel\descriptionlabel 1471 | \enit@style@standard 1472 | \enit@preset{#2}{#1}{#4}% 1473 | \enit@calcleft 1474 | \let\enit@svlabel\makelabel 1475 | \def\makelabel##1{% 1476 | \labelsep\z@ 1477 | \ifenit@boxdesc 1478 | \enit@svlabel{\enit@align{\enit@format{##1}}}% 1479 | \else 1480 | \nobreak 1481 | \enit@svlabel{\enit@format{##1}}% 1482 | \aftergroup\enit@postlabel 1483 | \fi}% 1484 | \enit@before 1485 | \enit@negwidth}% 1486 | \enit@keyfirst 1487 | \fi} 1488 | 1489 | \let\enit@enddescription\enit@endlist 1490 | \@namedef{enit@enddescription*}{\enit@endinlist} 1491 | 1492 | % trivlist 1493 | % ======== 1494 | 1495 | \def\enit@trivlist{% 1496 | \let\enit@type\tw@ 1497 | \parsep\parskip 1498 | \csname @list\romannumeral\the\@listdepth\endcsname 1499 | \@nmbrlistfalse 1500 | \enit@tagid 1501 | \enit@setglobalkeys % ie, list and list 1502 | \enit@setkeys{trivlist}% 1503 | \enit@setkeys{trivlist\romannumeral\@listdepth}% 1504 | \@trivlist 1505 | \labelwidth\z@ 1506 | \leftmargin\z@ 1507 | \itemindent\z@ 1508 | \let\@itemlabel\@empty 1509 | \def\makelabel##1{##1}} 1510 | 1511 | % Description styles 1512 | % ================== 1513 | % 1514 | % the next definition is somewhat tricky because labels are boxed. 1515 | % That's fine when the label is just placed at the beginning of a line 1516 | % of text, but when the box is placed without horizontal material, 1517 | % leading is killed. So, we need change somehow \box to \unhbox, but 1518 | % I don't want to modify \@item. The code below presumes \@item has 1519 | % not been changed and arguments gobble the part setting \@labels, 1520 | % which is replaced by a new one. 1521 | % 1522 | % The default value in description is itemindent=!, but some styles 1523 | % (those whose item text begin at a fixed place, ie, nextline, 1524 | % multiline and sameline) change it to labelwidth=!. 1525 | % 1526 | % We must be careful with the group and the whatsit added by color to 1527 | % boxes. Alignment is applied here and some adjustments in skips are 1528 | % necessary to get proper line breaks (including a \nobreak at the 1529 | % beginning of \enit@align, ie, after the first whatsit, see above). 1530 | % To "pass" the inner group added by color to the box, \enit@postlabel 1531 | % checks if the following is }. ie, \egroup -- if not, the box has 1532 | % not reached yet its end. 1533 | 1534 | \def\enit@postlabel{% 1535 | \@ifnextchar\egroup 1536 | {\aftergroup\enit@postlabel}% 1537 | {\enit@postlabel@i}} 1538 | 1539 | \def\enit@postlabel@i#1#2#3#4#5{% 1540 | \def\enit@lblpenalty{\penalty\z@\hskip\skip@}% 1541 | \ifenit@nextline 1542 | \ifdim\wd\@tempboxa>\labelwidth 1543 | \def\enit@lblpenalty{\newline\@nobreaktrue}% 1544 | \fi 1545 | \fi 1546 | \everypar{% 1547 | \@minipagefalse 1548 | \global\@newlistfalse 1549 | \if@inlabel 1550 | \global\@inlabelfalse 1551 | {\setbox\z@\lastbox 1552 | \ifvoid\z@ 1553 | \kern-\itemindent 1554 | \fi}% 1555 | \unhbox\@labels 1556 | \skip@\lastskip % Save last \labelsep 1557 | \unskip % Remove it 1558 | \enit@lblpenalty % Restore it, after penalty 1559 | \fi 1560 | \if@nobreak 1561 | \@nobreakfalse 1562 | \clubpenalty\@M 1563 | \else 1564 | \clubpenalty\@clubpenalty 1565 | \everypar{}% 1566 | \fi}% 1567 | \def\enit@a{#1#2#3#4}% 1568 | \def\enit@b{\global\setbox\@labels\hbox}% 1569 | \ifx\enit@a\enit@b\else 1570 | \enit@error{Non standard \string\item}% 1571 | {A class or a package has redefined \string\item\MessageBreak 1572 | and I do not know how to continue}% 1573 | \fi 1574 | \global\setbox\@labels\hbox{% 1575 | \unhbox\@labels 1576 | \hskip\itemindent 1577 | \hskip-\labelwidth 1578 | \hskip-\labelsep 1579 | \ifdim\wd\@tempboxa>\labelwidth 1580 | \enit@align{\unhbox\@tempboxa}\unskip % Removes (typically) \hfil 1581 | \else 1582 | \leavevmode\hbox to\labelwidth{\enit@align{\unhbox\@tempboxa}}% 1583 | \fi 1584 | \hskip\labelsep}} 1585 | 1586 | % +=============================+ 1587 | % | (RE)DEFINING LISTS | 1588 | % +=============================+ 1589 | % 1590 | % Set keys/values 1591 | % =============== 1592 | % Remember \romannumeral0 expands to nothing. 1593 | % #1 = list name, #2 = level, #3 = flag if star, #4 = keys/values 1594 | 1595 | \let\enit@keys@sizes\relax 1596 | 1597 | \def\enit@saveset#1#2#3#4{% 1598 | \setcounter{enit@cnt}{#2}% 1599 | \ifx\enit@forsize\@empty 1600 | \ifcase#3% 1601 | \expandafter 1602 | \def\csname enit@@#1\romannumeral\c@enit@cnt\endcsname{#4}% 1603 | \or 1604 | \expandafter\let\expandafter\enit@b 1605 | \csname enit@@#1\romannumeral\c@enit@cnt\endcsname 1606 | \ifx\enit@b\relax 1607 | \let\enit@b\@empty 1608 | \fi 1609 | \expandafter\def 1610 | \csname enit@@#1\romannumeral\c@enit@cnt\expandafter\endcsname 1611 | \expandafter{\enit@b,#4}% 1612 | \fi 1613 | \else 1614 | \ifcase#3% 1615 | \enit@ifunset{enit@@#1\romannumeral\c@enit@cnt}% 1616 | {\expandafter\let 1617 | \csname enit@@#1\romannumeral\c@enit@cnt\endcsname\@empty}% 1618 | {}% 1619 | \expandafter\let\expandafter\enit@b 1620 | \csname enit@@#1\romannumeral\c@enit@cnt @@sizes\endcsname 1621 | \ifx\enit@b\relax 1622 | \let\enit@b\@empty 1623 | \fi 1624 | \toks@\expandafter{\enit@b}% 1625 | \edef\enit@b{\the\toks@\enit@forsize\enit@keys@sizes}% 1626 | \expandafter\def 1627 | \csname enit@@#1\romannumeral\c@enit@cnt @@sizes\expandafter\endcsname 1628 | \expandafter{\enit@b{#4}}% 1629 | \else 1630 | \enit@error{* and \string<\string> are not compatible}% 1631 | {Use either * or angles, but not both.}% 1632 | \fi 1633 | \fi} 1634 | 1635 | % TODO: more robust tests (catch wrong key names, but not easy) 1636 | 1637 | % Internally, LaTeX uses a short name for enumerate (enum) 1638 | % and itemize (item). To be consistent with this convention, 1639 | % a couple of macros provide a "translation". I'm not very 1640 | % happy with the current implementation. 1641 | 1642 | \def\enit@shortenumerate{enum} 1643 | \def\enit@shortitemize{item} 1644 | 1645 | \newcommand\setlist{% 1646 | \@ifstar{\enit@setlist\@ne}{\enit@setlist\z@}} 1647 | 1648 | \def\enit@setlist#1{% 1649 | \@ifnextchar<% 1650 | {\enit@setlist@q#1}% 1651 | {\let\enit@forsize\@empty\enit@setlist@n#1}} 1652 | 1653 | % Default definitions. Modified below with option 'sizes': 1654 | 1655 | \def\enit@setlist@q#1<#2>{% 1656 | \enit@error 1657 | {Activate this feature with options 'sizes'}% 1658 | {Size dependent setting with \string<\string> must be\MessageBreak 1659 | explicitly activated with the package option 'sizes'}} 1660 | 1661 | \def\enit@setlist@n#1{% 1662 | \@ifnextchar[{\enit@setlist@x#1}{\enit@setlist@i#1\@empty}} 1663 | 1664 | % Let's accept \setlist[]*{}, too, because an error in <=3.5.1 1665 | 1666 | \def\enit@setlist@x#1[#2]{% 1667 | \@ifstar{\enit@setlist@i\@ne{#2}}{\enit@setlist@i#1{#2}}} 1668 | 1669 | % #1 list names/levels, #2 keys/values 1670 | 1671 | % #1 star flag, #2 list names/levels, #3 keys/values 1672 | 1673 | \def\enit@setlist@i#1#2#3{% 1674 | \let\enit@eltnames\relax 1675 | \let\enit@b\@empty 1676 | \let\enit@eltlevels\relax 1677 | \let\enit@c\@empty 1678 | \protected@edef\enit@a{#2}% 1679 | \@for\enit@a:=\enit@a\do{% the 2nd enit@a is first expanded 1680 | \enit@ifunset{enitdp@\enit@meaning\enit@a}% 1681 | {\edef\enit@c{\enit@c\enit@eltlevels{\enit@a}}}% 1682 | {\enit@ifunset{enit@short\enit@meaning\enit@a}% 1683 | \@empty 1684 | {\edef\enit@a{\@nameuse{enit@short\enit@a}}}% 1685 | \edef\enit@b{\enit@b\enit@eltnames{\enit@a}}}}% 1686 | \ifx\enit@b\@empty 1687 | \def\enit@b{\enit@eltnames{list}}% 1688 | \fi 1689 | \ifx\enit@c\@empty 1690 | \def\enit@c{\enit@eltlevels{0}}% 1691 | \fi 1692 | \def\enit@eltnames##1{% 1693 | \def\enit@a{##1}% 1694 | \enit@c}% 1695 | \def\enit@eltlevels##1{% 1696 | \enit@saveset\enit@a{##1}#1{#3}}% 1697 | \enit@b}% 1698 | 1699 | % Deprecated: 1700 | 1701 | \newcommand\setdisplayed[1][0]{\setlist[trivlist,#1]} 1702 | \let\enitdp@trivlist\@empty % dummy, let know it exists 1703 | \newcommand\setenumerate[1][0]{\setlist[enumerate,#1]} 1704 | \newcommand\setitemize[1][0]{\setlist[itemize,#1]} 1705 | \newcommand\setdescription[1][0]{\setlist[description,#1]} 1706 | 1707 | % New lists 1708 | % ========= 1709 | 1710 | % When defining a list, \label... and counters must be defined 1711 | % for each level, too: 1712 | 1713 | \def\enit@xset@itemize{% 1714 | \@namedef{label\enit@c\romannumeral\count@}{% 1715 | \enit@error{Undefined label}% 1716 | {You have defined a list, but labels have 1717 | not been setup.\MessageBreak 1718 | You can set the label field with \string\setlist.}}} 1719 | \@namedef{enit@xset@itemize*}{\enit@xset@itemize} 1720 | 1721 | \def\enit@xset@enumerate{% 1722 | \enit@xset@itemize 1723 | \enit@ifunset{c@\enit@c\romannumeral\count@}% 1724 | {\@definecounter{\enit@c\romannumeral\count@}}{}} 1725 | \@namedef{enit@xset@enumerate*}{\enit@xset@enumerate} 1726 | 1727 | \let\enit@xset@description\@empty 1728 | \@namedef{enit@xset@description*}{\enit@xset@description} 1729 | 1730 | \newcommand\newlist{\enit@newlist\newenvironment} 1731 | \newcommand\renewlist{\enit@newlist\renewenvironment} 1732 | 1733 | % , , , 1734 | 1735 | \def\enit@newlist#1#2#3#4{% 1736 | \enit@ifunset{enit@xset@#3}% 1737 | {\enit@error{Unknown list type '#3')}% 1738 | {Valid types are: 1739 | enumerate, itemize, description,\MessageBreak 1740 | enumerate*, itemize*, description*}}% 1741 | {}% 1742 | \setcounter{enit@cnt}{#4}% 1743 | \count@\@ne 1744 | \enit@ifunset{enit@short#2}% 1745 | {\def\enit@c{#2}}% 1746 | {\edef\enit@c{\csname enit@short#2\endcsname}}% 1747 | \loop 1748 | \@nameuse{enit@xset@#3}% Uses \enit@c 1749 | \ifnum\count@<\c@enit@cnt 1750 | \advance\count@\@ne 1751 | \repeat 1752 | \enit@ifunset{enitdp@#2}% 1753 | {\expandafter\newcount\csname enitdp@#2\endcsname}{}% 1754 | \csname enitdp@#2\endcsname\z@ 1755 | \advance\c@enit@cnt\m@ne 1756 | \edef\enit@a{% 1757 | \noexpand#1{#2}[1][]% 1758 | {\enit@noexcs{enit@#3}% 1759 | \enit@noexcs{enitdp@#2}% 1760 | {\enit@c}% 1761 | {\the\c@enit@cnt}% 1762 | {####1}}% 1763 | {\enit@noexcs{enit@end#3}}}% 1764 | \enit@a} 1765 | 1766 | % Changing the default nesting limit 1767 | % ---------------------------------- 1768 | 1769 | \newcommand\setlistdepth{\def\enit@listdepth} 1770 | \setlistdepth{5} 1771 | 1772 | % +=============================+ 1773 | % | PACKAGE OPTIONS | 1774 | % +=============================+ 1775 | 1776 | \newif\ifenit@loadonly 1777 | 1778 | \DeclareOption{ignoredisplayed}{\let\enit@trivlist\trivlist} 1779 | \DeclareOption{includedisplayed}{% 1780 | \def\enit@setglobalkeys{% 1781 | \enit@setkeys{list}% 1782 | \enit@setkeys{list\romannumeral\@listdepth}}} 1783 | \let\enit@setglobalkeys\relax 1784 | 1785 | \DeclareOption{loadonly}{\enit@loadonlytrue} 1786 | 1787 | \DeclareOption{shortlabels} 1788 | {\def\enit@shl#1{% 1789 | \ifnum\enit@type=\tw@ 1790 | \enit@toks{#1}% 1791 | \else 1792 | \def\enit@c{#1}% 1793 | \enit@first#1,\@nil\@@nil % Returns enit@toks 1794 | \fi}} 1795 | 1796 | \DeclareOption{inline} 1797 | {\newenvironment{enumerate*}[1][]% 1798 | {\@nameuse{enit@enumerate*}\enitdp@enumerate{enum}\thr@@{#1}} 1799 | {\@nameuse{enit@endenumerate*}} 1800 | \newenvironment{itemize*}[1][]% 1801 | {\@nameuse{enit@itemize*}\enitdp@itemize{item}\thr@@{#1}} 1802 | {\@nameuse{enit@enditemize*}} 1803 | \newenvironment{description*}[1][]% 1804 | {\@nameuse{enit@description*}\enitdp@description{description}\@M{#1}} 1805 | {\@nameuse{enit@enddescription*}}} 1806 | 1807 | \def\enit@setlength{\setlength} 1808 | \DeclareOption{sizes} 1809 | {\def\enit@setlength#1#2{% 1810 | \enit@try@size@range{#2}% Returns \enit@c 1811 | \setlength#1{\enit@c}}% 1812 | \def\enit@setkeys#1{% 1813 | \enit@ifunset{enit@@#1}{}% 1814 | {\let\enit@c\@empty 1815 | \enit@ifunset{enit@@#1@@sizes}{}% 1816 | {\expandafter\let\expandafter\enit@a\csname enit@@#1@@sizes\endcsname 1817 | \expandafter\enit@try@size@range\expandafter{\enit@a}% 1818 | \def\enit@keys@sizes{\def\enit@c}% 1819 | \enit@c 1820 | \let\enit@keys@sizes\relax}% 1821 | \expandafter\expandafter\expandafter 1822 | \enit@setkeys@i 1823 | \csname enit@@#1\expandafter\endcsname 1824 | \expandafter,\enit@c\@@}}% 1825 | \def\enit@setlist@q#1<#2>{% 1826 | \def\enit@forsize{<#2>}% 1827 | \enit@setlist@n#1}} 1828 | 1829 | \chardef\enit@seriesopt\z@ 1830 | \DeclareOption{series=override}{\chardef\enit@seriesopt\tw@} 1831 | 1832 | \let\enit@shl\enit@toks 1833 | 1834 | \ProcessOptions 1835 | 1836 | \let\trivlist\enit@trivlist 1837 | 1838 | % If there is no loadonly, redefine the basic lists: 1839 | 1840 | \ifenit@loadonly\else 1841 | 1842 | \let\enitdp@enumerate\@enumdepth 1843 | \renewenvironment{enumerate}[1][] 1844 | {\enit@enumerate\enitdp@enumerate{enum}\thr@@{#1}} 1845 | {\enit@endenumerate} 1846 | 1847 | \let\enitdp@itemize\@itemdepth 1848 | \renewenvironment{itemize}[1][] 1849 | {\enit@itemize\enitdp@itemize{item}\thr@@{#1}} 1850 | {\enit@enditemize} 1851 | 1852 | \newcount\enitdp@description 1853 | \renewenvironment{description}[1][] 1854 | {\enit@description\enitdp@description{description}\@M{#1}} 1855 | {\enit@enddescription} 1856 | 1857 | \fi 1858 | 1859 | % +=============================+ 1860 | % | TOOLS | 1861 | % +=============================+ 1862 | 1863 | \def\enit@drawrule#1#2#3#4{% 1864 | \rlap{% 1865 | \ifdim#1>0pt\relax 1866 | \vrule width #1 height #2 depth -#3\relax 1867 | \else\ifdim#1=0pt\relax 1868 | % 1869 | \else 1870 | \hskip#1% 1871 | \vrule width -#1 height #2 depth -#4\relax 1872 | \fi\fi}} 1873 | 1874 | \def\DrawEnumitemLabel{% 1875 | \begingroup 1876 | \item[]% 1877 | \hskip-\labelsep 1878 | \enit@drawrule\labelsep{4pt}{3pt}{2.3pt}% 1879 | \hskip-\labelwidth 1880 | \enit@drawrule\labelwidth{6pt}{5pt}{4.3pt}% 1881 | \hskip\labelwidth 1882 | \hskip\labelsep 1883 | % 1884 | \hskip-\itemindent 1885 | \enit@drawrule\itemindent{2pt}{1pt}{.3pt}% 1886 | \rlap{\vrule height 9pt depth .5pt}% 1887 | \hskip-\leftmargin 1888 | \rlap{\vrule height 9pt depth .5pt}% 1889 | \enit@drawrule\labelindent{8pt}{7pt}{6.5pt}% 1890 | % \message{\the\labelindent/\the\labelwidth/\the\labelsep/\the\itemindent}% 1891 | \endgroup} 1892 | 1893 | % TODO - option 'verbose' 1894 | 1895 | % +=============================+ 1896 | % | TWO-PASS TOOLS | 1897 | % +=============================+ 1898 | 1899 | % TODO - Not for the moment, because both tools would require to take 1900 | % into account series and resume, which is not simple. Also, are they 1901 | % applied to all lists, by type, by level, by name, etc.? Document how 1902 | % to do it in at least the simplest cases. 1903 | % 1904 | % - reverse counting 1905 | % - automatic widest, based on existing labels. 1906 | 1907 | \endinput 1908 | 1909 | MIT License 1910 | ----------- 1911 | 1912 | Permission is hereby granted, free of charge, to any person obtaining a 1913 | copy of this software and associated documentation files (the 1914 | "Software"), to deal in the Software without restriction, including 1915 | without limitation the rights to use, copy, modify, merge, publish, 1916 | distribute, sublicense, and/or sell copies of the Software, and to 1917 | permit persons to whom the Software is furnished to do so, subject to 1918 | the following conditions: 1919 | 1920 | The above copyright notice and this permission notice shall be included 1921 | in all copies or substantial portions of the Software. 1922 | 1923 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1924 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1925 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 1926 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 1927 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 1928 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 1929 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 1930 | -------------------------------------------------------------------------------- /enumitem.tds.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jbezos/enumitem/ec9787500280b3c2bd280906093183589338a809/enumitem.tds.zip -------------------------------------------------------------------------------- /enumitem.tex: -------------------------------------------------------------------------------- 1 | % 2 | % Copyright (C) 2003-2025 Javier Bezos http://www.texnia.com 3 | % 4 | % This file may be distributed and/or modified under the conditions of 5 | % the MIT License. A version can be found at the end of this file. 6 | % 7 | % Repository: https://github.com/jbezos/enumitem 8 | % 9 | 10 | \documentclass[a4paper]{ltxguide} 11 | 12 | \raggedright 13 | \parskip=.8ex 14 | \advance\oddsidemargin-.5cm 15 | \advance\textwidth1cm 16 | \addtolength{\textheight}{2cm} 17 | \addtolength{\topmargin}{-1.5cm} 18 | 19 | \usepackage{xcolor,bera} 20 | 21 | \definecolor{notes}{rgb}{.75, .3, .3}% 22 | 23 | \makeatletter 24 | \newenvironment{desc} 25 | {\if@nobreak 26 | \vskip-\lastskip 27 | \vspace*{-2.5ex}% 28 | \fi 29 | \decl} 30 | {\enddecl} 31 | \def\@begintheorem#1#2{% 32 | \list{}{}% 33 | \global\advance\@listdepth\m@ne 34 | \item[{\sffamily\bfseries\color{notes}\MakeUppercase{#1}}]}% 35 | \makeatother 36 | \newtheorem{warning}{Warning} 37 | \newtheorem{note}{Note} 38 | \newtheorem{example}{Example} 39 | \makeatother 40 | 41 | \usepackage{framed} 42 | \definecolor{shadecolor}{rgb}{0.96,0.96,0.93} 43 | \let\bblxv\verbatim 44 | \let\bblexv\endverbatim 45 | \def\verbatim{\begin{shaded*}\bblxv\vskip-\baselineskip\vskip2.5\parsep} 46 | \def\endverbatim{\bblexv\vskip-2\baselineskip\end{shaded*}} 47 | 48 | \newcommand\New[1]{% 49 | \colorbox[rgb]{.87, .9, .83}{New #1}\enspace\ignorespaces} 50 | 51 | \usepackage{hyperref} 52 | 53 | \title{Customizing lists\\with the\\\textsf{enumitem} package} 54 | 55 | \author{Javier Bezos\footnote{For bug reports, comments and 56 | suggestions go to \href{http://www.texnia.com/enumitem.html}% 57 | {\texttt{http://www.texnia.com/enumitem.html}}.}} 58 | 59 | \date{Version 3.11\\2025/02/06} 60 | 61 | \IfFileExists{enumitem.sty}{\usepackage{enumitem}}{} 62 | \IfFileExists{layouts.sty}{\usepackage{layouts}}{} 63 | 64 | \addtolength{\topmargin}{-3pc} 65 | \addtolength{\textwidth}{6pc} 66 | \addtolength{\oddsidemargin}{-2pc} 67 | \addtolength{\textheight}{7pc} 68 | 69 | \raggedright 70 | \parindent1.8em 71 | \parskip0pt 72 | 73 | \begin{document} 74 | 75 | \maketitle 76 | \tableofcontents 77 | 78 | \newpage 79 | 80 | \vspace*{1cm} 81 | 82 | \begin{note} 83 | Changes and new features with relation to version 3.5 are highlighted 84 | with \New{X.X}\hspace{-.5em}. The most recent features could be still 85 | unstable. Please, report any issues you find on 86 | \texttt{https://github.com/jbezos/enumitem/issues}, which is better 87 | than just complaining on an e-mail list or a web forum. Forking 88 | and pull requests are welcome. 89 | \end{note} 90 | 91 | \begin{warning} 92 | Version 3.6 introduced two new keys: |left| and |first|. If your 93 | documents define some series with these names, an error is raised. 94 | Just rename them, or set the package option |series=override|. 95 | \end{warning} 96 | 97 | \section{Introduction} 98 | 99 | This package provides most of the flexibility you may want to customize 100 | the three basic list environments (|enumerate|, |itemize| and 101 | |description|) and to design your own lists, with a |=| 102 | syntax: 103 | \begin{itemize} 104 | \item Fancy labels and fancy refs, including a syntax similar to that 105 | in the \textsf{enumerate} package. 106 | 107 | \item Alternative ways for positioning the label, with a new 108 | parameter (|labelindent|) and a tab-like setting (|left|). 109 | 110 | \item Settings applied globally or only in one of the three types or 111 | even in a single list (including |\topsep|). 112 | 113 | \item Inline lists. 114 | 115 | \item Several description styles (which fix some bad spacing, too). 116 | 117 | \item |trivlist|s properly formatted. 118 | 119 | \item Gathering of lists to be treated like a unit, as well as counter 120 | resuming. 121 | 122 | \end{itemize} 123 | 124 | In the interface a sort of ``inheritance'' is used. You can set 125 | globally the behavior of lists and then override several parameters of, 126 | say, |enumerate| and then in turn override a few parameters in a 127 | particular instance. The values will be searched in the hierarchy. 128 | 129 | The package extends the syntax of the lists to allow an optional 130 | argument where a set of parameters in the form |key=value| are 131 | available. These keys are equivalent to the well known list parameters. 132 | Please, see a \LaTeX{} manual for a description of them. Next sections 133 | explain the extensions provided by \textsf{enumitem}. 134 | \begin{itemize} 135 | \item 136 | Vertical spacing: 137 | \begin{itemize} 138 | \setlength{\itemsep}{0pt} 139 | \item |topsep| 140 | \item |partopsep| 141 | \item |parsep| 142 | \item |itemsep| 143 | \end{itemize} 144 | \item 145 | Horizontal spacing: 146 | \begin{itemize} 147 | \setlength{\itemsep}{0pt} 148 | \item |leftmargin| 149 | \item |rightmargin| 150 | \item |listparindent| 151 | \item |labelwidth| 152 | \item |labelsep| 153 | \item |itemindent| 154 | \end{itemize} 155 | \end{itemize} 156 | 157 | \begin{example} 158 | A straightforward example is: 159 | \begin{verbatim} 160 | \begin{itemize}[itemsep=1ex, leftmargin=1cm] 161 | \end{verbatim} 162 | \end{example} 163 | 164 | \begin{note} 165 | A way to see how these parameters work is with the |layouts| package 166 | (the manual is named |layman.pdf|). 167 | \ifx\listdiagram\notundefined\else 168 | See figure \ref{f.drawlist}. 169 | \begin{figure} 170 | \centering 171 | \listdiagram 172 | \caption{List parameters}\label{f.drawlist} 173 | \end{figure} 174 | \fi 175 | \end{note} 176 | 177 | \section{Quick reference} 178 | 179 | Some common settings. See the manual below for details. 180 | 181 | \begin{itemize} 182 | \def\verbatim{\begin{shaded*}\bblxv} 183 | \def\endverbatim{\bblexv\vskip-1.6\baselineskip\end{shaded*}} 184 | 185 | \item To remove the vertical space altogether in a list: 186 | \begin{verbatim} 187 | \begin{enumerate}[nosep] 188 | \end{verbatim} 189 | 190 | \item To remove the vertical space altogether in \textit{all} lists: 191 | \begin{verbatim} 192 | \setlist{nosep} 193 | \end{verbatim} 194 | 195 | \item To start the label at the margin and the item text at the 196 | current parindent: 197 | \begin{verbatim} 198 | \begin{enumerate}[left=0pt .. \parindent] 199 | \end{verbatim} 200 | 201 | \item To configure the labels like in \textsf{enumerate}: include the 202 | package option |shortlabels| and then, as a first element, write your 203 | label: 204 | \begin{verbatim} 205 | \begin{enumerate}[(1)] 206 | \end{verbatim} 207 | 208 | \item To continue the previous list, after a ``pause'': 209 | \begin{verbatim} 210 | \begin{enumerate}[resume*] 211 | \end{verbatim} 212 | 213 | \item To use the three basic lists in line: just add the package option 214 | |inline| and then the environments |enumerate*|, |itemize*| and 215 | |description*|. 216 | 217 | \item To set a numeric label with parenthesis, but a cross-reference 218 | without them: 219 | \begin{verbatim} 220 | \begin{enumerate}[label=(\arabic*), ref=\arabic*] 221 | \end{verbatim} 222 | 223 | \end{itemize} 224 | 225 | \section{Keys} 226 | 227 | This section describes the keys in displayed lists. Most of them are 228 | available in inline lists, where further keys are available (see 229 | \ref{s.inline}). 230 | 231 | \begin{warning} 232 | If the value is completely enclosed in braces, they are stripped off. 233 | If you want the braces, they must be duplicated. This is the default 234 | behavior of \textsf{keyval}, which \textsf{enumitem} just emulates. 235 | \end{warning} 236 | 237 | \subsection{Label and cross references format} 238 | 239 | \begin{desc} 240 | |label=| 241 | \end{desc} 242 | 243 | Sets the label to be used in the current level. A set of starred 244 | versions of |\alph|, |\Alph|, |\arabic|, |\roman| and |\Roman|, without 245 | argument stand for the current counter in 246 | |enumerate|.\footnote{Actually, the asterisk is currently the argument 247 | but things may change. Consider them as starred variants and follow the 248 | corresponding syntax.} It works with |\value|, too (provided the widest 249 | label is not to be computed or |widest*| is used, see below). 250 | 251 | \begin{note} 252 | If you prefer setting labels like the \textsf{enumerate} package, use 253 | ``short labels'' (see section \ref{s.short}). 254 | \end{note} 255 | 256 | \begin{example} 257 | The following prints \textit{a}), \textit{b}), and so on (this is a 258 | standard style in Spanish, and formerly used by Chicago, too). 259 | \begin{verbatim} 260 | \begin{enumerate}[label=\emph{\alph*})] 261 | \end{verbatim} 262 | \end{example} 263 | 264 | \begin{warning} 265 | The value of |label| is a moving argument, and fragile commands must 266 | be protected \textit{except} the counters. Because of that, use of 267 | |\value| is somewhat tricky, because |\the| or |\ifnum| 268 | expects an actual value, which is not the case when |label| is 269 | being processed to replace internally the |*| by the form with 270 | the counter argument. The best solution is usually encapsulating the 271 | logic inside a new ``counter'' with the help of 272 | |\AddEnumerateCounter|.\footnote{Which is admittedly somewhat 273 | convoluted. A better way to accomplish this is on the way.} 274 | \end{warning} 275 | 276 | \begin{example} 277 | A fancier example 278 | (which looks ugly, but it is intended only to illustrate what is 279 | possible; requires \textsf{color} and \textsf{pifont}): 280 | \begin{verbatim} 281 | \begin{enumerate}[label=\protect\fcolorbox{blue}{yellow}{\protect\ding{\value*}}] 282 | \end{verbatim} 283 | \end{example} 284 | 285 | \begin{desc} 286 | |label*=| 287 | \end{desc} 288 | 289 | Like |label| but its value is appended to the parent label. For 290 | example, the following defines a |legal| list (1., 1.1., 1.1.1., and so 291 | on): 292 | \begin{verbatim} 293 | \newlist{legal}{enumerate}{10} 294 | \setlist[legal]{label*=\arabic*.} 295 | \end{verbatim} 296 | 297 | \begin{desc} 298 | |ref=| 299 | \end{desc} 300 | 301 | By default, |label| sets also the form of cross references and 302 | |\the...| (overriding the settings in parent hierarchical 303 | levels), but you can define a different format with this key. For 304 | example, to remove the right parenthesis: 305 | \begin{verbatim} 306 | \begin{enumerate}[label=\emph{\alph*}), ref=\emph{\alph*}] 307 | \end{verbatim} 308 | 309 | \begin{note} 310 | In both |label| and |ref|, the counters can be used as usual. So, and 311 | provided the current level is the second one: 312 | \begin{verbatim} 313 | \begin{enumerate}[label=\theenumi.\arabic*.] 314 | \end{verbatim} 315 | or 316 | \begin{verbatim} 317 | \begin{enumerate}[label=\arabic{enumi}.\arabic*.] 318 | \end{verbatim} 319 | \end{note} 320 | 321 | \begin{note} 322 | The |label|s are \textit{not} accumulated to form the reference. 323 | If you want, say, something like 1.\textit{a} from 1) as first level 324 | and \textit{a}) as second level, you must set it with |ref|. You may 325 | use |\ref{level1}.\ref{level2}| with appropriate |ref| settings, but as 326 | Robin Fairbairns points out in the \TeX{} FAQ: 327 | \begin{quote} 328 | \dots{} [that] would be both tedious and error-prone. What is more, it 329 | would be undesirable, since you would be constructing a visual 330 | representation which is inflexible (you could not change all the 331 | references to elements of a list at one fell swoop). 332 | \end{quote} 333 | This is sensible and I recommend to follow the advice, but sometimes 334 | you might want something like: 335 | \begin{verbatim} 336 | ... subitem \ref{level2} of item \ref{level1} ... 337 | \end{verbatim} 338 | \end{note} 339 | 340 | \begin{warning} 341 | The value of |ref| is a moving argument, and fragile commands must be 342 | protected \textit{except} the counters. 343 | \end{warning} 344 | 345 | \begin{desc} 346 | |font=|\qquad|format=| 347 | \end{desc} 348 | 349 | Sets the label font. Useful when the label is changed with the optional 350 | argument of |\item| and in \texttt{description}. The last command in 351 | || can take an argument with the item label. In 352 | \texttt{description} class setting are in force, so you may want to begin 353 | with |\normalfont|. A synonym is \texttt{format}. Actually, this key 354 | may be used for any stuff to be executed at each |\item|, just before the 355 | label. 356 | 357 | \begin{desc} 358 | |align=left|\qquad |align=right|\qquad |align=parleft| 359 | \end{desc} 360 | 361 | How the label is aligned (with relation to the label box edges). 362 | Three values are possible: |left|, the default |right| and 363 | |parleft| (a parbox of width |\labelwidth| with flush left 364 | text). The parameters controlling the label spacing should be 365 | properly set, either by hand or more conveniently with the |*| 366 | settings (see below): 367 | \begin{verbatim} 368 | \begin{enumerate}[label=\Roman*., align=left, leftmargin=*] 369 | \end{verbatim} 370 | When the label box is supposed to have its natural width, use 371 | |left|. 372 | 373 | \begin{desc} 374 | |\SetLabelAlign{}{}| 375 | \end{desc} 376 | 377 | New align types can be defined (or the existing ones redefined) with 378 | |\SetLabelAlign|; the predefined values are equivalent 379 | to: 380 | \begin{verbatim} 381 | \SetLabelAlign{right}{\hss\llap{#1}} 382 | \SetLabelAlign{left}{#1\hfil} 383 | \SetLabelAlign{parleft}{\strut\smash{\parbox[t]\labelwidth{\raggedright##1}}} 384 | \end{verbatim} 385 | 386 | \begin{example} 387 | Although primarily intended for the alignment, this commands has 388 | other uses (an example is the provided |parleft|). For example, with 389 | the following all labels with |align=right| are set as superscripts: 390 | \begin{verbatim} 391 | \SetLabelAlign{right}{\hss\llap{\textsuperscript{#1}}} 392 | \end{verbatim} 393 | A new name is also possible, of course. 394 | \end{example} 395 | 396 | \begin{note} 397 | If the last thing in the definition is a skip (typically |\hfil|), it 398 | is removed sometimes by |description|. If for some reason you want to 399 | avoid this, just add |\null| at the end. 400 | \end{note} 401 | 402 | \begin{note} 403 | If you want the internal settings for \texttt{align} and \texttt{font} 404 | be ignored, you can override the \textsf{enumitem} definition of 405 | |\makelabel| in \texttt{before}: 406 | \begin{verbatim} 407 | \begin{description}[before={\renewcommand\makelabel[1]{\ref{##1}}}] 408 | \end{verbatim} 409 | Alternatively, define a macro and use |\let|. 410 | \end{note} 411 | 412 | \subsection{Horizontal spacing of labels} 413 | 414 | The horizontal space in the left margin of the current level is 415 | distributed in the following way:\footnote{Admittedly, these figures 416 | are not exactly the clearest possible, and I intend to improve them in 417 | a future release.} 418 | \begin{center} 419 | \begin{tabular}{cc} 420 | \fbox{\fbox{\strut \texttt{labelindent}} 421 | \fbox{\strut \texttt{labelwidth}} 422 | \fbox{\strut \texttt{labelsep} $-$ \texttt{itemindent}}} 423 | & 424 | \fbox{\strut\texttt{itemindent}}\\ 425 | \texttt{leftmargin} 426 | \end{tabular} 427 | \end{center} 428 | Here |labelindent| is a new parameter introduced by \textsf{enumitem}, 429 | described below. The rest are those in standard \LaTeX. 430 | 431 | Actually, the layout is more complex because the label box (ie, 432 | |labelwidth|) could stick into the margin, which means |labelindent| 433 | takes a negative value. 434 | 435 | \begin{note} 436 | Since |\parindent| is not used as such inside lists, but instead is 437 | set internally to either |\itemindent| or |\listparindent|, when used 438 | as the value of a parameter \textsf{enumitem} returns the global 439 | value, i. e., the value it has outside the outermost list. 440 | \end{note} 441 | 442 | \begin{note} 443 | \New{3.6} If you find these parameters baffling, you are not alone. You 444 | can visualize them by writing |\DrawEnumitemLabel| just before the 445 | first item (or in |first|), which draws 4 rules from top to bottom, 446 | |labelindent|, |labelwidth|, |labelsep|, |itemindent| (thin if 447 | positive, thick if negative); the |leftmargin| is marked with two 448 | vertical rules. 449 | \end{note} 450 | 451 | \begin{desc} 452 | |labelindent=|\\ 453 | |\labelindent| 454 | \end{desc} 455 | 456 | This parameter is added in \textsf{enumitem} for the blank space from 457 | the margin of the enclosing list/text to the left edge of the label 458 | box. This means there is a redundancy because one of the parameters 459 | depends on the others, i.e., it has to be computed from the other 460 | values, as described below. By default, the computed value is 461 | |labelindent|, even if explicitly set with some value (it defaults to 462 | 0~pt). So, if you are setting it to some value, very likely you want to 463 | set some other parameter to |!| or |*|, because otherwise it is 464 | ignored. 465 | 466 | There is a new counter length |\labelindent|. 467 | 468 | The five parameters are related in the following way: 469 | \[ 470 | |\leftmargin|+|\itemindent| = 471 | |\labelindent|+|\labelwidth|+|\labelsep| 472 | \] 473 | 474 | \begin{desc} 475 | |left=|\\ 476 | |left= .. | 477 | \end{desc} 478 | 479 | \New{3.6} This is a convenience key to set quickly the most common 480 | layouts for the label. You may regard it as a sort or ``rule'' with two 481 | tab stops: the start of the label and the start of the text (both with 482 | relation to the normal side margin). With only ||, the 483 | left margin (the ``start of text'') is computed with the |labelsep|. It 484 | internally resorts to |widest|, so the restrictions of the letter with 485 | relation to |description| also applies here: you might need change the 486 | computed parameter (eg, |itemindent=*| with |align=left|). 487 | 488 | \begin{example} 489 | Typical settings would be: 490 | \begin{verbatim} 491 | \begin{enumerate}[left= 0pt] 492 | \begin{enumerate}[left= 0pt .. \parindent] 493 | \begin{enumerate}[left= \parindent] 494 | \begin{enumerate}[left= \parindent .. 2\parindent] 495 | \begin{enumerate}[left= -\parindent .. 0pt] 496 | \end{verbatim} 497 | \end{example} 498 | 499 | \begin{note} 500 | The label width is set to the default widest one. If there are lists 501 | with Arabic numerals $\ge 10$, you may want to set |widest|, too. 502 | \end{note} 503 | 504 | \begin{note} 505 | |left=| sets |leftmargin=*|; 506 | |left= .. | sets |labelsep=*|. 507 | \end{note} 508 | 509 | \begin{desc} 510 | |leftmargin=!|\qquad|itemindent=!|\qquad|labelsep=!| 511 | \qquad|labelwidth=!|\qquad|labelindent=!| 512 | \end{desc} 513 | 514 | Sets which value is to be computed from the others. The default is 515 | |labelindent=!|, but note some keys set another value (|wide| and 516 | description |style|s). Computations are done after \textit{all} keys 517 | have been read. Explicit values are not lost, and so with the following 518 | hierarchical settings: 519 | \begin{verbatim} 520 | leftmargin=2em 521 | labelindent=1em,leftmargin=! 522 | labelindent=! 523 | \end{verbatim} 524 | |leftmargin| is again 2em and |labelindent| is the computed parameter. 525 | 526 | \begin{note} 527 | With |align=right| (the default), |labelindent=!| and |labelwidth=!| 528 | behave similarly in practice. 529 | \end{note} 530 | 531 | \begin{desc} 532 | |leftmargin=*|\qquad|itemindent=*|\qquad|labelsep=*| 533 | \qquad|labelwidth=*|\qquad|labelindent=*| 534 | \end{desc} 535 | 536 | Like before, but in addition |labelwidth| is first set to the width of 537 | the current label, using the default value of \textit{0} in |\arabic*|, 538 | \textit{viii} in |\roman*|, \textit{m} in |\alph*| and similarly in 539 | uppercase forms (these values can be changed with |widest|, see below). 540 | Examples are: 541 | \begin{verbatim} 542 | \begin{itemize}[label=\textbullet, leftmargin=*] 543 | \begin{enumerate}[label=\roman*), leftmargin=*, widest=iii] 544 | \begin{itemize}[label = \textbullet, 545 | leftmargin = 2pc, 546 | labelsep = *] 547 | \begin{enumerate}[label = \arabic*., 548 | labelindent = \parindent, 549 | leftmargin = 2\parindent, 550 | labelsep = *] 551 | \end{verbatim} 552 | 553 | The most useful are |labelsep=*| and |leftmargin=*|. With the former 554 | the item body begins at a fixed place (namely, |leftmargin|), while 555 | with the latter begins at a variable place depending on the label (but 556 | always the same within a list, of course). 557 | 558 | \begin{note} 559 | Unfortunately, \LaTeX{} does not define a default |labelsep| to 560 | be applied to all lists---simply the current value is used. With 561 | \textsf{enumitem} you can set default values for every list, as 562 | described below, and so, if you want to make sure |labelsep| is 563 | under your control, all you need is something like: 564 | \begin{verbatim} 565 | \setlist{labelsep=.5em} 566 | \end{verbatim} 567 | \end{note} 568 | 569 | \begin{note} 570 | |labelwidth=*| and |labelwidth=!| are synonymous. Use them with care, 571 | because they may take negative values, which does not make sense (a 572 | warning is shown). 573 | \end{note} 574 | 575 | \begin{desc} 576 | |widest=|\qquad|widest*=|\qquad|widest| 577 | \end{desc} 578 | 579 | To be used in conjunction with the \texttt{*}-values, if desired. It 580 | overrides the default value for the widest printed counter. Sometimes, 581 | if lists are not very long, a value of |a| for |\alph| is more sensible 582 | than the default |m|: 583 | \begin{verbatim} 584 | \begin{enumerate}[leftmargin=*, widest=a] % Assume standard 2nd level 585 | \end{verbatim} 586 | With no value, the default is restored. With |widest*|, the string is 587 | built using || as the value of the counter (e.g., with 588 | |\roman|, 589 | |widest=viii| and |widest*=8| are the same). 590 | 591 | Since |\value| does not return a string but a number, |widest| and the 592 | |*| values cannot be used with it. However, with |widest*|, 593 | being a number, it is allowed. 594 | 595 | \New{3.6} It can be used with |itemize| and |description|, too. 596 | However, since the latter does some tricky formatting inside the label 597 | you might need change the computed parameter (eg, |itemindent=*| with 598 | |align=left|). 599 | 600 | \begin{desc} 601 | |labelsep*=| 602 | \end{desc} 603 | 604 | Remember |labelsep| spans part of |leftmargin| and |itemindent| if the 605 | latter is not zero. This is often somewhat confusing, so a new key is 606 | provided---with \texttt{labelsep*} the value is reckoned from the left 607 | margin (it just sets |\labelsep| and then adds |\itemindent| to it, but 608 | in addition later changes to |itemindent| are taken into account): 609 | \begin{center} 610 | \begin{tabular}{cc} 611 | \fbox{\fbox{\strut \texttt{labelindent}} 612 | \fbox{\strut \texttt{labelwidth}} 613 | \fbox{\strut \texttt{labelsep*}}} 614 | & 615 | \fbox{\strut\texttt{itemindent}}\\ 616 | \texttt{leftmargin} 617 | \end{tabular} 618 | \end{center} 619 | 620 | \begin{desc} 621 | |labelindent*=| 622 | \end{desc} 623 | 624 | Like |labelindent|, but it is reckoned from the left margin in 625 | the current list and not from that in the enclosing list/text. 626 | 627 | \begin{example} 628 | A first pattern aligns the label with the surrounding |\parindent| 629 | while the item body is indented depending on the label and a fixed 630 | |labelsep|: 631 | \begin{verbatim} 632 | labelindent = \parindent, 633 | leftmargin = * 634 | \end{verbatim} 635 | A fairly frequent variant is aligning the label with the surrounding 636 | text (remember |labelindent| is |0pt| by default if it is not the 637 | computed parameter): 638 | \begin{verbatim} 639 | leftmargin = * 640 | \end{verbatim} 641 | The former looks better in the first level while the latter seems 642 | preferable in subsequent ones. That can be easily set with 643 | \begin{verbatim} 644 | \setlist{leftmargin=*} 645 | \setlist[1]{labelindent=\parindent} % Only the level 1 646 | \end{verbatim} 647 | \end{example} 648 | 649 | \begin{example} 650 | A second pattern aligns the item body with the surrounding 651 | |\parindent|. In this case (remember |labelindent| is the computed 652 | parameter if not set): 653 | \begin{verbatim} 654 | leftmargin = \parindent 655 | \end{verbatim} 656 | \end{example} 657 | 658 | \begin{example} 659 | A third pattern would be the label aligned with |\parindent|, 660 | and the item body with |2\parindent|: 661 | \begin{verbatim} 662 | labelindent = \parindent, 663 | leftmargin = 2\parindent, 664 | itemsep = * 665 | \end{verbatim} 666 | Again, a variant would be the label aligned with the surrounding 667 | text, and the item body with |\parindent|: 668 | \begin{verbatim} 669 | leftmargin = \parindent, 670 | itemsep = * 671 | \end{verbatim} 672 | \end{example} 673 | 674 | \subsection{Numbering, stopping, and resuming} 675 | 676 | \begin{desc} 677 | |start=| 678 | \end{desc} 679 | Sets the number of the first item. 680 | 681 | \begin{desc} 682 | |resume| 683 | \end{desc} 684 | 685 | The counter continues from the previous |enumerate|, 686 | instead of being reset to 1. 687 | \begin{verbatim} 688 | \begin{enumerate} 689 | \item First item. 690 | \item Second item. 691 | \end{enumerate} 692 | Text. 693 | \begin{enumerate}[resume] 694 | \item Third item 695 | \end{enumerate} 696 | \end{verbatim} 697 | 698 | This is done locally. If you want global resuming, see next section on 699 | series. 700 | 701 | \begin{desc} 702 | |resume*| 703 | \end{desc} 704 | 705 | Like |resume| but the options from the previous list are used, too. 706 | This option must be restricted to the optional argument in a 707 | environment (this is the only place where it makes sense). It should be 708 | used sparingly---if you are using it often, then very likely you want 709 | to define a new list (see \ref{s.clone}). Further keys are allowed, and 710 | in this case the saved options are overridden by those in the current 711 | list (i.e., the position of \texttt{resume*} does not matters). If 712 | there is a series of a certain list with \texttt{resume*}, options are 713 | taken from the list previous to the first one, except for 714 | \texttt{start}. 715 | 716 | \begin{example} 717 | For example: 718 | \begin{verbatim} 719 | \begin{enumerate}[resume*, start=1] % or [start=1, resume*] 720 | \end{verbatim} 721 | uses the keys in the previous \texttt{enumerate}, but restarts the 722 | counter. 723 | \end{example} 724 | 725 | \subsection{Series} 726 | 727 | \begin{desc} 728 | |series=|\\ 729 | ||\qquad|resume*=| 730 | \qquad|resume=| 731 | \end{desc} 732 | 733 | Another method to continue lists is by means of the key 734 | \texttt{series}, so that they behave like a unit. A list with key 735 | \texttt{series} is considered the starting list and its settings are 736 | stored \textit{globally}, so that they can be used later with 737 | \texttt{resume}/\texttt{resume*}. All these keys take a value with the 738 | series name (which must be different from existing keys): 739 | \begin{itemize} 740 | \item |resume=| just continue numbering items in the 741 | series, 742 | \item |resume*=| also applies the settings of the 743 | starting list, 744 | \item ||, i.e., the series name used as a key, is an 745 | alternative to |resume*=|. 746 | \end{itemize} 747 | 748 | \begin{example} 749 | Consider: 750 | \begin{verbatim} 751 | \begin{enumerate}[label=\arabic*(a), leftmargin=1cm, series=l_after] 752 | \item A 753 | \item B 754 | \end{enumerate} 755 | \end{verbatim} 756 | You get: 1(a) 2(a). You can continue with: 757 | \begin{verbatim} 758 | \begin{enumerate}[label=\arabic*(b), resume*=l_after] 759 | % or [label=\arabic*(b), l_after] 760 | \item A 761 | \item B 762 | \end{enumerate} 763 | \end{verbatim} 764 | You get: 3(b) 4(b). (But you can use |start=1|, if you like.) 765 | \end{example} 766 | 767 | Note you can add further arguments, which are executed after those 768 | saved at the starting list and therefore take precedence over them -- 769 | in particular, |resume*| itself takes precedence over a |start| (e.g., 770 | |start=1|) in the the starting list. 771 | 772 | \begin{note} 773 | Every time a series is started, several commands are defined 774 | internally. Thus, to avoid wasting resources use the same name for 775 | non-overlapping series. 776 | \end{note} 777 | 778 | \begin{warning} 779 | The package may introduce new keys in the future, so using directly 780 | || as a key is a potential source of forward 781 | incompatibilities. However, it's safe using a non-letter character 782 | other than hyphen or star in the key name (e.g., |!notes| or 783 | |m_steps|), as well as uppercase letters and digits, because 784 | \textsf{enumitem} will never use them. \New{3.7} If you have defined 785 | some series with an all lowercase name and a new conflicting key has 786 | been introduced, an alternative to changing their names is the 787 | package option |series=override| (the error message is 788 | \texttt{Invalid series name `key'}). With it series names take 789 | precedence over predefined keys -- but use it only when absolutely 790 | necessary. 791 | \end{warning} 792 | 793 | \subsection{Penalties} 794 | 795 | \begin{desc} 796 | |beginpenalty=|\qquad 797 | |midpenalty=|\qquad |endpenalty=| 798 | \end{desc} 799 | 800 | Set the penalty at the beginning of a list, between items and at the 801 | end of the list, respectively. Please, refer to your \LaTeX{} or 802 | \TeX{} manual about how penalties control page breaks. Unlike other 803 | parameters, when a list starts their values are not reset to the 804 | default, thus they apply to the child lists. 805 | 806 | \subsection{Injecting code} 807 | 808 | \begin{desc} 809 | |before=| \qquad |before*=| 810 | \end{desc} 811 | 812 | Execute code before the list starts (more precisely, in the second 813 | argument of the |list| environment used to define them). The 814 | unstarred form sets the code to be executed, overriding any previous 815 | value, while the starred one adds the code to the existing one (in 816 | the setting hierarchy, see below, \textit{not} with relation to the 817 | enclosing list/text). It can contain, say, rules and text, but this 818 | has not been extensively tested. All calculations have been finished, 819 | and you can access and manipulate the list parameters. 820 | 821 | \begin{example} 822 | To have both margins (left and right) set to the widest label: 823 | \begin{verbatim} 824 | \setlist{leftmargin=*, before=\setlength{\rightmargin}{\leftmargin}} 825 | \end{verbatim} 826 | \end{example} 827 | 828 | \begin{desc} 829 | |after=|\qquad|after*=| 830 | \end{desc} 831 | 832 | Same, but just before the list ends. 833 | 834 | \begin{desc} 835 | |first=|\qquad|first*=| 836 | \end{desc} 837 | 838 | \New{3.6} Same, but as the very first thing in the list body, so that 839 | \begin{verbatim} 840 | \begin{itemize}[first=] 841 | \end{verbatim} 842 | is the same as 843 | \begin{verbatim} 844 | \begin{itemize} 845 | 846 | \end{verbatim} 847 | 848 | \begin{example} 849 | With |first| you can define your own environments for displayed 850 | material. A trivial example is: 851 | \begin{verbatim} 852 | \newlist{letter}{itemize}{1} 853 | \setlist[letter]{first=\item[]\itshape, rightmargin=\leftmargin} 854 | \end{verbatim} 855 | Here there is no need for a |label|, because it is not used. 856 | \end{example} 857 | 858 | \begin{desc} 859 | |\EnumitemId| 860 | \end{desc} 861 | 862 | \New{3.7} To help in some tasks, a unique numeric identifier is 863 | assigned to each list, returned by |\EnumitemId|. 864 | 865 | \begin{example} 866 | Here is an example of how to combine a |\label| with |\EnumitemId|, 867 | and |after| to automatically set the width of the list label to the 868 | widest one (provided the ref is the same as the label):\footnote{See 869 | \texttt{https://tex.stackexchange.com/questions/29322/% 870 | how-to-make-enumerate-items-align-at-left-margin}.} 871 | \begin{verbatim} 872 | \SetEnumitemKey{widestlabel} 873 | {labelwidth = \widthof{\ref{enum-\EnumitemId}}, 874 | after = \label{enum-\EnumitemId}} 875 | \end{verbatim} 876 | Then just use the key |widestlabel|. 877 | \end{example} 878 | 879 | \begin{example} 880 | Reverse counting is also doable, but somewhat trickier, and we need 881 | some ``external'' help. Here is a possible solution, but not the 882 | only one (and very likely not even the best -- for example, |start| 883 | is in fact no-op). 884 | \begin{verbatim} 885 | \newcounter{rev-enumi} \newcounter{rev-enumii} 886 | \newcounter{rev-enumiii} \newcounter{rev-enumiv} 887 | 888 | \newcommand\revcounter[1]{% 889 | \setcounter{#1}{\value{#1}-2}% 890 | \stepcounter{rev-#1}% 891 | \gdef\afterrev{% 892 | \refstepcounter{rev-#1}% 893 | \setcounter{rev-#1}{0}}} 894 | 895 | \AddEnumerateCounter\revcounter\revcounter{} % the 2nd is dummy 896 | 897 | \SetEnumitemKey{revRoman} 898 | {start = \getrefnumber{enum-\EnumitemId}-1, 899 | label = (\Roman*)\revcounter*, 900 | ref = (\Roman*), 901 | after = \afterrev 902 | \label{enum-\EnumitemId}} 903 | \end{verbatim} 904 | \end{example} 905 | 906 | \subsection{Description styles} 907 | 908 | A key available in |description|. 909 | \begin{desc} 910 | |style=| 911 | \end{desc} 912 | 913 | Sets the description \textit{style}. || can be any of the 914 | following: 915 | \begin{description} 916 | \item[|standard|] Like |description| in standard classes, although 917 | with other classes it could be somewhat different. The label is 918 | boxed. Sets |itemindent=!|. 919 | 920 | \item[|unboxed|] Much like the standard |description|, but 921 | the label is not boxed to avoid uneven spacing and unbroken labels if 922 | they are long. Sets |itemindent=!|. 923 | 924 | \item [|nextline|] If the label does not fit in the margin, the text 925 | continues in the next line, otherwise it is placed in a box of width 926 | |\leftmargin| $-$ |\labelsep|, i.e., the item body never sticks into 927 | the left margin. Sets |labelwidth=!|. 928 | 929 | \item[|sameline|] Like |nextline| but if the label does not 930 | fit in the margin the text continues in the same line. Same as 931 | |style=unboxed,labelwidth=!|. 932 | 933 | \item[|multiline|] The label is placed in a parbox whose width is 934 | |leftmargin|, with several lines if necessary. Same as 935 | |style=standard,align=parleft,labelwidth=!|. If you modify it, bear in 936 | mind |align| cannot be set freely (for an internal optimization; in 937 | particular, a horizontal box doesn’t make sense and can raise an 938 | error). 939 | 940 | \end{description} 941 | 942 | \begin{warning} 943 | \begin{enumerate} 944 | \item Mixing boxed and unboxed labels has not a well-defined behavior. 945 | \item When nesting list all combinations are allowed but not all make 946 | sense. 947 | \item Nesting |nextline| lists is not supported (it works, but its 948 | behavior might change in the future, because the current one is not 949 | what one could expect). 950 | \end{enumerate} 951 | \end{warning} 952 | 953 | \subsection{Compact lists} 954 | 955 | \begin{desc} 956 | |noitemsep|\qquad|nosep| 957 | \end{desc} 958 | 959 | The key |noitemsep| kills the space between items and paragraphs 960 | (i.e., |itemsep=0pt| and |parsep=0pt|), while 961 | |nosep| kills all vertical spacing.\footnote{The key 962 | \texttt{nolistsep}, now deprecated, introduced a thin stretch, which 963 | was not the intended behavior.} 964 | 965 | \subsection{``Wide'' lists} 966 | 967 | \begin{desc} 968 | |wide|\\ 969 | |wide=| 970 | \end{desc} 971 | 972 | With this convenience key, the leftmargin is null and the label is 973 | part of the text---in other word, the items look like ordinary 974 | paragraphs.\footnote{\texttt{fullwidth} is deprecated.} Here |labelsep| 975 | sets the separation between the label and the first word. It is 976 | equivalent to 977 | \begin{verbatim} 978 | align=left, leftmargin=0pt, labelindent=\parindent, 979 | listparindent=\parindent, labelwidth=0pt, itemindent=! 980 | \end{verbatim} 981 | With |wide=| you may set at once another value instead of 982 | |\parindent|. Of course, these keys can be overridden after 983 | |wide|, too; for example, remembering that with left-aligned labels 984 | the text is pushed if the they are wider than |labelwidth|, you 985 | can set |labelwidth=1.5em| for a minimal width, or instead of 986 | |itemindent=!| you may prefer |itemindent=*|, which sets the 987 | minimal width to that of widest label. In level 2 you may prefer 988 | |labelindent=2\parindent|, and so on. You may also want to 989 | combine it with |noitemsep| or |nosep|. 990 | 991 | \subsection{\textsf{enumerate}-like labels} 992 | \label{s.short} 993 | 994 | \begin{desc} 995 | |shortlabels| (package option) 996 | \end{desc} 997 | 998 | With the package option \texttt{shortlabels} you can use an 999 | \textsf{enumerate}-like syntax, where |A|, |a|, |I|, 1000 | |i| and |1| stand for |\Alph*|, |\alph*|, 1001 | |\Roman*|, |\roman*| and |\arabic*|. This is intended 1002 | mainly as a sort of compatibility mode with the \textsf{enumerate} 1003 | package, and therefore the following special rule applies: if the very 1004 | first option (at any level) is not recognized as a valid key, then it 1005 | will be considered a label with the \textsf{enumerate}-like syntax. For 1006 | example: 1007 | \begin{verbatim} 1008 | \begin{enumerate}[i), labelindent=\parindent, labelsep=*] 1009 | ... 1010 | \end{enumerate} 1011 | \end{verbatim} 1012 | You may want to set |ref|, too, if different from the label. 1013 | 1014 | Although perhaps not so useful, you can omit |label=| in the 1015 | itemize environment under similar conditions, too: 1016 | \begin{verbatim} 1017 | \begin{itemize}[\textbullet] 1018 | ... 1019 | \end{itemize} 1020 | \end{verbatim} 1021 | 1022 | \begin{desc} 1023 | |\SetEnumerateShortLabel{}{}| 1024 | \end{desc} 1025 | 1026 | With this command, you can define new keys (or redefine them), which is 1027 | particularly useful for enumerate to be adapted to specific 1028 | typographical rules or to extend it for non-Latin scripts. Here 1029 | || contains one of the starred versions of 1030 | counters. 1031 | 1032 | \begin{example} 1033 | For example: 1034 | \begin{verbatim} 1035 | \SetEnumerateShortLabel{i}{\textsc{\roman*}} 1036 | \end{verbatim} 1037 | redefines |i| so that items using this key are numbered with 1038 | small caps roman numerals. 1039 | \end{example} 1040 | 1041 | \begin{note} 1042 | The key has to be a single character. 1043 | \end{note} 1044 | 1045 | \subsection{Generic keys and values} 1046 | 1047 | \begin{desc} 1048 | |\SetEnumitemKey{}{}| 1049 | \end{desc} 1050 | 1051 | With this command you can create your own (valueless) keys. Keys so 1052 | defined can then be used like the others. 1053 | 1054 | \begin{example} 1055 | With 1056 | \begin{verbatim} 1057 | \SetEnumitemKey{midsep}{topsep=3pt, partopsep=0pt} 1058 | \end{verbatim} 1059 | you may write 1060 | \begin{verbatim} 1061 | \begin{enumerate}[midsep] 1062 | \end{verbatim} 1063 | \end{example} 1064 | 1065 | \begin{example} 1066 | Another example is multicolumn lists, with \textsf{multicol}: 1067 | \begin{verbatim} 1068 | \SetEnumitemKey{twocol}{ 1069 | itemsep = 1\itemsep, 1070 | parsep = 1\parsep, 1071 | before = \raggedcolumns\begin{multicols}{2}, 1072 | after = \end{multicols}} 1073 | \end{verbatim} 1074 | Here, the settings for \texttt{itemsep} and \texttt{parsep} kill the 1075 | stretch and shrink parts, which in this case improves the result. Of 1076 | course, you may want to define a new list. 1077 | \end{example} 1078 | 1079 | \begin{warning} 1080 | The package may introduce new keys in the future, so 1081 | |\SetEnumitemKey| is a potential source of forward incompatibilities. 1082 | However, it's safe using a non-letter character other than hyphen or 1083 | star in the key name (e.g., |:name| or |2_col|), as well as uppercase 1084 | letters and digits, because \textsf{enumitem} will never use them. 1085 | \end{warning} 1086 | 1087 | \begin{desc} 1088 | |\SetEnumitemValue{}{}{}| 1089 | \end{desc} 1090 | 1091 | This commands provides a further abstraction layer for the 1092 | |=| pairs. With it you can define logical names which 1093 | are translated to the actual value. For example, with: 1094 | \begin{verbatim} 1095 | \SetEnumitemValue{label}{numeric}{\arabic*.} 1096 | \SetEnumitemValue{leftmargin}{standard}{\parindent} 1097 | \end{verbatim} 1098 | you might say: 1099 | \begin{verbatim} 1100 | \begin{enumerate}[label=numeric, leftmargin=standard] 1101 | \end{verbatim} 1102 | So, you can left to the final design what |label=numeric| means. 1103 | 1104 | \section{Inline lists} 1105 | \label{s.inline} 1106 | 1107 | Inline lists are ``horizontal'' lists set as ordinary text inside a 1108 | paragraph. With this package you can create inline lists, as explained 1109 | below, with |\newlist|, which have their own labels and counters. 1110 | However, very often inline versions of standard lists, with the same 1111 | labeling schema, will be enough -- the package option |inline| does 1112 | that. 1113 | 1114 | \begin{warning} 1115 | Items are boxed, so floats are lost and nested lists are not allowed 1116 | (remember many displayed elements are defined as lists). Links may 1117 | point to a wrong place, display math is forbidden, and due to an 1118 | optimization done by \TeX{} when building lists explicit hyphenation 1119 | may be wrong.\footnote{A Knuthian ``premature optimization''? Who 1120 | knows, but anyway with Lua\TeX{} hyphenation should be correct.} 1121 | There was a reason for this default setting, namely, this feature was 1122 | mainly devised for short items (a few words), and the parameter 1123 | |itemjoin*| could be useful for logical markup. To overcome these 1124 | limitations, you may set |mode=unboxed|, described below. 1125 | \end{warning} 1126 | 1127 | \begin{desc} 1128 | |inline| \qquad(package option)\\ 1129 | \texttt{enumerate*}\qquad\texttt{itemize*}\qquad 1130 | \texttt{description*} \qquad(environments) 1131 | \end{desc} 1132 | 1133 | With the package option \texttt{inline}, three environments for inline 1134 | lists are defined: \texttt{enumerate*}, \texttt{itemize*}, and 1135 | \texttt{description*}. They emulate the behavior of \textsf{paralist} 1136 | and \textsf{shortlst} in that labels and settings are shared with the 1137 | displayed (ie, ``normal'') lists \texttt{enumerate}, \texttt{itemize} 1138 | and \texttt{description}, respectively (however, remember resuming is 1139 | based on environment names, not on list types). This applies only to 1140 | those created with \texttt{inline} -- inline lists created with 1141 | |\newlist| as described below are independent and use their own labels 1142 | and settings. 1143 | 1144 | \begin{note} 1145 | Note |inline| is not required if you do not need the inline versions 1146 | of standard lists, but instead you define your own standalone inline 1147 | lists with |\newlist|. 1148 | \end{note} 1149 | 1150 | \begin{warning} 1151 | Settings for these three environments as defined by |inline| are 1152 | shared with the displayed variants, so they cannot be redefined 1153 | directly with |\newlist|. Trying to do it raises a cryptic error. If 1154 | you need separate setting, define them with |\newlist| and not with 1155 | |inline|. 1156 | \end{warning} 1157 | 1158 | \begin{desc} 1159 | |itemjoin=|\qquad|itemjoin*=| 1160 | \qquad|afterlabel=| 1161 | \end{desc} 1162 | 1163 | Format is set with keys \texttt{itemjoin} (default is a space), and 1164 | \texttt{afterlabel} (default is |\nobreakspace|, ie, |~|). 1165 | An additional key is \texttt{itemjoin*}, which, if set, is used 1166 | instead of \texttt{itemjoin} before the last item. 1167 | 1168 | |itemjoin| is ignored in vertical mode (i.e., in mode unboxed 1169 | and just after a quote, a displayed list and the like). 1170 | 1171 | \begin{example} 1172 | With 1173 | \begin{verbatim} 1174 | before=\unskip{: }, itemjoin={{; }}, itemjoin*={{, and }} 1175 | \end{verbatim} 1176 | the following punctuation between items is used: 1177 | \begin{quote} 1178 | Blah blah: (a) one; (b) two; (c) three, and (d) four. Blah blah 1179 | \end{quote} 1180 | \end{example} 1181 | 1182 | \begin{desc} 1183 | |mode=unboxed|\qquad|mode=boxed| 1184 | \end{desc} 1185 | 1186 | If using floats, lists or displayed math inside inline lists is 1187 | important, use an alternative ``mode'', which you can activate with 1188 | \texttt{mode=unboxed} (the default is \texttt{mode=boxed}). With it, 1189 | floats may be used freely, but misplaced |\item|s are not caught and 1190 | \texttt{itemjoin*} is ignored (a warning is written to the log about 1191 | this fact). 1192 | 1193 | \section{Global settings} 1194 | 1195 | Global changes, to be applied to all of these list, are also 1196 | possible: 1197 | \begin{desc} 1198 | |\setlist[enumerate,]{}|\\ 1199 | |\setlist[itemize,]{}|\\ 1200 | |\setlist[description,]{}|\\ 1201 | |\setlist[]{}| 1202 | \end{desc} 1203 | Where || is the list level (one or more) in |list|, and the 1204 | corresponding levels in |enumerate| and 1205 | |itemize|.\footnote{|\string\setenumerate|, 1206 | |\string\setitemize| and |\string\setdescription| are 1207 | deprecated.} With no ||, the format applies to all of them. 1208 | Here `list' does not mean any list but only the three ones handled by 1209 | this package, and those redefined by this package or defined with 1210 | |\newlist| (see below). For example: 1211 | \begin{verbatim} 1212 | \setlist{noitemsep} 1213 | \setlist[1]{labelindent=\parindent} % << Usually a good idea 1214 | \setlist[itemize]{leftmargin=*} 1215 | \setlist[itemize,1]{label=$\triangleleft$} 1216 | \setlist[enumerate]{labelsep=*, leftmargin=1.5pc} 1217 | \setlist[enumerate,1]{label = \arabic*., 1218 | ref = \arabic*} 1219 | \setlist[enumerate,2]{label = \emph{\alph*}), 1220 | ref = \theenumi.\emph{\alph*}} 1221 | \setlist[enumerate,3]{label = \roman*), 1222 | ref = \theenumii.\roman*} 1223 | \setlist[description]{font=\sffamily\bfseries} 1224 | \end{verbatim} 1225 | These setting are read in the following order: list, list at the 1226 | current level, enumerate/itemize/description, and 1227 | enumerate/itemize/description at the current level; if a key appears 1228 | several times with different values, the last one, i.e., the most 1229 | specific one, is applied. If we are resuming a series or a list with 1230 | \texttt{resume*}, the saved keys are then applied. Finally, the 1231 | optional argument (except \texttt{resume*}), if any, is applied. 1232 | 1233 | \LaTeX{} provides a set of macros to change many of these parameters, 1234 | but setting them with the package is more consistent and sometimes 1235 | more flexible at the cost of being more ``explicit'' (and verbose). 1236 | 1237 | The list specification can contain variables and counters, provided 1238 | they are expandable, and counters are \textsf{calc}-savvy, so that if 1239 | you load this package you can write things like: 1240 | \begin{verbatim} 1241 | \newcount{toplist} 1242 | \setcount{toplist}{1} 1243 | \newcommand{\mylistname}{enumerate} 1244 | \setlist[\mylistname,\value{toplist}+1]{labelsep=\itemindent+2em] 1245 | \end{verbatim} 1246 | This allows defining lists with the help of loops. 1247 | 1248 | \begin{warning} 1249 | It seems there is no way to catch a misspelled name in |\setlist| or 1250 | |\newlist|, and a meaningless error ``Missing number, treated as 1251 | zero'' is raised. 1252 | \end{warning} 1253 | 1254 | \section{Size dependent settings} 1255 | \label{s:sized} 1256 | 1257 | \New{3.6} For settings depending on the font size, in most cases all 1258 | you need are relative units like |ex| or |em|. Sometimes, you may want 1259 | discrete steps, and a special syntax allows them. 1260 | 1261 | The following package option is required for making use of this 1262 | feature. 1263 | 1264 | \begin{desc} 1265 | |sizes| (package option) 1266 | \end{desc} 1267 | 1268 | Lengths can contain size-based settings as follows (the value before 1269 | the first \texttt{<} is a default). 1270 | \begingroup 1271 | \makeatletter 1272 | \renewcommand\verbatim@font{\normalfont\ttfamily} 1273 | \begin{verbatim} 1274 | \setlist{ 1275 | topsep = 20pt <-10> 6pt <10-> 40pt, 1276 | leftmargin = <-10> 0cm <10> 1cm <10-> 2cm , 1277 | rightmargin = <-10> 0cm <10> 1cm <10-> 2cm , 1278 | } 1279 | \end{verbatim} 1280 | \endgroup 1281 | 1282 | Names are accepted, too: |script|, |tiny|, |footnote|, |small|, 1283 | |normal|, |large|, |Large|, |LARGE|, |huge|, |Huge| (ie, remove `size' 1284 | from the \LaTeX{} name if necessary). For example: 1285 | \begingroup 1286 | \makeatletter 1287 | \renewcommand\verbatim@font{\normalfont\ttfamily} 1288 | \begin{verbatim} 1289 | \setlist{ 1290 | topsep = 20pt <-normal> 6pt 40pt, 1291 | leftmargin = <-normal> 0cm 1cm 2cm , 1292 | rightmargin = <-normal> 0cm 1cm 2cm , 1293 | } 1294 | \end{verbatim} 1295 | \endgroup 1296 | 1297 | Single values take precedence over ranges (i. e., specific takes 1298 | precedence over generic). In ranges, the last match wins. The range 1299 | |a-b| is $a \le \mbox{size} < b$ (the lower bound is included, but not 1300 | the upper one). These rules allow in the examples above the setting for 1301 | |10| or |normal| in the logical place. Remember nominal sizes are not 1302 | always the real sizes -- for example, with option |11pt|, |\normalsize| 1303 | (and |normal|) is 10.95. You may precede a value with several single 1304 | qualifiers like 1305 | \texttt{<}|small|\texttt{><}|normal|\texttt{>}|12pt|.\footnote{Note 1306 | this syntax follows closely that of \texttt{\string\DeclareFontShape}, 1307 | except in the precedence of single values.} A value before the first 1308 | \texttt{<..>} is considered a default value. 1309 | 1310 | \begin{note} 1311 | For efficiency reasons, named sizes are assigned only once, when 1312 | \textsf{enumitem} is loaded, in the assumption they are set by the 1313 | class, or a local style loaded previously. 1314 | \end{note} 1315 | 1316 | \begin{desc} 1317 | |\SetEnumitemSize{}{}| 1318 | \end{desc} 1319 | 1320 | \New{3.7} If sizes are modified after loading \textsf{enumitem} or you 1321 | are using a class with non standard sizes (or even you just want 1322 | another names), they can be set or reset with the following tool. 1323 | 1324 | \begin{example} 1325 | A trivial example: 1326 | \begin{verbatim} 1327 | \SetEnumitemSize{normal}{\normalsize} 1328 | \SetEnumitemSize{large}{\large} 1329 | \end{verbatim} 1330 | \end{example} 1331 | 1332 | \begin{desc} 1333 | |\setlist|\texttt{\string<}||\texttt{\string>}% 1334 | |[,]{}| 1335 | \end{desc} 1336 | 1337 | \New{3.7} An extension to |\setlist| described below which adds the 1338 | definitions, but only for the given size (either single or a range). 1339 | The precedence rules for sizes also apply here (so that the order of 1340 | |\setlist|'s are relevant), and size dependent keys as defined by this 1341 | procedure take precedence over the rest of the keys. For example: 1342 | \begingroup 1343 | \makeatletter 1344 | \renewcommand\verbatim@font{\normalfont\ttfamily} 1345 | \begin{verbatim} 1346 | \setlist<-normal>[enumerate]{nosep} 1347 | \end{verbatim} 1348 | \endgroup 1349 | 1350 | However, only a size qualifier is accepted in each |\setlist|. 1351 | 1352 | \section{Cloning the basic lists} 1353 | \label{s.clone} 1354 | 1355 | \begin{desc} 1356 | |\newlist{}{}{}|\\ 1357 | |\renewlist{}{}{}| 1358 | \end{desc} 1359 | 1360 | The three lists can be cloned so that you can define ``logical'' 1361 | environments behaving like them. To define a new lists (or redefine a 1362 | existing one), use |\newlist| (or |\renewlist|), where || is 1363 | |enumerate|, |itemize| or |description|. Inline lists have types 1364 | \texttt{enumerate*}, \texttt{itemize*}, and \texttt{description*}. 1365 | 1366 | \begin{note} 1367 | The inline ||s are available always, even without the package 1368 | option |inline|, which just defines three environments of the 1369 | corresponding types with those names. 1370 | \end{note} 1371 | 1372 | If || is |enumerate|, a set of counters with names |i|, 1373 | |ii|, |iii|, |iv|, etc. (depending on ||) 1374 | is defined. 1375 | 1376 | Then you can use those counters in labels; e. g., if you have defined a 1377 | list named \texttt{steps}, you can define a label with: 1378 | \begin{verbatim} 1379 | label=\arabic{stepsii}.\arabic{stepsi} 1380 | \end{verbatim} 1381 | 1382 | \begin{warning} 1383 | Don't use an arbitrarily large number for ||, to avoid 1384 | creating too many counters and related macros. 1385 | \end{warning} 1386 | 1387 | \begin{warning} 1388 | For consistency with the counter naming schema in \LaTeX, list levels 1389 | are also named internally with a roman numeral, ie, |i|, 1390 | |ii|, |iii|, etc. For this reason (both counter and list 1391 | names), defining two lists as, say, |books| and |booksi| leads to 1392 | unexpected results (currently without any warning, which should be 1393 | fixed). 1394 | % TODO - Perhaps I must change the internal names, so that 1395 | % this restriction doesn't apply to itemize and description.] 1396 | \end{warning} 1397 | 1398 | \begin{desc} 1399 | |\setlist[,]{}|\\ 1400 | |\setlist*[,]{}| 1401 | \end{desc} 1402 | 1403 | After creating a list, you can (in fact you 1404 | must, at least the label) set the new list with |\setlist|: 1405 | \begin{verbatim} 1406 | \newlist{ingredients}{itemize}{1} 1407 | \setlist[ingredients]{label=\textbullet} 1408 | \newlist{steps}{enumerate}{2} 1409 | \setlist[steps,1,2]{label=(\arabic*)} 1410 | \end{verbatim} 1411 | Names in the optional argument of |\setlist| say which lists applies the 1412 | settings to, and numbers say the level (it is |calc|-savvy). Several 1413 | lists and/or several levels can be given, and all combinations are 1414 | set; e.g.: 1415 | \begin{verbatim} 1416 | \setlist[enumerate,itemize,2,3]{...} 1417 | \end{verbatim} 1418 | \noindent sets enumerate/2, enumerate/3, itemize/2 and itemize/3. 1419 | No number (or 0) means ``all levels'' and no name means ``all lists''; no 1420 | optional argument means ``all lists at all levels''. 1421 | 1422 | The starred form |\setlist*| adds the settings to the previous ones. 1423 | You may restrict the additions to a certain font size, as explained in 1424 | section \ref{s:sized}. It must be noted the latter have a higher 1425 | precedence than the starred ones (i. e., settings added for some sizes 1426 | take precedence over settings added for all sizes, so that the most 1427 | specific value for a key is applied). 1428 | 1429 | \begin{desc} 1430 | |\setlistdepth{}| 1431 | \end{desc} 1432 | 1433 | By default, \LaTeX{} has a limit of 5 nesting levels, but when 1434 | cloning lists this value may be too short, and therefore you may want 1435 | to set a new value. In levels below the 5th (or the deepest defined by a 1436 | class), the settings of the last are used (i.e., |\@listvi|). 1437 | 1438 | \section{More about counters} 1439 | 1440 | \subsection{New counter representation} 1441 | 1442 | \begin{desc} 1443 | |\AddEnumerateCounter{}{}{}| 1444 | \end{desc} 1445 | 1446 | ``Registers'' a counter representation so that \textsf{enumitem} 1447 | recognizes it. Intended mainly for non Latin scripts, but also useful 1448 | in Latin scripts. 1449 | 1450 | \begin{example} 1451 | The following example defines a new counter with named ordinals: 1452 | \begin{verbatim} 1453 | \makeatletter 1454 | \def\ctext#1{\expandafter\@ctext\csname c@#1\endcsname} 1455 | \def\@ctext#1{\ifcase#1\or First\or Second\or Third\or 1456 | Fourth\or Fifth\or Sixth\fi} 1457 | \makeatother 1458 | \AddEnumerateCounter{\ctext}{\@ctext}{Second} 1459 | \end{verbatim} 1460 | \end{example} 1461 | 1462 | \begin{note} 1463 | The counter names can contain |@| even if not a letter without 1464 | raising an error, as shown in the example above. 1465 | \end{note} 1466 | 1467 | A starred variant allows to give a number instead of a string as the 1468 | widest label. 1469 | 1470 | \begin{example} 1471 | If the widest label is that corresponding to the value 2: 1472 | \begin{verbatim} 1473 | \AddEnumerateCounter*{\ctext}{\@ctmoreext}{2} 1474 | \end{verbatim} 1475 | \end{example} 1476 | 1477 | This variant is to be preferred if the representation is not a plain 1478 | string but it is styled, e.g., with small caps. 1479 | 1480 | \begin{example} 1481 | An example for Russian is: 1482 | \begin{verbatim} 1483 | \AddEnumerateCounter*{\asbuk}{\c@asbuk}{7} 1484 | \end{verbatim} 1485 | \end{example} 1486 | 1487 | \subsection{Restarting \texttt{enumerate}s} 1488 | 1489 | \begin{desc} 1490 | |\restartlist{}| 1491 | \end{desc} 1492 | 1493 | Currently you can get a continuous numbering through a document with: 1494 | \begin{verbatim} 1495 | \setlist[enumerate]{resume} 1496 | \end{verbatim} 1497 | |\restartlist| has been added for restarting the counter in the middle 1498 | of the document. For example, you could emit a |\restartlist| when 1499 | chapters start, so that there is a continuous numbering through every 1500 | chapter. 1501 | 1502 | \begin{warning} 1503 | It is based solely in the list \textit{name}, \textit{not} the list 1504 | \textit{type}, which means \texttt{enumerate*} as defined with the 1505 | package option \texttt{inline} is not the same as \texttt{enumerate}, 1506 | because its name is different. 1507 | \end{warning} 1508 | 1509 | \section{Package options} 1510 | 1511 | Besides |inline|, |ignoredisplayed|, |sizes|, |series=override| and 1512 | |shortlabels|, the following option is available. 1513 | 1514 | \begin{desc} 1515 | |loadonly| 1516 | \end{desc} 1517 | 1518 | With this package option the package is loaded but the three 1519 | lists are not redefined. You can create your own lists, yet, or 1520 | even redefine the existing ones. 1521 | 1522 | \section{The trivlist issue} 1523 | 1524 | \LaTeX{} uses a simplified version of |list| named |trivlist| to set 1525 | displayed material, like |center|, |tabbing|, |theorem|, etc., even if 1526 | conceptually they are not lists. Unfortunately, |trivlist| uses the 1527 | current list settings, which has the odd side effect that changing the 1528 | vertical spacing of lists also changes sometimes the spacing in these 1529 | environments. 1530 | 1531 | This package modifies |trivlist| so that the default settings for 1532 | the current level (ie, those set by the corresponding |clo| 1533 | files) are set again. In standard \LaTeX{} that is usually redundant, 1534 | but if we want to fine tune lists, not resetting the default values 1535 | could be a real issue (particularly if you use the |nosep| 1536 | option). 1537 | 1538 | A minimal control of vertical spacing has been made possible 1539 | with\footnote{|\string\setdisplayed| is deprecated.} 1540 | \begin{itemize} 1541 | \item |\setlist[trivlist,]{}| 1542 | \end{itemize} 1543 | but |trivlist| itself, which is not used directly very often, does not 1544 | accept an optional argument. This feature is not intended as a 1545 | full-fledge |trivlist| formatter. 1546 | 1547 | If for some reason you do not want to change |trivlist| and preserve 1548 | the original definition, you can use the package option 1549 | |ignoredisplayed|. 1550 | 1551 | \New{3.6} If, on the other hand, you want to also apply the changes for 1552 | all lists to trivlists, just set the package option |includedisplayed|. 1553 | 1554 | \section{Samples} 1555 | 1556 | \expandafter\ifx\csname setenumerate\endcsname\relax 1557 | 1558 | Please, install first the package and then typeset this document again. 1559 | 1560 | \else 1561 | 1562 | In these samples we set |\setlist{noitemsep}| 1563 | 1564 | \setlist{noitemsep} 1565 | \small 1566 | 1567 | \newcommand{\newsample}{\vskip6pt\goodbreak\hrule height 1pt\vskip6pt} 1568 | \newcommand{\samplesep}{\vskip6pt\goodbreak\hrule\vskip6pt} 1569 | \newbox\vsep 1570 | \setbox\vsep\hbox{\vrule height 2ex depth 16ex width 1pt} 1571 | \dp\vsep0pt 1572 | \newcommand\showsep{\leavevmode\llap{\copy\vsep}} 1573 | 1574 | \newsample 1575 | 1576 | \begin{verbatim} 1577 | En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1578 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1579 | \begin{enumerate}[labelindent=\parindent,leftmargin=*] 1580 | \item lanza en astillero, 1581 | \item adarna antigua, 1582 | \item roc\'{\i}n flaco, y 1583 | \item galgo corredor. 1584 | \end{enumerate} 1585 | Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s 1586 | noches, duelos y quebrantos los s\'{a}bados... 1587 | \end{verbatim} 1588 | 1589 | The rule shows |labelindent|. 1590 | 1591 | \samplesep 1592 | 1593 | \showsep En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1594 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1595 | \begin{enumerate}[labelindent=\parindent,leftmargin=*] 1596 | \item lanza en astillero, 1597 | \item adarna antigua, 1598 | \item roc\'{\i}n flaco, y 1599 | \item galgo corredor. 1600 | \end{enumerate} 1601 | Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s 1602 | noches, duelos y quebrantos los s\'{a}bados... 1603 | 1604 | \newsample 1605 | 1606 | With |\begin{enumerate}[leftmargin=*] % labelindent=0pt by default|. 1607 | 1608 | The rule shows |labelindent|. 1609 | 1610 | \samplesep 1611 | 1612 | \noindent\showsep\hskip\parindent En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1613 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1614 | \begin{enumerate}[leftmargin=*] 1615 | \item lanza en astillero, 1616 | \item adarna antigua, 1617 | \item roc\'{\i}n flaco, y 1618 | \item galgo corredor. 1619 | \end{enumerate} 1620 | Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s 1621 | noches, duelos y quebrantos los s\'{a}bados... 1622 | 1623 | \newsample 1624 | 1625 | With |\begin{enumerate}[leftmargin=\parindent]|. 1626 | 1627 | The rule shows |leftmargin|. 1628 | 1629 | \samplesep 1630 | 1631 | \showsep En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1632 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1633 | \begin{enumerate}[leftmargin=\parindent] 1634 | \item lanza en astillero, 1635 | \item adarna antigua, 1636 | \item roc\'{\i}n flaco, y 1637 | \item galgo corredor. 1638 | \end{enumerate} 1639 | Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s 1640 | noches, duelos y quebrantos los s\'{a}bados... 1641 | 1642 | \newsample 1643 | 1644 | With |\begin{enumerate}[labelindent=\parindent,|\allowbreak 1645 | | leftmargin=*,|\allowbreak| label=\Roman*.,|\allowbreak 1646 | | widest=III,|\allowbreak| align=left]|. 1647 | 1648 | The rule shows |labelindent|. Note 1649 | 1650 | \samplesep 1651 | 1652 | \showsep En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1653 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1654 | \begin{enumerate}[labelindent=\parindent, leftmargin=*, 1655 | label=\Roman*., widest=III, align=left] 1656 | \item lanza en astillero, 1657 | \item adarna antigua, 1658 | \item roc\'{\i}n flaco, y 1659 | \item galgo corredor. 1660 | \end{enumerate} 1661 | Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s 1662 | noches, duelos y quebrantos los s\'{a}bados... 1663 | 1664 | \newsample 1665 | 1666 | With |\begin{enumerate}[label=\fbox{\arabic*}]|. A reference to 1667 | the first item is \ref{i:first} 1668 | 1669 | \samplesep 1670 | 1671 | En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1672 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1673 | \begin{enumerate}[label=\fbox{\arabic*}] 1674 | \item \label{i:first}lanza en astillero, 1675 | \item adarna antigua, 1676 | \item roc\'{\i}n flaco, y 1677 | \item galgo corredor. 1678 | \end{enumerate} 1679 | Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s 1680 | noches, duelos y quebrantos los s\'{a}bados... 1681 | 1682 | \newsample 1683 | 1684 | With nested lists. 1685 | 1686 | \samplesep 1687 | 1688 | \begin{verbatim} 1689 | En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1690 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1691 | \begin{enumerate}[label=(\alph*), labelindent=\parindent, 1692 | leftmargin=*, start=12] 1693 | \item lanza en astillero, 1694 | \begin{enumerate}[label=(\alph{enumi}.\roman*), leftmargin=*, start=7] 1695 | \item adarna antigua, 1696 | \end{enumerate} 1697 | \item roc\'{\i}n flaco, y 1698 | \begin{enumerate}[label=(\alph{enumi}.\roman*), leftmargin=*, resume] 1699 | \item galgo corredor. 1700 | \end{enumerate} 1701 | \end{enumerate} 1702 | Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s 1703 | noches, duelos y quebrantos los s\'{a}bados... 1704 | \end{verbatim} 1705 | 1706 | En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1707 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1708 | \begin{enumerate}[label=(\alph*), labelindent=\parindent, 1709 | leftmargin=*, start=12] 1710 | \item lanza en astillero, 1711 | \begin{enumerate}[label=(\alph{enumi}.\roman*), leftmargin=*, start=7] 1712 | \item adarna antigua, 1713 | \end{enumerate} 1714 | \item roc\'{\i}n flaco, y 1715 | \begin{enumerate}[label=(\alph{enumi}.\roman*), leftmargin=*, resume] 1716 | \item galgo corredor. 1717 | \end{enumerate} 1718 | \end{enumerate} 1719 | Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s 1720 | noches, duelos y quebrantos los s\'{a}bados... 1721 | 1722 | \newsample 1723 | 1724 | \begin{verbatim} 1725 | En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1726 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1727 | \begin{description}[font=\sffamily\bfseries, leftmargin=3cm, 1728 | style=nextline] 1729 | \item[Lo primero que ten\'{\i}a el Quijote] lanza en astillero, 1730 | \item[Lo segundo] adarna antigua, 1731 | \item[Lo tercero] roc\'{\i}n flaco, y 1732 | \item[Y por \'{u}ltimo, lo cuarto] galgo corredor. 1733 | \end{description} 1734 | Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s 1735 | noches, duelos y quebrantos los s\'{a}bados... 1736 | \end{verbatim} 1737 | 1738 | \samplesep 1739 | 1740 | En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1741 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1742 | \begin{description}[font=\sffamily\bfseries, leftmargin=3cm, 1743 | style=nextline] 1744 | \item[Lo primero que ten\'{\i}a el Quijote] lanza en astillero, 1745 | \item[Lo segundo] adarna antigua, 1746 | \item[Lo tercero] roc\'{\i}n flaco, y 1747 | \item[Y por \'{u}ltimo, lo cuarto] galgo corredor. 1748 | \end{description} 1749 | Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s 1750 | noches, duelos y quebrantos los s\'{a}bados... 1751 | 1752 | \newsample 1753 | 1754 | Same, but with |sameline|. 1755 | 1756 | \samplesep 1757 | 1758 | En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1759 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1760 | \begin{description}[font=\sffamily\bfseries, leftmargin=3cm, 1761 | style=sameline] 1762 | \item[Lo primero que ten\'{\i}a el Quijote] lanza en astillero, 1763 | \item[Lo segundo] adarna antigua, 1764 | \item[Lo tercero] roc\'{\i}n flaco, y 1765 | \item[Y por \'{u}ltimo, lo cuarto] galgo corredor. 1766 | \end{description} 1767 | Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s 1768 | noches, duelos y quebrantos los s\'{a}bados... 1769 | 1770 | \newsample 1771 | 1772 | Same, but with |multiline|. Note the text overlaps if the item body is 1773 | too short. 1774 | 1775 | \samplesep 1776 | 1777 | En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1778 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1779 | \begin{description}[font=\sffamily\bfseries, leftmargin=3cm, 1780 | style=multiline] 1781 | \item[Lo primero que ten\'{\i}a el Quijote] lanza en astillero, 1782 | \item[Lo segundo] adarna antigua, 1783 | \item[Lo tercero] roc\'{\i}n flaco, y 1784 | \item[Y por \'{u}ltimo, lo cuarto] galgo corredor. 1785 | \end{description} 1786 | Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s 1787 | noches, duelos y quebrantos los s\'{a}bados... 1788 | 1789 | \fi 1790 | 1791 | \normalsize 1792 | 1793 | \section{Afterword} 1794 | 1795 | \subsection{\LaTeX{} lists} 1796 | 1797 | As it is well known, \LaTeX{} predefines three lists: 1798 | \texttt{enumerate}, \texttt{itemize} and \texttt{description}. This 1799 | is a very frequent classification which can also be found in, say, 1800 | HTML. However, there is a more general model based in three 1801 | fields---namely, label, title, and body---, so that enumerate and 1802 | itemize has label (numbered and unnumbered) but no title, while 1803 | description has title but no label. In this model, one can have a 1804 | description with entries marked with labels, as for example (of 1805 | course, this simple solution is far from satisfactory): 1806 | \begin{verbatim} 1807 | \newcommand\litem[1]{\item{\bfseries #1,\enspace}} 1808 | \begin{itemize}[label=\textbullet] 1809 | \litem{Lo primero que ten\'{\i}a el Quijote} lanza en astillero, 1810 | ... etc. 1811 | \end{verbatim} 1812 | 1813 | \vskip6pt 1814 | \goodbreak 1815 | \hrule 1816 | \vskip6pt 1817 | 1818 | \newcommand\litem[1]{\item{\bfseries #1,\enspace}} 1819 | En un lugar de la Mancha, de cuyo nombre no quiero acordarme, 1820 | no ha mucho tiempo que viv\'{\i}a un hidalgo de los de 1821 | \begin{itemize}[label=\textbullet] 1822 | \litem{Lo primero que ten\'{\i}a el Quijote} lanza en astillero, 1823 | \litem{Lo segundo} adarna antigua, 1824 | \litem{Lo tercero} roc\'{\i}n flaco, y 1825 | \litem{Y por \'{u}ltimo, lo cuarto} galgo corredor. 1826 | \end{itemize} 1827 | 1828 | \vskip6pt 1829 | \goodbreak 1830 | \hrule 1831 | \vskip6pt 1832 | 1833 | % This format in not infrequent at all and a tool for defining them is 1834 | % on the way and at a very advanced stage. It has not been include in 1835 | % version 3.0 because I'm not sure if the proper place is this package 1836 | % or \textsf{titlesec} and it is not stable enough yet. 1837 | 1838 | \subsection{Known issues} 1839 | 1840 | \begin{itemize} 1841 | 1842 | \item 1843 | List resuming is based on environment names, and when a 1844 | |\newenvironment| contains a list you may want to use |\begin{}| 1845 | and |\end{}|. Using the corresponding low-level commands (ie, 1846 | |\| and |\end|) is not an error, but it is your 1847 | responsibility to make sure the result is correct. 1848 | 1849 | \item The behavior of mixed boxed labels (including enumerate and 1850 | itemize) and unboxed labels is not well-defined. The same applies to 1851 | boxed and unboxed inline lists (which could even raise an error). 1852 | 1853 | \item 1854 | Similarly, resuming a series and a list at the same time is allowed, 1855 | too, but again its behavior is not well-defined. 1856 | 1857 | \item (3.5.2) An incompatibility with 2.x has popped up -- if you were 1858 | using the optional argument to pass a value to a |\ref| or other 1859 | macro requiring expandable macros, an error is raised. A quick fix 1860 | is letting |\makelabel| to |\descriptionlabel| in \texttt{before}. 1861 | 1862 | \end{itemize} 1863 | 1864 | \subsection{What's new in 3.0} 1865 | 1866 | \begin{itemize} 1867 | \item Inline lists, with keys to set how items are joined (ie, the 1868 | punctuation between items). Two modes are provided: |boxed| and 1869 | |unboxed|. 1870 | 1871 | \item |\setlist| is \textsf{calc}-savvy (eg, for use in loops), 1872 | and you can set different lists and levels at once. \item All lengths 1873 | related to labels can take the value |*| (and not only 1874 | |labelsep| and |leftmargin|). Its behavior has been made 1875 | consistent and there is new value |!| which does not compute the 1876 | widest label. 1877 | 1878 | \item With |\restartlist{}|, list counters can be restarted (in 1879 | case you are using |resume|). 1880 | 1881 | \item |resume*| can be combined with other keys. 1882 | 1883 | \item Lists can be gathered globally using series, so that they are 1884 | considered a single list. To start a series just use 1885 | |series=| and then resume it with |resume=| 1886 | or |resume*=|. 1887 | 1888 | \item The ``experimental'' |fullwidth| has been replaced by a new key 1889 | |wide|. 1890 | 1891 | \item|\SetLabelAlign| defines new align values. 1892 | 1893 | \item You can define ``abstract'' values (eg, |label=numeric|) and 1894 | new keys. 1895 | \end{itemize} 1896 | 1897 | \begin{itemize} 1898 | \item (3.2) |start| and |widest*| are \textsf{calc}-savvy. 1899 | \item (3.2) |\value| can be used with |widest*|. 1900 | \item (3.2) Some internal restrictions in |\arabic| and the like 1901 | has been removed. It is more flexible at the cost of having a more 1902 | ``relaxed'' error checking. 1903 | \end{itemize} 1904 | \subsection{Bug fixes} 1905 | 1906 | \begin{itemize} 1907 | \item Star values (eg, |leftmargin=*|) could not be overridden 1908 | and new values were ignored. 1909 | \item |nolistsep| as the first of several keys was not always 1910 | recognized and therefore treated like a short label 1911 | (i.e., |nol\roman*stsep|). 1912 | \item |labelwidth| did not always work (when there was a prior 1913 | |widest| and |*|) 1914 | \item With |align=right| the label and the following text could 1915 | overlap. 1916 | \item |description| did not get the correct list level. 1917 | \item At some point (2.x?) |\value*| stopped working. 1918 | \item (3.1) Unfortunately, \textsf{xkeyval} ``kills'' 1919 | \textsf{keyval}, so the latest has been replicated in 1920 | \textsf{enumitem}. 1921 | \item (3.3) Fixes a serious bug -- with |*| neither 1922 | |itemize| nor |description| worked. 1923 | \item (3.4) Fixes bad spacing in mode boxed (misplaced |\unskip| 1924 | before the first item and wrong spacefactor between items). 1925 | \item (3.4) |nolistsep| did not work as intended, but since the 1926 | error has been there for several years, a new key |nosep| is 1927 | provided. 1928 | \item (3.4) The issue with |nolistsep| with |shortlabels| 1929 | (see above) was not fixed in all cases. Hopefully now it is. 1930 | \item (3.5.0) Fixed the fix related to the spacefactor between items. 1931 | \item (3.5.0) Fixed a problem with nested boxed inline lists. 1932 | \item (3.5.1) \texttt{resume*} only worked once, and subsequent ones 1933 | bahaved like \texttt{resume}. 1934 | \item (3.5.2) Fixed |\setlist*|, which didn't work. 1935 | \end{itemize} 1936 | 1937 | \subsection{Acknowledgements} 1938 | 1939 | I wish to thank particularly the comments and suggestions from Lars 1940 | Madsen, who has found some bugs, too. 1941 | 1942 | \end{document} 1943 | 1944 | MIT License 1945 | ----------- 1946 | 1947 | Permission is hereby granted, free of charge, to any person obtaining a 1948 | copy of this software and associated documentation files (the 1949 | "Software"), to deal in the Software without restriction, including 1950 | without limitation the rights to use, copy, modify, merge, publish, 1951 | distribute, sublicense, and/or sell copies of the Software, and to 1952 | permit persons to whom the Software is furnished to do so, subject to 1953 | the following conditions: 1954 | 1955 | The above copyright notice and this permission notice shall be included 1956 | in all copies or substantial portions of the Software. 1957 | 1958 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1959 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1960 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 1961 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 1962 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 1963 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 1964 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 1965 | --------------------------------------------------------------------------------