% \iffalse meta-comment % % Copyright 1994 the LaTeX3 project and the individual authors. % All rights reserved. For further copyright information see the file % legal.txt, and any other copyright indicated in this file. % % This file is part of the LaTeX2e system. % ---------------------------------------- % % This system is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. % % % IMPORTANT NOTICE: % % For error reports in case of UNCHANGED versions see bugs.txt. % % Please do not request updates from us directly. Distribution is % done through Mail-Servers and TeX organizations. % % You are not allowed to change this file. % % You are allowed to distribute this file under the condition that % it is distributed together with all files mentioned in manifest.txt. % % If you receive only some of these files from someone, complain! % % You are NOT ALLOWED to distribute this file alone. You are NOT % ALLOWED to take money for the distribution or use of either this % file or a changed version, except for a nominal charge for copying % etc. % \fi % % \iffalse %<*driver> % \fi \ProvidesFile{ltlists.dtx} [1994/05/21 v1.0e LaTeX Kernel (List Environments)] % \iffalse \documentclass{ltxdoc} \GetFileInfo{ltlists.dtx} \title{\filename} \date{\filedate} \author{% Johannes Braams\and David Carlisle\and Alan Jeffrey\and Leslie Lamport\and Frank Mittelbach\and Chris Rowley\and Rainer Sch\"opf} \begin{document} \maketitle \DocInput{\filename} \end{document} % % \fi % % \CheckSum{418} % % \changes{v1.0b}{1994/03/28}{Improve documentation} % \changes{v1.0e}{1994/05/21}{Use new error commands} % % \section{List, and related environments} % % The generic commands for creating an indented environment -- % enumerate, itemize, quote, etc -- are: % % |\list|\marg{LABEL}\marg{COMMANDS} ... |\endlist| % % which can be invoked by the user as the list environment. The LABEL % argument specifies item labeling. COMMANDS contains commands for % changing the horizontal and vertical spacing parameters. % % Each item of the environment is begun by the command % |\item[|ITEMLABEL|]| % which produces an item labeled by ITEMLABEL. If the argument is % missing, then the LABEL argument of the |\list| command is used as the % item label. % % The label is formed by putting |\makelabel|\marg{ITEMLABEL} in an hbox % whose width is either its natural width or else |\labelwidth|, % whichever is larger. The |\list| command defines |\makelabel| to have % the default definition: % % |\makelabel|\marg{ARG} == BEGIN |\hfil| ARG END % % which, for a label of width less than |\labelwidth|, puts the label % flushright, |\labelsep| to the left of the item's text. However, % |\makelabel| can be |\let| to another command by the |\list|'s % COMMANDS argument. % % A |\usecounter|\marg{foo} command in the second argument causes the % counter \emph{foo} to be initialized to zero, and stepped by every % |\item| command without an argument. (|\label| commands within the % list refer to this counter.) % % When you leave a list environment, returning either to an enclosing % list or normal text mode, LaTeX begins a new paragraph if and only if % you leave a blank line after the |\end| command. This is accomplished % by the |\@endparenv| command. % % Blank lines are ignored every other reasonable place--i.e.: % \begin{itemize} % \item Between the |\begin{list}| and the first |\item|, % \item Between the |\item| and the text of that item. % \item Between the end of the last item and the |\end{list}|. % \end{itemize} % % For an environment like quotation, in which items are not labeled, % the entire environment is a single item. It is defined by % letting |\quotation| == |\list{}{...}\item\relax|. (Note the % |\relax|, there in case the first character in the environment is a % '['.) The spacing parameters provide a great deal of flexability in % designing the format, including the ability to let the indentation of % the first paragraph be different from that of the subsequent ones. % % The trivlist environment is equivalent to a list environment % whose second argument sets the following parameter values:\\ % |\leftmargin| = 0 : causes no indentation of left margin\\ % |\labelwidth| = 0 : see below for precise effect this has.\\ % |\itemindent| = 0 : with a null label, makes first paragraph % have no indentation. Succeeding paragraphs have |\parindent| % indentation. To give first paragraph same indentation, set % |\itemindent| = |\parindent| before the |\item[]|. % % Every |\item| in a trivlist environment must have an argument---in % many cases, this will be the null argument (|\item[]|). The trivlist % environment is mainly used for paragraphing environments, like % verbatim, in which there is no margin change. It provides the same % vertical spacing as the list environment, and works reasonably well % when it occurs immediately after an |\item| command in an enclosing % list. % % \StopEventually{} % % % \changes{v1.0a}{1994/03/04}{Initial version, split from latex.dtx} % \changes{v1.0a}{1994/03/07}{Long lines wrapped to 72 columns} % % % \subsection{list and trivlist} % % \begin{oldcomments} % % The following variables are used inside a list environment: % \@totalleftmargin : The distance that the prevailing left margin is % indented from the outermost left margin, % \linewidth : The width of the current line. Must be % initialized to \hsize. % \@listdepth : A count for holding current list nesting depth. % \makelabel : A macro with a single argument, used to generate % the label from the argument (given or implied) % of the \item command. % Initialized to \@mklab by the \list command. % This command must produce some stretch % --i.e., an \hfil. % @inlabel : A switch that is false except between the time % an \item is encountered and the time that TeX % actually enters horizontal mode. Should be % tested by commands that can be messed up by % the list environment's use of \everypar. % \box\@labels : When @inlabel = true, it holds the labels % to be put out by \everypar. % @noparitem : A switch set by \list when @inlabel = true. % Handles the case of a \list being the first % thing in an item. % @noparlist : A switch set true for a list that begins an % item. No \topsep space is added before or after % \item's such a list. % @newlist : Set true by \list, set false by the first % text (by \everypar). % @noitemarg : Set true when executing an \item with no % explicit argument. Used to save space. % To save time, make two separate % \@item commands. % @nmbrlist : Set true by \usecounter command, causes list to % be numbered. % \@listctr : \def'ed by \usecounter to name of counter. % @noskipsec : A switch set true by a sectioning command when % it is creating an in-text heading with \everypar. % % Throughout a list environment, \hsize is the width of the current % line, measured from the outermost left margin to the outermost right % margin. Environments like tabbing should use \linewidth instead of % \hsize. % % Here are the parameters of a list that can be set by commands in % the \list's COMMANDS argument. These parameters are all TeX % skips or dimensions (defined by \newskip or \newdimen), so the usual % TeX or LaTeX commands can be used to set them. The commands will % be executed in vmode if and only if the \list was preceded by a % \par (or something like an \end{list}), so the spacing parameters % can be set according to whether the list is inside a paragraph % or is its own paragraph. % % VERTICAL SPACING (skips): % % \topsep : Space between first item and preceding paragraph. % \partopsep : Extra space added to \topsep when environment % starts a new paragraph (is called in vmode). % \itemsep : Space between successive items. % \parsep : Space between paragraphs within an item -- the % \parskip for this environment. % % PENALTIES % \@beginparpenalty : put at the beginning of a list % \@endparpenalty : put at end of list % \@itempenalty : put between items. % % HORIZONTAL SPACING (dimens) % \leftmargin : space between left margin of enclosing environment % (or of page if top level list) and left margin of % this list. Must be nonnegative. % \rightmargin : analogous. % \listparindent: extra indentation at beginning of every paragraph % of a list except the one started by the \item % command. May be negative! Usually, labeled % lists have \listparindent equal to zero. % \itemindent : extra indentation added right BEFORE an item % label. % \labelwidth : nominal width of box that contains the label. % If the natural width of the % label < = \labelwidth, % then the label is flushed right inside a box % of width \labelwidth (with an \hfil). Otherwise, % a box of the natural width is employed, which % causes an indentation of the text on that line. % \labelsep : space between end of label box and text of % first item. % % DEFAULT VALUES: % Defaults for the list environment are set as follows. % First, \rightmargin, \listparindent and \itemindent are set % to 0pt. Then, one of the commands % \@listi, \@listii, ... , \@listvi % is called, depending upon the current level of the list. % The \@list... commands should be defined by the document % style. A convention that the document style should follow is % to set \leftmargin to \leftmargini, ... , \leftmarginvi for % the appropriate level. Items that aren't changed may be left % alone, but everything that could possibly be changed must be % reset. % % \list{LABEL}{COMMANDS} == % BEGIN % if \@listdepth > 5 % then LaTeX error: 'Too deeply nested' % else \@listdepth :=G \@listdepth + 1 % fi % \rightmargin := 0pt % \listparindent := 0pt % \itemindent := 0pt % \eval(@list \romannumeral\the\@listdepth) %% Set default values: % \@itemlabel :=L LABEL % \makelabel == \@mklab % @nmbrlist :=L false % COMMANDS % % \@trivlist % commands common to \list and \trivlist % % \parskip :=L \parsep % \parindent :=L \listparindent % \linewidth :=L \linewidth - \rightmargin -\leftmargin % \@totalleftmargin :=L \@totalleftmargin + \leftmargin % \parshape 1 \@totalleftmargin \linewidth % \ignorespaces % gobble space up to \item % END % % \endlist == BEGIN \@listdepth :=G \@listdepth -1 % \endtrivlist % END % % \@trivlist == % BEGIN % if @newlist = T then \@noitemerr fi % %% This command removed for some forgotten reason. % \@topsepadd :=L \topsep % if @noskipsec then leave vertical mode fi %% Added 11 Jun 85 % if vertical mode % then \@topsepadd :=L \@topsepadd + \partopsep % else \unskip \par % remove glue from end of last line % fi % if @inlabel = true % then @noparitem :=L true % @noparlist :=L true % else @noparlist :=L false % \@topsep :=L \@topsepadd % fi % \@topsep :=L \@topsep + \parskip %% Change 4 Sep 85 % \leftskip :=L 0pt % Restore paragraphing parameters % \rightskip :=L \@rightskip % \parfillskip :=L 0pt + 1fil % % NOTE: \@setpar called on every \list in case \par has been % temporarily munged before the \list command. % \@setpar{if @newlist = false then {\@@par} fi} % \@newlist :=G T % \@outerparskip :=L \parskip % END % % \trivlist == % BEGIN % \parsep := \parskip % @nmbrlist := F % \@trivlist % \labelwidth := 0 % \leftmargin := 0 % \itemindent := \parindent % \@itemlabel :=L "empty" %% added 93/12/13 % \makelabel{LABEL} == LABEL % END % % \endtrivlist == % BEGIN % if @inlabel = T then \indent fi % if horizontal mode then \unskip \par fi % if @noparlist = true % else if \lastskip > 0 % then \@tempskipa := \lastskip % \vskip - \lastskip % \vskip \@tempskipa -\@outerparskip + \parskip % fi % \@endparenv % fi % END % % \@endparenv == % BEGIN % \addpenalty{@endparpenalty} % \addvspace{\@topsepadd} % \endgroup %% ends the \begin command's \begingroup % \par == BEGIN % \@restorepar % \everypar{} % \par % END % \everypar == BEGIN remove \lastbox \everypar{} END % \begingroup %% to match the \end commands \endgroup % END % % \item == BEGIN if math mode then WARNING fi % if next char = [ % then \@item % else @noitemarg := true % \@item[@itemlabel] % END % % \@item[LAB] == % BEGIN % if @noparitem = true % then @noparitem := false % % NOTE: then clause hardly every taken, % % so made a macro \@donoparitem % \box\@labels :=G \hbox{\hskip -\leftmargin % \box\@labels % \hskip \leftmargin } % if @minipage = false then % \@tempskipa := \lastskip % \vskip -\lastskip % \vskip \@tempskipa + \@outerparskip - \parskip % fi % else if @inlabel = true % then \indent \par % previous item empty. % fi % if hmode then 2 \unskip's % % To remove any space at end of prev. % % paragraph that could cause a blank line. % \par % fi % if @newlist = T % then if @nobreak = T % Kludge if list follows \section % then \addvspace{\@outerparskip - \parskip} % else \addpenalty{\@beginparpenalty} % \addvspace{\@topsep} % \addvspace{-\parskip} %% added 4 Sep 85 % fi % else \addpenalty{\@itempenalty} % \addvspace{\itemsep} % fi % @inlabel :=G true % fi % % \everypar{ @minipage :=G F % @newlist :=G F % if @inlabel = true % then @inlabel :=G false % \hskip -\parindent % \box\@labels % \penalty 0 % %% 3 Oct 85 -- allow line break here % \box\@labels :=G null % fi % \everypar{} } % @nobreak :=G false % if @noitemarg = true % then @noitemarg := false % if @nmbrlist % then \refstepcounter{\@listctr} % fi fi % \@tempboxa :=L \hbox{\makelabel{LAB}} % \box\@labels :=G \@labels \hskip \itemindent % \hskip - (\labelwidth + \labelsep) % if \wd \@tempboxa > \labelwidth % then \box\@tempboxa % else \hbox to \labelwidth {\unhbox\@tempboxa} % fi % \hskip\labelsep % \ignorespaces %gobble space up to text % END % % \makelabel{LABEL} == ERROR %% default to catch lonely \item % % % \usecounter{CTR} == BEGIN @nmbrlist :=L true % \@listctr == CTR % \setcounter{CTR}{0} % END % % DEFINE \dimen's and \count % \begin{macrocode} %<*2ekernel> \newskip\topsep \newskip\partopsep \newskip\itemsep \newskip\parsep \newskip\@topsep \newskip\@topsepadd \newskip\@outerparskip % \end{macrocode} % % \begin{macrocode} \newdimen\leftmargin \newdimen\rightmargin \newdimen\listparindent \newdimen\itemindent \newdimen\labelwidth \newdimen\labelsep \newdimen\linewidth \newdimen\@totalleftmargin \@totalleftmargin=\z@ \newdimen\leftmargini \newdimen\leftmarginii \newdimen\leftmarginiii \newdimen\leftmarginiv \newdimen\leftmarginv \newdimen\leftmarginvi % \end{macrocode} % % \begin{macrocode} \newcount\@listdepth \@listdepth=0 \newcount\@itempenalty \newcount\@beginparpenalty \newcount\@endparpenalty % \end{macrocode} % % \begin{macrocode} \newbox\@labels % \end{macrocode} % % \begin{macrocode} \newif\if@inlabel \@inlabelfalse \newif\if@newlist \@newlistfalse \newif\if@noparitem \@noparitemfalse \newif\if@noparlist \@noparlistfalse \newif\if@noitemarg \@noitemargfalse \newif\if@nmbrlist \@nmbrlistfalse % \end{macrocode} % % \begin{macrocode} \def\list#1#2{\ifnum \@listdepth >5\relax \@toodeep \else \global\advance\@listdepth\@ne \fi \rightmargin \z@ \listparindent\z@ \itemindent\z@ \csname @list\romannumeral\the\@listdepth\endcsname \def\@itemlabel{#1}\let\makelabel\@mklab \@nmbrlistfalse #2\relax \@trivlist \parskip\parsep \parindent\listparindent \advance\linewidth -\rightmargin \advance\linewidth -\leftmargin \advance\@totalleftmargin \leftmargin \parshape \@ne \@totalleftmargin \linewidth \ignorespaces} % \end{macrocode} % % RmS 92/12/02: Added check for loop within item by counting the % number of times a paragraph is started. % This catches the infinite loop caused by omitting % \item. % \begin{macrocode} \newcount\par@deathcycles \def\@trivlist{\@topsepadd\topsep \if@noskipsec \leavevmode \fi \ifvmode \advance\@topsepadd\partopsep \else \unskip\par\fi \if@inlabel \@noparitemtrue \@noparlisttrue \else \@noparlistfalse \@topsep\@topsepadd \fi \advance\@topsep \parskip \leftskip\z@skip\rightskip\@rightskip \parfillskip\@flushglue \par@deathcycles\z@ \@setpar{\if@newlist \advance\par@deathcycles\@ne \ifnum\par@deathcycles>\@m \@noitemerr{\@@par}\fi \else{\@@par}\fi}% \global\@newlisttrue \@outerparskip\parskip} % \end{macrocode} % % RmS 92/03/18 added \@nmbrlistfalse % \begin{macrocode} \def\trivlist{\parsep\parskip\@nmbrlistfalse \@trivlist \labelwidth\z@ \leftmargin\z@ \itemindent\z@ % \end{macrocode} % \end{oldcomments} % We initialise |\@itemlabel| so that a \texttt{trivlist} with % an |\item| not having an optional argument doesn't produce an % error message. % \changes{latex2e}{1993/12/13}{Initialised `@itemlabel} % \begin{macrocode} \let\@itemlabel\@empty \def\makelabel##1{##1}} % \end{macrocode} % % \begin{macrocode} \def\endlist{\global\advance\@listdepth\m@ne \endtrivlist} % \end{macrocode} % % Definition of |\endtrivlist| moved earlier in file so other commands % can be |\let| = to it. % \begin{macrocode} \def\@mklab#1{\hfil #1} % \end{macrocode} % % \changes{LaTeX2.09}{1992/09/18} % {(RmS) Added warning if \cs{item} is used in math mode} % \changes{v1.0c}{1994/04/28} % {Replaced \cmd\@ltxnomath by \cmd\@inmatherr} % \changes{v1.0d}{1994/05/03} % {Removed superfluous braces} % \begin{macrocode} \def\item{\@inmatherr\item \@ifnextchar [\@item{\@noitemargtrue \@item[\@itemlabel]}} % \end{macrocode} % % \begin{macrocode} \def\@donoparitem{\@noparitemfalse \global\setbox\@labels\hbox{\hskip -\leftmargin \unhbox\@labels \hskip \leftmargin}\if@minipage\else \@tempskipa\lastskip \vskip -\lastskip \advance\@tempskipa\@outerparskip \advance\@tempskipa -\parskip \vskip\@tempskipa\fi} % \end{macrocode} % % \begin{macro}{\@item} % \begin{macrocode} \def\@item[#1]{\if@noparitem \@donoparitem \else \if@inlabel \indent \par \fi \ifhmode \unskip\unskip \par \fi \if@newlist \if@nobreak \@nbitem \else \addpenalty\@beginparpenalty \addvspace\@topsep \addvspace{-\parskip}\fi \else \addpenalty\@itempenalty \addvspace\itemsep \fi \global\@inlabeltrue \fi \everypar{\global\@minipagefalse\global\@newlistfalse \if@inlabel \global\@inlabelfalse % \end{macrocode} % This next command was changed from an hskip to a kern to avoid % a break point after the parindent box: the skip can cause a % line-break if a very long label occurs in raggedright setting. % \changes{v1.0d}{1994/05/03}{\cmd\hskip changed to \cmd\kern} % \begin{macrocode} % \hskip -\parindent \kern -\parindent \box\@labels \penalty\z@ \fi \everypar{}}% \global\@nobreakfalse \if@noitemarg \@noitemargfalse \if@nmbrlist \refstepcounter{\@listctr}\fi \fi % \end{macrocode} % We use |\sbox| to support colour commands. % \changes{LaTeX2e}{1993/12/08}{use \cmd\sbox to support colour} % \begin{macrocode} \sbox\@tempboxa{\makelabel{#1}}% \global\setbox\@labels \hbox{\unhbox\@labels \hskip \itemindent \hskip -\labelwidth \hskip -\labelsep \ifdim \wd\@tempboxa >\labelwidth \box\@tempboxa % \end{macrocode} % \changes{LaTeX2.09}{1991/11/22} % {(RmS) Changed second call to \cmd\makelabel to % \cmd\unhbox\cmd{\@tempboxa}. % Avoids problems with side effects in \cmd\makelabel and is % more efficient.} % \begin{macrocode} \else \hbox to\labelwidth {\unhbox\@tempboxa}\fi \hskip \labelsep}\ignorespaces} % \end{macrocode} % \end{macro} % % \begin{macro}{\makelabel} % \changes{LaTeX2.09}{1991/11/04} % {(RmS) added default definition for \cmd\makelabel, % to produce an error message.} % \begin{macrocode} \def\makelabel#1{\@latex@error{Lonely \string\item--perhaps a missing list environment}\@ehc} % \end{macrocode} % \end{macro} % % \begin{macrocode} \def\@nbitem{\@tempskipa\@outerparskip \advance\@tempskipa -\parskip \addvspace{\@tempskipa}} % \end{macrocode} % % \begin{macrocode} \def\usecounter#1{\@nmbrlisttrue\def\@listctr{#1}\setcounter{#1}\z@} % \end{macrocode} % % \begin{macrocode} % \message{itemize,} % \end{macrocode} % % \subsection{Itemize and Enumerate} % % \begin{oldcomments} % % Enumeration is done with four counters: enumi, enumii, enumiii % and enumiv, where enumN controls the numbering of the Nth level % enumeration. The label is generated by the commands % \labelenumi ... \labelenumiv, which should be defined by the % document style. Note that \p@enumN\theenumN defines the output % of a \ref command. A typical definition might be: % \def\theenumii{\alph{enumii}} % \def\p@enumii{\theenumi} % \def\labelenumii{(\theenumii)} % which will print the labels as '(a)', '(b)', ... and print a \ref as % '3a'. % % The item numbers are moved to the right of the label box, so they are % always a distance of \labelsep from the item. % % \@enumdepth holds the current enumeration nesting depth. % % Itemization is controlled by four commands: \labelitemi, \labelitemii, % \labelitemiii, and \labelitemiv. To cause the second-level list to be % bulleted, you just define \labelitemii to be $\bullet$. \@itemspacing % and \@itemdepth are the analogs of \@enumspacing and \@enumdepth. % % \enumerate == % BEGIN % if \@enumdepth > 3 % then errormessage: ``Too deeply nested''. % else \@enumdepth :=L \@enumdepth + 1 % \@enumctr :=L eval(enum@\romannumeral\the\@enumdepth) % \list{\label(\@enumctr)} % {\usecounter{\@enumctr} % \makelabel{LABEL} == \hss \llap{LABEL}} % fi % END % % \endenumerate == \endlist % % \begin{macrocode} \newcount\@enumdepth \@enumdepth = 0 % \end{macrocode} % % \begin{macrocode} \@definecounter{enumi} \@definecounter{enumii} \@definecounter{enumiii} \@definecounter{enumiv} % \end{macrocode} % % \begin{macrocode} \def\enumerate{\ifnum \@enumdepth >3 \@toodeep\else \advance\@enumdepth \@ne \edef\@enumctr{enum\romannumeral\the\@enumdepth}\list {\csname label\@enumctr\endcsname}{\usecounter {\@enumctr}\def\makelabel##1{\hss\llap{##1}}}\fi} % \end{macrocode} % % \begin{macrocode} \let\endenumerate =\endlist % \end{macrocode} % % % \itemize == % BEGIN % if \@itemdepth > 3 % then errormessage: 'Too deeply nested'. % else \@itemdepth :=L \@itemdepth + 1 % \@itemitem == eval(labelitem\romannumeral\the\@itemdepth) % \list{\@nameuse{\@itemitem}} % {\makelabel{LABEL} == \hss \llap{LABEL}} % fi % END % % \enditemize == \endlist % % \begin{macrocode} \newcount\@itemdepth \@itemdepth = 0 % \end{macrocode} % % \begin{macrocode} \def\itemize{% \ifnum \@itemdepth >3 \@toodeep\else \advance\@itemdepth \@ne \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}% \list{\csname\@itemitem\endcsname}% {\def\makelabel##1{\hss\llap{##1}}}\fi} % \end{macrocode} % % \begin{macrocode} \let\enditemize =\endlist % % \end{macrocode} % \end{oldcomments} % % \Finale %