| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 1993-2025 |
| 4 |
% |
| 5 |
% The LaTeX Project and any individual authors listed elsewhere |
| 6 |
% in this file. |
| 7 |
% |
| 8 |
% This file is part of the Standard LaTeX `Tools Bundle'. |
| 9 |
% ------------------------------------------------------- |
| 10 |
% |
| 11 |
% It may be distributed and/or modified under the |
| 12 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 13 |
% of this license or (at your option) any later version. |
| 14 |
% The latest version of this license is in |
| 15 |
% https://www.latex-project.org/lppl.txt |
| 16 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 17 |
% version 2005/12/01 or later. |
| 18 |
% |
| 19 |
% The list of all files belonging to the LaTeX `Tools Bundle' is |
| 20 |
% given in the file `manifest.txt'. |
| 21 |
% |
| 22 |
% \fi |
| 23 |
% \iffalse |
| 24 |
%% File: enumerate.dtx Copyright 1993 1994 1999 David Carlisle |
| 25 |
% |
| 26 |
%<*dtx> |
| 27 |
\ProvidesFile{enumerate.dtx} |
| 28 |
%</dtx> |
| 29 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 30 |
%<package>\ProvidesPackage{enumerate} |
| 31 |
%<driver> \ProvidesFile{enumerate.drv} |
| 32 |
% \fi |
| 33 |
% \ProvidesFile{enumerate.dtx} |
| 34 |
[2023/07/04 v3.00 enumerate extensions (DPC)] |
| 35 |
% |
| 36 |
% \iffalse |
| 37 |
%<*driver> |
| 38 |
\documentclass{ltxdoc} |
| 39 |
\usepackage{enumerate} |
| 40 |
\begin{document} |
| 41 |
\DocInput{enumerate.dtx} |
| 42 |
\end{document} |
| 43 |
%</driver> |
| 44 |
% \fi |
| 45 |
% |
| 46 |
% \GetFileInfo{enumerate.dtx} |
| 47 |
% \title{The \textsf{enumerate} package\thanks{This file |
| 48 |
% has version number \fileversion, last |
| 49 |
% revised \filedate.}} |
| 50 |
% \author{David Carlisle} |
| 51 |
% \date{\filedate} |
| 52 |
% \MaintainedByLaTeXTeam{tools} |
| 53 |
% \maketitle |
| 54 |
% |
| 55 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 56 |
% |
| 57 |
% |
| 58 |
% \changes{v1.00}{1990/00/00}{First version (since lost)} |
| 59 |
% \changes{v2.00}{1991/07/25}{New Algorithm} |
| 60 |
% \changes{v2.01}{1992/06/26}{Re-issue for the new doc and docstrip.} |
| 61 |
% \changes{v2.02}{1994/01/31}{Update for LaTeX2e} |
| 62 |
% \changes{v3.00}{1999/03/05}{Add extension hook for tools/2916} |
| 63 |
% \changes{v3.00}{2015/07/23}{Documentation fixes tools/2916} |
| 64 |
% |
| 65 |
% \changes{v3.00}{2025-06-04}{Add notice pointing to \pkg{enumitem}} |
| 66 |
% \begin{flushleft} |
| 67 |
% \bfseries |
| 68 |
% This package is retained in the \LaTeX{} \pkg{tools} bundle for |
| 69 |
% stability reasons. Whilst bug fixes will be applied to \pkg{enumerate}, |
| 70 |
% no \emph{new} features will be considered. For new material, the |
| 71 |
% \LaTeX{} team recommends that \pkg{enumitem} is used in place of |
| 72 |
% \pkg{enumerate}. |
| 73 |
% \end{flushleft} |
| 74 |
% |
| 75 |
% \begin{abstract} |
| 76 |
% This package gives the enumerate environment an optional argument |
| 77 |
% which determines the style in which the counter is printed. |
| 78 |
% |
| 79 |
% An occurrence of one of the tokens |A a I i 1| produces the value |
| 80 |
% of the counter printed with (respectively) |\Alph \alph \Roman \roman| |
| 81 |
% or |\arabic|. |
| 82 |
% |
| 83 |
% These letters may be surrounded by any strings involving any other |
| 84 |
% \TeX\ expressions, however the tokens |A a I i 1| must be inside a |
| 85 |
% |{ }| group if they are not to be taken as special. |
| 86 |
% \end{abstract} |
| 87 |
% |
| 88 |
% \section{Examples} |
| 89 |
%\showboxdepth=10 |
| 90 |
% \showboxbreadth=10 |
| 91 |
% \[ |
| 92 |
% \parbox{2.2in}{\hbadness2000 |
| 93 |
% \begin{enumerate}[EX i.] |
| 94 |
% \item one one one one one one one |
| 95 |
% one one one one one\label{LA} |
| 96 |
% \item two |
| 97 |
% \begin{enumerate}[{example} a)] |
| 98 |
% \item one of two one of two one of two\label{LB} |
| 99 |
% \item two of two |
| 100 |
% \end{enumerate} |
| 101 |
% \end{enumerate} |
| 102 |
% \begin{enumerate}[{A}-1] |
| 103 |
% \item one\label{LC} |
| 104 |
% \item two |
| 105 |
% \end{enumerate}} |
| 106 |
% \hspace{20pt} |
| 107 |
% \vcenter{\hsize=2.4in |
| 108 |
% \begin{verbatim} |
| 109 |
% \begin{enumerate}[EX i.] |
| 110 |
% \item one one one one one one one |
| 111 |
% one one one one\label{LA} |
| 112 |
% \item two |
| 113 |
% \begin{enumerate}[{example} a)] |
| 114 |
% \item one of two one of two |
| 115 |
% one of two\label{LB} |
| 116 |
% \item two of two |
| 117 |
% \end{enumerate} |
| 118 |
% \end{enumerate} |
| 119 |
% |
| 120 |
% \begin{enumerate}[{A}-1] |
| 121 |
% \item one\label{LC} |
| 122 |
% \item two |
| 123 |
% \end{enumerate} |
| 124 |
% \end{verbatim} |
| 125 |
% }\] |
| 126 |
% |
| 127 |
% |\label| and |\ref| may be used as with the standard {\tt |
| 128 |
% enumerate} environment. |\ref| only produces the counter value, |
| 129 |
% not the whole label. |\ref| prints the value in the same style |
| 130 |
% as |\item|, as determined by the presence of one of the tokens |
| 131 |
% |A a I i 1| in the optional argument. In the above example |
| 132 |
% |\ref{LA}|, |\ref{LB}| and |\ref{LC}| produce |
| 133 |
% `\ref{LA}', `\ref{LB}' and `\ref{LC}' respectively. |
| 134 |
% |
| 135 |
% \MaybeStop{} |
| 136 |
% |
| 137 |
%\section{Macros} |
| 138 |
% |
| 139 |
% \begin{macrocode} |
| 140 |
%<*package> |
| 141 |
% \end{macrocode} |
| 142 |
% |
| 143 |
% \begin{macro}{\@enlab} |
| 144 |
% Internal token register used to build up the label command from the |
| 145 |
% optional argument. |
| 146 |
% \begin{macrocode} |
| 147 |
\newtoks\@enLab |
| 148 |
% \end{macrocode} |
| 149 |
% \end{macro} |
| 150 |
% |
| 151 |
% \begin{macro}{\@enQmark} |
| 152 |
% This just expands to a `?'. |\ref| will produce this, if no counter |
| 153 |
% is printed. |
| 154 |
% \begin{macrocode} |
| 155 |
\def\@enQmark{?} |
| 156 |
% \end{macrocode} |
| 157 |
% \end{macro} |
| 158 |
% |
| 159 |
% The next four macros build up the command that will print the item |
| 160 |
% label. They each gobble one token or group from the optional argument, |
| 161 |
% and add corresponding tokens to the register |\@enLab|. They each end |
| 162 |
% with a call to |\@enloop|, which starts the processing of the next |
| 163 |
% token. |
| 164 |
% \begin{macro}{\@enLabel} |
| 165 |
% Add the counter to the label. |#2| will be one of the `special' |
| 166 |
% tokens |A a I i 1|, and is thrown away. |#1| will be a command |
| 167 |
% like |\Roman|. |
| 168 |
% \begin{macrocode} |
| 169 |
\def\@enLabel#1#2{% |
| 170 |
\edef\@enThe{\noexpand#1{\@enumctr}}% |
| 171 |
\@enLab\expandafter{\the\@enLab\csname the\@enumctr\endcsname}% |
| 172 |
\@enloop} |
| 173 |
% \end{macrocode} |
| 174 |
% \end{macro} |
| 175 |
% |
| 176 |
% \begin{macro}{\@enSpace} |
| 177 |
% \begin{macro}{\@enSp@ce} |
| 178 |
% Add a space to the label. The tricky bit is to gobble the space token, |
| 179 |
% as you can not do this with a macro argument. |
| 180 |
% \begin{macrocode} |
| 181 |
\def\@enSpace{\afterassignment\@enSp@ce\let\@tempa= } |
| 182 |
\def\@enSp@ce{\@enLab\expandafter{\the\@enLab\space}\@enloop} |
| 183 |
% \end{macrocode} |
| 184 |
% \end{macro} |
| 185 |
% \end{macro} |
| 186 |
% |
| 187 |
% \begin{macro}{\@enGroup} |
| 188 |
% Add a |{ }| group to the label. |
| 189 |
% \begin{macrocode} |
| 190 |
\def\@enGroup#1{\@enLab\expandafter{\the\@enLab{#1}}\@enloop} |
| 191 |
% \end{macrocode} |
| 192 |
% \end{macro} |
| 193 |
% |
| 194 |
% \begin{macro}{\@enOther} |
| 195 |
% Add anything else to the label |
| 196 |
% \begin{macrocode} |
| 197 |
\def\@enOther#1{\@enLab\expandafter{\the\@enLab#1}\@enloop} |
| 198 |
% \end{macrocode} |
| 199 |
% \end{macro} |
| 200 |
% |
| 201 |
% \begin{macro}{\@enloop} |
| 202 |
% \begin{macro}{\@enloop@} |
| 203 |
% The body of the main loop. |
| 204 |
% Eating tokens this way instead of using |\@tfor| lets you see |
| 205 |
% spaces and {\bf all} braces. |\@tfor| would treat {\tt a} and |
| 206 |
% |{a}| as special, but not |{{a}}|. |
| 207 |
% \begin{macrocode} |
| 208 |
\def\@enloop{\futurelet\@entemp\@enloop@} |
| 209 |
% \end{macrocode} |
| 210 |
% \begin{macrocode} |
| 211 |
\def\@enloop@{% |
| 212 |
\ifx A\@entemp \def\@tempa{\@enLabel\Alph }\else |
| 213 |
\ifx a\@entemp \def\@tempa{\@enLabel\alph }\else |
| 214 |
\ifx i\@entemp \def\@tempa{\@enLabel\roman }\else |
| 215 |
\ifx I\@entemp \def\@tempa{\@enLabel\Roman }\else |
| 216 |
\ifx 1\@entemp \def\@tempa{\@enLabel\arabic}\else |
| 217 |
\ifx \@sptoken\@entemp \let\@tempa\@enSpace \else |
| 218 |
\ifx \bgroup\@entemp \let\@tempa\@enGroup \else |
| 219 |
\ifx \@enum@\@entemp \let\@tempa\@gobble \else |
| 220 |
\let\@tempa\@enOther |
| 221 |
% \end{macrocode} |
| 222 |
% Hook for possible extensions |
| 223 |
% \begin{macrocode} |
| 224 |
\@enhook |
| 225 |
% \end{macrocode} |
| 226 |
% |
| 227 |
% \begin{macrocode} |
| 228 |
\fi\fi\fi\fi\fi\fi\fi\fi |
| 229 |
% \end{macrocode} |
| 230 |
% \end{macro} |
| 231 |
% Process the current token, then look at the next. |
| 232 |
% \begin{macrocode} |
| 233 |
\@tempa} |
| 234 |
% \end{macrocode} |
| 235 |
% \end{macro} |
| 236 |
% |
| 237 |
% \begin{macro}{\@enhook} |
| 238 |
% Hook for possible extensions. |
| 239 |
% Some packages may want to extend the number of special characters |
| 240 |
% that are associated with counter representations. This feature |
| 241 |
% was requested to enable Russian alphabetic counting, but here |
| 242 |
% I give an example of a footnote symbol counter, triggered by |*|. |
| 243 |
% |
| 244 |
% To enable a new counter type based on a letter, you just need |
| 245 |
% to add a new |\ifx| clause by analogy with the code above. |
| 246 |
% So for example to make |*| trigger footnote symbol counting, |
| 247 |
% a package should do the following. |
| 248 |
% |
| 249 |
% Initialise the hook, in case the package is loaded before |
| 250 |
% \textsf{enumerate}. |
| 251 |
%\begin{verbatim} |
| 252 |
% \providecommand\@enhook{} |
| 253 |
%\end{verbatim} |
| 254 |
% |
| 255 |
% Add to the hook a new |\ifx| clause that associates |*| with the |
| 256 |
% |\fnsymbol| counter command. |
| 257 |
%\begin{verbatim} |
| 258 |
% \g@addto@macro\@enhook{% |
| 259 |
% \ifx *\@entemp |
| 260 |
% \def\@tempa{\@enLabel\fnsymbol}% |
| 261 |
% \fi} |
| 262 |
%\end{verbatim} |
| 263 |
% This code sequence should work whether it is loaded before or after |
| 264 |
% this enumerate package. Any number of new counter types may be added |
| 265 |
% in this way. |
| 266 |
% |
| 267 |
% At this point we just need initialise the hook, taking care not |
| 268 |
% to overwrite any definitions another package may already have added. |
| 269 |
% \begin{macrocode} |
| 270 |
\providecommand\@enhook{} |
| 271 |
% \end{macrocode} |
| 272 |
% \end{macro} |
| 273 |
% |
| 274 |
% \begin{macro}{\enumerate} |
| 275 |
% The new {\tt enumerate} environment. This is the first half of the |
| 276 |
% original enumerate environment. If there is an optional argument, call |
| 277 |
% |\@@enum@| to define the label commands, otherwise call |
| 278 |
% |\@enum@| which is the second half of the original definition. |
| 279 |
% \begin{macrocode} |
| 280 |
\def\enumerate{% |
| 281 |
\ifnum \@enumdepth >3 \@toodeep\else |
| 282 |
\advance\@enumdepth \@ne |
| 283 |
\edef\@enumctr{enum\romannumeral\the\@enumdepth}\fi |
| 284 |
\@ifnextchar[{\@@enum@}{\@enum@}} |
| 285 |
% \end{macrocode} |
| 286 |
% \end{macro} |
| 287 |
% |
| 288 |
% \begin{macro}{\@@enum@} |
| 289 |
% Handle the optional argument. |
| 290 |
% \begin{macrocode} |
| 291 |
\def\@@enum@[#1]{% |
| 292 |
% \end{macrocode} |
| 293 |
% Initialise the loop which will break apart the optional argument. |
| 294 |
% The command to print the label is built up in |\@enlab|. |
| 295 |
% |\@enThe| will be used to define |\theenum|\,$n$. |
| 296 |
% \begin{macrocode} |
| 297 |
\@enLab{}\let\@enThe\@enQmark |
| 298 |
% \end{macrocode} |
| 299 |
% The |\@enum@| below is never expanded, it is used to detect the end |
| 300 |
% of the token list. |
| 301 |
% \begin{macrocode} |
| 302 |
\@enloop#1\@enum@ |
| 303 |
% \end{macrocode} |
| 304 |
% Issue a warning if we did not find one of the `special' tokens. |
| 305 |
% \begin{macrocode} |
| 306 |
\ifx\@enThe\@enQmark\@warning{The counter will not be printed.% |
| 307 |
^^J\space\@spaces\@spaces\@spaces The label is: \the\@enLab}\fi |
| 308 |
% \end{macrocode} |
| 309 |
% Define |\labelenum|$\,n$ and |\theenum|$\,n$. |
| 310 |
% \begin{macrocode} |
| 311 |
\expandafter\edef\csname label\@enumctr\endcsname{\the\@enLab}% |
| 312 |
\expandafter\let\csname the\@enumctr\endcsname\@enThe |
| 313 |
% \end{macrocode} |
| 314 |
% Set the counter to 7 so that we get the width of `vii' if roman |
| 315 |
% numbering is in force then set |\leftmargin|$\,n$. to the width of the |
| 316 |
% label plus |\labelsep|. |
| 317 |
% \begin{macrocode} |
| 318 |
\csname c@\@enumctr\endcsname7 |
| 319 |
\expandafter\settowidth |
| 320 |
\csname leftmargin\romannumeral\@enumdepth\endcsname |
| 321 |
{\the\@enLab\hspace{\labelsep}}% |
| 322 |
% \end{macrocode} |
| 323 |
% Finally call |\@enum@| which is the second half of the original |
| 324 |
% definition. |
| 325 |
% \begin{macrocode} |
| 326 |
\@enum@} |
| 327 |
% \end{macrocode} |
| 328 |
% \end{macro} |
| 329 |
% |
| 330 |
% \begin{macro}{\@enum@} |
| 331 |
% All the list parameters have now been defined, so call |\list|. This |
| 332 |
% is taken straight from the original definition of |\enumerate|. |
| 333 |
% \begin{macrocode} |
| 334 |
\def\@enum@{\list{\csname label\@enumctr\endcsname}% |
| 335 |
{\usecounter{\@enumctr}\def\makelabel##1{\hss\llap{##1}}}} |
| 336 |
% \end{macrocode} |
| 337 |
% \end{macro} |
| 338 |
% |
| 339 |
% \begin{macrocode} |
| 340 |
%</package> |
| 341 |
% \end{macrocode} |
| 342 |
% |
| 343 |
% \Finale |
| 344 |
% |
| 345 |
\endinput |