From 0a04967062b7de7c64f902743994a3edd7caac9f Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 26 Jul 2011 23:26:46 +0000 Subject: enumitem 3.3 (14jul11) git-svn-id: svn://tug.org/texlive/trunk@23242 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/enumitem/README | 72 +- Master/texmf-dist/doc/latex/enumitem/enumitem.pdf | Bin 166851 -> 325585 bytes Master/texmf-dist/doc/latex/enumitem/enumitem.tex | 1228 +++++++++----- Master/texmf-dist/tex/latex/enumitem/enumitem.sty | 1772 +++++++++++++++------ 4 files changed, 2203 insertions(+), 869 deletions(-) (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/enumitem/README b/Master/texmf-dist/doc/latex/enumitem/README index ccbadeaf525..d4e7156aac5 100644 --- a/Master/texmf-dist/doc/latex/enumitem/README +++ b/Master/texmf-dist/doc/latex/enumitem/README @@ -1,5 +1,5 @@ -Enumitem -~~~~~~~~ +Enumitem 3.3 +~~~~~~~~~~~~ A package to customize the three basic lists (enumerate, itemize and description) by means of a set of parameters, @@ -11,25 +11,75 @@ design your own lists: - changes applied globally or only in one of the three types or even in a single list (including topsep) by means of a sort of "inheritance", +- inline lists, - several description styles (which fix some bad spacing, too), - starting value and counter resuming, - trivlists properly formatted, -- control on page breaking +- control on page breaking, +- gathering of lists to be treated like a unit. -Recent changes -~~~~~~~~~~~~~~ -2.1 fixes a bug in resume* -- now it ignores the start key given -in the previous list, since we want to continue it, not to restart -it. +Recent changes (3.0) +~~~~~~~~~~~~~~~~~~~~ + +1) Inline lists, with keys to set how items are joined (ie, the +punctuation between items). Two modes are provided: `boxed' an +`unboxed' -- with the former (the default) a different punctuation +before the last item is allowed. +2) \setlist is calc-savvy (eg, for use in loops), and you can set +diferent lists and levels at once. +3) All lengths related to labels can take the value * (and not only +labelsep and leftmargin). Its behaviour has been made consistent and +there is new value ! which does not compute the widest label. +4) With \restartlist{list-name}, list counters can be restarted (in +case you are using `resume'). +5) `resume*' can be combined with other keys. +6) Lists can be gathered globally using series, so that they are +considered a single list. To start a series just use +series= and then resume it with resume= or +resume*=. +7) The ``experimental'' fullwidth has been replaced by a new key +`wide'. +8) \SetLabelAlign defines new align values. +9) You can define ``abstract'' values (eg, label=numeric) and +new keys. + +Bug fixes (3.0) +~~~~~~~~~~~~~~~ + +- Star values (eg, leftmargin=*) could not be overriden +and new values were ignored. +- nolistsep as the first of several keys was not always +recognized and therefore treated like a short label +(ie, nol\roman*stsep). +- labelwidth didn't always work (when there was a prior +`widest' and *) +- With align=right the label and the following text could +overlap. +- description didn't get the correct list level. +- At some point (2.x?) \value* stopped working. + +3.1 +~~~ +- Fixed incompatibility with xkeyval + +3.2 +~~~ +- start and widest* are calc-savvy. +- \value can be used with widest* +- Some internal restrictions in \arabic and the like has been removed. +It is more flexible at the cost of having a more ``relaxed'' error +checking. + +3.3 +~~~ +- Using *-values with itemize and description didn't work. -2.2 fixes a bug in some description styles, which didn't empty the -box containing the labels. _________________________________________________________________ Javier Bezos | http://www.tex-tipografia.com ................................................................. -2009-05-18 +2011-07-14 diff --git a/Master/texmf-dist/doc/latex/enumitem/enumitem.pdf b/Master/texmf-dist/doc/latex/enumitem/enumitem.pdf index f0705b8220f..f137f551d37 100644 Binary files a/Master/texmf-dist/doc/latex/enumitem/enumitem.pdf and b/Master/texmf-dist/doc/latex/enumitem/enumitem.pdf differ diff --git a/Master/texmf-dist/doc/latex/enumitem/enumitem.tex b/Master/texmf-dist/doc/latex/enumitem/enumitem.tex index ee15d9ff848..70e51ffaaef 100644 --- a/Master/texmf-dist/doc/latex/enumitem/enumitem.tex +++ b/Master/texmf-dist/doc/latex/enumitem/enumitem.tex @@ -2,10 +2,10 @@ % | Typeset this file to document enumitem.sty | % +--------------------------------------------------+ % -% Copyright (c) 2003-2009 by Javier Bezos. +% Copyright (c) 2003-2011 by Javier Bezos. % All Rights Reserved. % -% This file is part of the enumitem distribution release 2.2 +% This file is part of the enumitem distribution release 3.2 % ----------------------------------------------------------- % % It may be distributed and/or modified under the @@ -20,7 +20,19 @@ % % The Current Maintainer of this work is Javier Bezos. -\documentclass{article} +\documentclass[a4paper]{ltxguide} + +\makeatletter +\newenvironment{desc} + {\if@nobreak + \vskip-\lastskip + \vspace*{-2.5ex}% + \fi + \decl} + {\enddecl} +\makeatother + +\newcommand\3{\unskip\enspace\fbox{\fontsize{4}{4}\selectfont NEW 3.0}} \usepackage{hyperref} @@ -36,7 +48,7 @@ find mistakes in the manual. Other packages by the same author: \textsf{gloss} (with Jos\'e Luis D\'{\i}az), \textsf{accents, tensind, esindex, dotlessi, titlesec, titletoc}.}} -\date{Version 2.2\\2009-05-18} +\date{Version 3.3\\2011-07-14} \IfFileExists{enumitem.sty}{\usepackage{enumitem}}{} @@ -58,13 +70,11 @@ tensind, esindex, dotlessi, titlesec, titletoc}.}} When I began to use \LaTeX{} several year ago, two particular points annoyed me because I found customizing them was very complicated ---headlines/footlines and lists. A new way to redefine the former is -accomplished in my own \textit{titlesec} package, but none was -availiable to customize the latter except: +accomplished in my own \textsf{titlesec} package, but none was +available to customize the latter except: \begin{itemize} \item \textsf{enumerate}, which just allows to change the label and -it does it pretty well (or almost, as in Spanish a standard label is -\textit{a}) which cannot be set with \verb|\emph{a})| and one must -write \verb|\itshape a\/\upshape)|). +it does it pretty well. \item \textsf{mdwlist}, which only ``provides some vaguely useful list-related commands and environments,'' as its manual states, @@ -73,11 +83,9 @@ and not a coherent way of handling lists. \item \textsf{paralist}, which provides lists within a paragraph (the original purpose of this package), a few other hard-wired specific changes and the optional argument of \textsf{enumerate}. -Note \textsf{enumitem} does not allow grouping items within -a paragraph yet. \end{itemize} -One of the main drawbacks of the standard \verb|list| is its weird +One of the main drawbacks of the standard |list| is its weird parameters, whose meaning is not always obvious. In order to provide a cleaner interface two approaches were possible: either defining new lists, or introducing a new syntax making the standard lists easier to @@ -93,53 +101,59 @@ parameters of, say, enumerate and then in turn override a few paremeters of a particular instance. The values will be searched in the hierarchy. -This is basically an advance of a project which I am working -on which will add this kind of inheritance to other structures -of \LaTeX{}. - \section{The package} This package is intended to ease customizing the three -basic list environments: \verb|enumerate|, \verb|itemize| and -\verb|description|. It extends their syntax to allow +basic list environments: |enumerate|, |itemize| and +|description|. It extends their syntax to allow an optional argument where a set of parameters in the -form \verb|key=value| are available: +form |key=value| are available: \begin{itemize} \item Vertical spacing: \begin{itemize} -\item \verb|topsep| -\item \verb|partopsep| -\item \verb|parsep| -\item \verb|itemsep| +\item |topsep| +\item |partopsep| +\item |parsep| +\item |itemsep| \end{itemize} \item Horizontal spacing: \begin{itemize} -\item \verb|leftmargin| -\item \verb|rightmargin| -\item \verb|listparindent| -\item \verb|labelwidth| -\item \verb|labelsep| -\item \verb|itemindent| +\item |leftmargin| +\item |rightmargin| +\item |listparindent| +\item |labelwidth| +\item |labelsep| +\item |itemindent| \end{itemize} \end{itemize} -These are equivalent to the well known list parameters, but -two of them, namely \verb|leftmargin| and \verb|labelsep|, -can have in addition the special value of \verb|*| as -described below. +For example: +\begin{verbatim} +\begin{itemize}[itemsep=1ex,leftmargin=1cm] +\end{verbatim} + +The keys above are equivalent to the well known list parameters---see a +\LaTeX{} manual for a description of them. Next sections explains the +extensions provided by |enumitem|. -The following new parameters are provided: -\begin{itemize} +\section{Keys} + +This section describes the keys in displayed lists. Most of them are +available in inline lists, where further keys are available (see +\ref{s.inline}). -\item \verb|font|. Sets the label font. Useful when the label is -changed with the optional argument of \verb|\item|. +\subsection{Label and cross references format} -\item \verb|label|. Sets the label to be used in the current level. -A set of starred versions of \verb|\alph|, \verb|\Alph|, -\verb|\arabic|, \verb|\roman| and \verb|\Roman|, without argument -stand for the current counter in \verb|enumerate|.\footnote{Actually, +\begin{desc} +|label=| +\end{desc} + +Sets the label to be used in the current level. +A set of starred versions of |\alph|, |\Alph|, +|\arabic|, |\roman| and |\Roman|, without argument +stand for the current counter in |enumerate|.\footnote{Actually, the asterisk is currently the argument but things may change. Consider them as starred variants and follow the corresponding syntax.} Thus @@ -147,33 +161,53 @@ syntax.} Thus \begin{enumerate}[label=\emph{\alph*})] \end{verbatim} prints \textit{a}), \textit{b}), and so on (this is a -standard style in Spanish). +standard style in Spanish, and formerly used by Chicago, too). -A fancier example (which looks ugly, but it is intended only -to illustrate what is possible; requires \textsf{color} and -\textsf{pifont}): +It works with |\value|, too (provided the widest label is not to be +computed or \verb|widest*| is used, see below). A fancier example +(which looks ugly, but it is intended only to illustrate what is +possible; requires \textsf{color} and \textsf{pifont}): \begin{verbatim} -\begin{enumerate}[label=\protect\fcolorbox{blue}{yellow}{\ding{\value*}}, +\begin{enumerate}[label=\protect\fcolorbox{blue}{yellow}{\protect\ding{\value*}}, start=172] \end{verbatim} -\item \verb|label*| is like \verb|label| but its value is appended to -the current label. For example, the follollowing defines a -\verb|legal| list (1., 1.1., 1.1.1., and so on): +The value of |label| is a moving argument, and fragile commands must +be protected \textit{except} the counters. Because of that, use of +\verb|\value| is somewhat tricky, because \verb|\the| or \verb|\ifnum| +expects an actual value, which is not the case when \verb|label| is +being processed to replace internally the \verb|*| by the form with +the counter argument. The best solution is usually encapsulating the +logic inside a new ``counter'' with the help of +\verb|\AddEnumerateCounter|.\footnote{Which is admittedly somewhat +convoluted. A better way to accomplish this is on the way.} + +If you prefer setting labels like the \textsf{enumerate} package, use +``short labels'' (see section \ref{s.short}). + +\begin{desc} +|label*=| +\end{desc} + +Like |label| but its value is appended to the parent label. For example, the follollowing defines a |legal| list (1., +1.1., 1.1.1., and so on): \begin{verbatim} \newlist{legal}{enumerate}{10} \setlist[legal]{label*=\arabic*.} \end{verbatim} +\begin{desc} +|ref=| +\end{desc} -\item \verb|ref|. By default, \verb|label| sets also the form of cross -references and \verb|\the...|, but you can define a -different format. For +By default, |label| sets also the form of cross references and +|\the...| (overriding the settings in previous hierarchical +levels), but you can define a different format with this key. For example, to remove the right parethesis: \begin{verbatim} \begin{enumerate}[label=\emph{\alph*}),ref=\emph{\alph*}] \end{verbatim} -In both \verb|label| and \verb|ref|, the counters can be +In both |label| and |ref|, the counters can be used as usual: \begin{verbatim} \begin{enumerate}[label=\theenumi.\arabic*.] @@ -184,11 +218,11 @@ or \end{verbatim} (provided the current level is the second one). -Note the \verb|label|s are \textit{not} accumulated to form +Note the |label|s are \textit{not} accumulated to form the reference. If you want, say, something like 1.\textit{a} from 1) as first level and \textit{a}) as second level, -you must set it with \verb|ref|. You may use -\verb|\ref{level1}.\ref{level2}| with appropiate \verb|ref| +you must set it with |ref|. You may use +|\ref{level1}.\ref{level2}| with appropiate |ref| settings, but as Robin Fairbairns points out in the \TeX{} FAQ \begin{quote} \dots{} [that] would be both tedious and error-prone. What is more, it @@ -202,84 +236,160 @@ you might want something like: ... subitem \ref{level2} of item \ref{level1} ... \end{verbatim} -Both \verb|label| and \verb|ref| are moving arguments, and fragile +The value of |ref| is a moving argument, and fragile commands must be protected \textit{except} the counters. -\item \verb|leftmargin=*|. Sets the label width to the width of -the current label, using the default value of \textit{0} in -\verb|\arabic*|, \textit{viii} in \verb|\roman*|, \textit{m} in -\verb|\alph*| and similarly in uppercase forms. The left -margin is then set to \verb|labelwidth| $+$ \verb|labelsep|. -You can give a value to the key \verb|widest|, and it will -be used to set the margin. For example: +\begin{desc} +|font=|\qquad\verb|format=| +\end{desc} + +Sets the label font. Useful when the label is changed with the +optional argument of |\item| and in \texttt{description}. The last +command in || can take an argument with the item label. In +\texttt{description} class setting are in force, so you may want begin +with \verb|\normalfont|. A synonymous is \texttt{format}. + +\begin{desc} +|align=left|\qquad |align=right|\qquad |align=parleft|\3 +\end{desc} + +How the label is aligned (with relation to the label box edges). +Three values are possible: |left|, the default |right| and +\verb|parleft| (a parbox of width \verb|\labelwidth| with flush left +text). The parameters controlling the label spacing should be +properly set, either by hand or more conveniently with the |*| +settings (see below): \begin{verbatim} -\begin{itemize}[label=\textbullet, leftmargin=*] -\begin{enumerate}[label=\roman*), leftmargin=*, widest=iii] +\begin{enumerate}[label=\Roman*., align=left, leftmargin=*] \end{verbatim} +(When the label box is supposed to have its natural width, use +|left|.) -Put in in other words, the label starts at the same place as the -surrounding text (but see \verb|labelindent| below), then comes the -label, the space after it as set by \verb|labelsep| and the item body. +\begin{desc} +|\SetLabelAlign{}{}|\3 +\end{desc} + +New align types can be defined (or the existing ones redefined) with +|\SetLabelAlign|; the predefined values are equivalent +to:\footnote{Prior to version 3.0 the left alignments was incorrectly +defined and the label and the text could overlap.} +\begin{verbatim} +\SetLabelAlign{right}{\hss\llap{#1}} +\SetLabelAlign{left}{#1\hfil} +\SetLabelAlign{parleft}{\strut\smash{\parbox[t]\labelwidth{\raggedright##1}}} +\end{verbatim} -\item \verb|labelsep=*|. Similar to the previous one -but here the label sep is set to \verb|leftmargin| $-$ -\verb|labelwidth|. +If the last thing in the definition is a skip (typically \verb|\hfil|), it is +removed sometimes by description. If for some reason you want to avoid +this, just add \verb|\null| at the end. + + +\subsection{Horizontal spacing of labels} + +\begin{desc} +|labelindent=|\\ +\verb|\labelindent| +\end{desc} + +This parameter is added in \textsf{enumitem} for the blank space from +the margin of the enclosing list/text to the left edge of the label box. This +means there is a redundancy because one of the parameters depends on +the others, i.e., it has to be computed from the other values, as +described below. There is a new counter length |\labelindent| which +defaults to 0 pt. The five parameteres are related in the following +way: +\[ +\verb|\leftmargin|+\verb|\itemindent| = +\verb|\labelindent|+\verb|\labelwidth|+\verb|\labelsep| +\] + +\begin{desc} +|leftmargin=!|\qquad|itemindent=!|\qquad|labelsep=!| +\qquad|labelwidth=!|\qquad|labelindent=!|\3 +\end{desc} + +Sets which value is to be computed from the others. This is done +after \textit{all} keys has been read. Explicit values are not lost, and +so with the following hierarchical settings: \begin{verbatim} +leftmargin=2em +labelindent=1em,leftmargin=! +labelindent=! +\end{verbatim} +|leftmargin| is again 2em and |labelindent| is the computed parameter. +The default is |labelindent=!|, but note some keys sets another value +(\verb|wide| and description \verb|style|s). + +With |align=right| (the default), |labelindent=!| and +|labelwidth=!| behave similarly in practice. + +\begin{desc} +|leftmargin=*|\qquad|itemindent=*|\qquad|labelsep=*| +\qquad|labelwidth=*|\qquad|labelindent=*| +\end{desc} + +Like before, but |labelwidth| is set to the width of the current +label, using the default value of \textit{0} in |\arabic*|, +\textit{viii} in |\roman*|, \textit{m} in |\alph*| and +similarly in uppercase forms (these values can be changed with +|widest|, see below). Examples are: +\begin{verbatim} +\begin{itemize}[label=\textbullet, leftmargin=*] +\begin{enumerate}[label=\roman*), leftmargin=*, widest=iii] \begin{itemize}[label=\textbullet, leftmargin=2pc, labelsep=*] +\begin{enumerate}[label=\arabic*., leftmargin=2\parindent, + labelindent=\parindent, labelsep=*] \end{verbatim} -As before, the label starts at the same place as the surrounding text, -then comes the label, the space after it and the item body. The -difference between \verb|labelsep=*| and \verb|leftmargin=*| is that -in the former the item body begins at a fixed place (namely, -\verb|leftmargin|), while the latter begins at a variable place +The most useful are |labelsep=*| and |leftmargin=*|. +With the former the item body begins at a fixed place (namely, +|leftmargin|), while with the latter begins at a variable place depending on the label (but always the same within a list, of course). -Most of times, what you would want is \verb|leftmargin=*|. - -Unfortunately, \verb|labelsep| has not a default value -to be applied to all lists---simply the current value -is used. If you nest a \verb|leftmargin=*| within a -\verb|labelsep=*|, the value to compute the left margin -is not what you could expect. The way \LaTeX{} assigns values -to the list parameters is one of the things which makes -redefining lists a mess, but with \textsf{enumitem} you can -set default values for every list, as described below. -In this case, all you need is: +Most of times, what you would want is |leftmargin=*|. + +Unfortunately, \LaTeX{} does not define a default |labelsep| to +be applied to all lists---simply the current value is used. With +\textsf{enumitem} you can set default values for every list, as +described below, and so, if you want to make sure |labelsep| is +under your control, all you need is something like: \begin{verbatim} \setlist{itemsep=.5em} \end{verbatim} -% \textbf{Note.} Version 0.2 computes the values even with -% the settings predefined by the classes (only partially -% tested). Please, let me know if a class gives a wrong -% result. +|labelwidth=*| and |labelwidth=!| are synonymous. -\item \verb|widest|. To be used in conjunction with any of the -two previous keys, if desired. It overrides the default -values for the label width. Sometimes, if lists are not very -long, a value of \verb|a| for \verb|\alph| is more sensible -than \verb|m|: +\begin{desc} +|widest=|\qquad|widest*=|\3\qquad|widest| +\end{desc} + +To be used in conjunction with the \texttt{*}-values, if +desired. It overrides the default value for the widest +printed counter. Sometimes, if lists are not very long, a value of +|a| for |\alph| is more sensible than the default |m|: \begin{verbatim} \begin{enumerate}[leftmargin=*,widest=a] % Assume standard 2nd level \end{verbatim} +With no value, the default is restored. With |widest*|, the string is +built using || as the value of the counter (e.g., with +\verb|\roman|, +\verb|widest=viii| and \verb|widest*=8| are the same). -\item \verb|labelindent|. Blank space before the label -with \verb|leftmargin=*| and \verb|labelsep=*|, and in -\verb|description|. Example: -\begin{verbatim} -\begin{enumerate}[label=\arabic*., leftmargin=2\parindent, - labelindent=\parindent, labelsep=*] -\end{verbatim} +Since |\value| does not return a string but a number, +|widest| and the \verb|*| values cannot be used with it. +However, with \verb|widest*|, being a number, it is allowed. + +\subsection{More on horizontal spacing} -Since \verb|\parindent| is not used as such inside lists, but instead -is set internally to either \verb|itemindent| or \verb|listparindent|, +Since |\parindent| is not used as such inside lists, but instead +is set internally to either |\itemindent| or |\listparindent|, when used as the value of a parameter \textsf{enumitem} returns the global value, i. e., the value it has outside the outermost list. -\end{itemize} -The horizontal space in the left margin of the current level -is distributed in the following way: +The horizontal space in the left margin of the current level is +distributed in the following way:\footnote{Admittedly, these figures +are not exactly the clearest possible, and I intend to improve them in +a future release} \begin{center} \begin{tabular}{cc} \fbox{\fbox{\strut \texttt{labelindent}} @@ -290,31 +400,48 @@ is distributed in the following way: \texttt{leftmargin} \end{tabular} \end{center} -Remember \verb|labelsep| spans part of \verb|leftmargin| and -\verb|itemindent| if the latter is not zero. This is often -somewhat confusing, so remember that if you want a separation -between label and item \textit{body} of, say, 6pt, and the item -indent is 8pt, then \verb|labelsep| should be $6 + 8$. The -foregoing discussion about how the \verb|*| values are computed -presumes \verb|itemindent| is 0 pt, but any other value it is -taken into account. -\begin{itemize} - -\item \verb|align|. How the label is aligned. Two values -are possible: \verb|left| and the default \verb|right|. -The parameters controlling the label spacing should be -properly set, either by hand or more conveniently with -the \verb|*| settings: -\begin{verbatim} -\begin{enumerate}[label=\Roman*., align=left, leftmargin=*] -\end{verbatim} +\begin{desc} +\verb|labelsep*=|\3 +\end{desc} + +Remember |labelsep| spans part of |leftmargin| and +|itemindent| if the latter is not zero. This is often somewhat +confusing, so a new key is provided---with \texttt{labelsep*} the +value is reckoned from the left margin (it just sets |\labelsep| +and then adds |\itemindent| to it, but in addition later changes to +|itemindent| are taken into account): +\begin{center} +\begin{tabular}{cc} +\fbox{\fbox{\strut \texttt{labelindent}} + \fbox{\strut \texttt{labelwidth}} + \fbox{\strut \texttt{labelsep*}}} +& +\fbox{\strut\texttt{itemindent}}\\ +\texttt{leftmargin} +\end{tabular} +\end{center} + +\begin{desc} +|labelindent*=|\3 +\end{desc} -\item \verb|start|. Sets the number of the first item. +Like |labelindent|, but it is reckoned from the left margin in +the current list and not from that in the enclosing list/text. -\item \verb|resume|. Makes the counter to be continued -from the previous \verb|enumerate|, instead of resetting it -to 1. +\subsection{Numbering, stopping, and resuming} + +\begin{desc} +|start=| +\end{desc} +Sets the number of the first item. + +\begin{desc} +|resume| +\end{desc} + +The counter continues from the previous |enumerate|, +instead of being reset to 1. \begin{verbatim} \begin{enumerate} \item First item. @@ -322,124 +449,316 @@ to 1. \end{enumerate} Text. \begin{enumerate}[resume] -\item Third item +\item Third item \end{enumerate} \end{verbatim} -\item \verb|resume*| is like \verb|resume| but the options from the -previous list are used, too. This option must be restricted to the -optional argument in a environment (this is the only place where it -makes sense) and further keys are not allowed. It should be used -sparingly---if you are using it often, then very likely you want -to define a new list (see below). +This is done locally. If you want global resuming, see next section on series. + +\begin{desc} +|resume*| +\end{desc} + +Like |resume| but the options from the previous list are used, +too. This option must be restricted to the optional argument in a +environment (this is the only place where it makes sense). It should +be used sparingly---if you are using it often, then very likely you +want to define a new list (see \ref{s.clone}). Further keys are allowed, and +in this case the saved options are overriden by those in the current +list (i.e., the position of \texttt{resume*} does not matters). For +example: +\begin{verbatim} +\begin{enumerate}[resume*,start=1] % or [start=1,resume*] +\end{verbatim} +uses the keys in the previuos \texttt{enumerate}, but restarts the +counter. + +\subsection{Series} + +\begin{desc} +|series=|\3\\ +||\qquad|resume*=| +\qquad|resume=|\3 +\end{desc} + +A new method (3.0) of continuing lists is by means of the key +\texttt{series}, so that they behave like a unit. A list with key +\texttt{series} is considered the starting list and its settings are +stored \textit{globally}, so that they can be used later with +\texttt{resume}/\texttt{resume*}. All these keys take a value with +the series name (which must be different from existing keys): +\begin{itemize} +\item |resume=| just continue numbering items in the +series, +\item |resume*=| also applies the settings of the +starting list, +\item ||, i.e., the series name used as a key, is an +alternative to |resume*=|. +\end{itemize} +For example: +\begin{verbatim} +\begin{enumerate}[label=\arabic*(a),leftmargin=1cm,series=lafter] +\item A +\item B +\end{enumerate} +\end{verbatim} +You get: 1(a) 2(a). You can continue with: +\begin{verbatim} +\begin{enumerate}[label=\arabic*(b),resume*=lafter] + % or [label=\arabic*(b),lafter] +\item A +\item B +\end{enumerate} +\end{verbatim} +You get: 3(b) 4(b). (But you can use |start=1|, if you like.) + +Note you can add further arguments, which are executed after those +saved at the starting list and therefore take precedence over them -- +in particular, |resume*| itself takes precedence over a +|start| (e.g., |start=1|) in the the starting list. + +Every time a series is started, several commands are defined +internally, so to avoid wasting resources and use the same name for +non-overlapping series. + + +\subsection{Penalties} + +\begin{desc} +|beginpenalty=|\qquad +|midpenalty=|\qquad |endpenalty=| +\end{desc} + +Set the penalty at the beginning of a list, between items and at the +end of the list, respectively. Please, refer to your \LaTeX{} or +\TeX{} manual about how penalties control page breaks. Unlike other +parameters, when a list starts their values are not reset to the +default, thus they apply to the child lists. +\begin{desc} +|before=| \qquad |before*=| +\end{desc} + +Execute code before the list starts (more precisely, in the second +argument of the |list| environment used to define them). The +unstarred form sets the code to be executed, overriding any previous +value, while the starred one adds the code to the existing one (in +the setting hierarchy, see below, \textit{not} with relation to the +enclosing list/text). It can contain, say, rules and text, but this +has not been extensively tested. All calculations have been finished, +and you can access and manipulate the list parameters. For example, +to have both margins (left and right) set to the widest label: +\begin{verbatim} +\setlist{leftmargin=*,before=\setlength{\rightmargin}{\leftmargin}} +\end{verbatim} -\item \verb|beginpenalty|, \verb|midpenalty| and \verb|endpenalty| set -the penalty at the beginning of a list, between items and at the end -of the list. Please, refer to your \LaTeX{} or \TeX{} manual about -how penalties control page breaks. Unlike other parameters, when a -list starts their values are not reset to the default, thus they -apply to the enclosed lists, too. +\begin{desc} +|after=|\qquad|after*=| +\end{desc} -\item \verb|before| and \verb|before*| executes code before the list -starts (more precisely, in the second argument of the \verb|list| -environment used to define them). The former sets the code to be -executed, overriding any previous value, while the starred form adds -the code to the existing one (in the setting hierarchy, see below, -\textit{not} with relation to the enclosing list). It can contain, -say, rules and text, but this has not been extensively tested. +Same, but just before the list ends. -\item \verb|after| and \verb|after*| is the same but just before -the list ends. +\subsection{Description styles} -\end{itemize} +A key available in |description|. +\begin{desc} +|style=| +\end{desc} -A key are available in \verb|description| -\begin{itemize} -\item \verb|style|. Sets the \textit{style}, with the -following values: +Sets the description \textit{style}. || can be any of the +following: \begin{itemize} -\item \verb|nextline|: if the label does not fit in the margin, the -text continues in the next line, otherwise it is placed in a box of -width \verb|leftmargin|, ie, the item body never sticks into the left -margin. +\item |standard|: like |description| in standard classes, although +with other classes it could be somewhat different. The label is +boxed. Sets \verb|itemindent=!|. -\item \verb|sameline|: like \verb|nextline| but if the label does not -fit in the margin the text continues in the same line. +\item |unboxed|: much like the standard |description|, but +the label is not boxed to avoid uneven spacing and unbroken labels if +they are long. Sets \verb|itemindent=!|. + +\item |nextline|: if the label does not fit in the margin, the text +continues in the next line, otherwise it is placed in a box of width +|\leftmargin| $-$ |\labelsep|, i.e., the item body never sticks into +the left margin. Sets \verb|labelwidth=!|. + +\item |sameline|: like |nextline| but if the label does not +fit in the margin the text continues in the same line. Same as +\verb|style=unboxed,labelwidth=!|. + +\item |multiline|: the label is placed in a parbox whose width is +|leftmargin|, with several lines if +necessary. Same as \verb|style=standard,align=parleft,labelwidth=!|. + +Three caveats: (1) mixing boxed and unboxed labels has not a +well-defined behaviour, (2) when nesting list all combinations are +allowed but not all make sense, and (3) nesting \verb|nextline| lists +is not supported (it works, but its behaviour might change in the +future, because the current one is not what one could expect). -\item \verb|multiline|: the label is placed in a parbox whose width is -\verb|leftmargin|, with several lines if necessary. -\item \verb|unboxed|: much like the standard \verb|description|, but -the label is not boxed to avoid uneven spacing and unbroken labels if -they are long. -\end{itemize} -\end{itemize} -A few predefined valueless keys might be useful: -\begin{itemize} -\item \verb|noitemsep| kills the space between items -and paragraphs (ie, \verb|itemsep=0pt| and \verb|parsep=0pt|). -\item \verb|nolistsep| kills all vertical spacing. -\item \verb|fullwidth| is still somewhat experimental. The -leftmargin is null and the label is part of the text. Here -\verb|labelsep| sets the separation between the label and the first -word. -You may want to set \verb|itemindent| and \verb|listparindent| -to \verb|\parindent|, too. \end{itemize} -% If you think the addition of \verb|\parskip| and \verb|\parsep| -% is annoying, you can use \verb|listskip| ($=$ \verb|\topsep| $-$ -% \verb|\parskip|) and \verb|itemskip| ($=$ \verb|\itemsep| $-$ -% \verb|\parsep|). + +\subsection{Compact lists} + +\begin{desc} +|noitemsep|\qquad|nolistsep| +\end{desc} + +The key |noitemsep| kills the space between items and paragraphs +(i.e., |itemsep=0pt| and |parsep=0pt|), while +|nolistsep| kills all vertical spacing. + +\subsection{``Wide'' lists} + +\begin{desc} +\verb|wide|\3\\ +\verb|wide=| +\end{desc} + +With this convenience key, the leftmargin is null and the label is +part of the text---in other word, the items look like ordinary +paragraphs.\footnote{\texttt{fullwidth} is deprecated.} Here |labelsep| +sets the separation between the label and the first word. It is +equivalent to +\begin{verbatim} +align=left, leftmargin=0pt, labelindent=\parindent, +listparindent=\parindent, labelwidth=0pt, itemindent=! +\end{verbatim} +With |wide=| you may set at once another value instead of +|\parindent|. Of course, these keys can be overriden after +\verb|wide|, too; for example, remembering that with left-aligned labels +the text is pushed if the they are wider than |labelwidth|, you +can set |labelwidth=1.5em| for a minimal width, or instead of +|itemindent=!| you may prefer |itemindent=*|, which sets the +minimal width to that of widest label. In level 2 you may prefer +|labelindent=2\parindent|, and so on. You may also want to +combine it with |noitemsep| or |nolistsep|. + +\section{Inline lists} +\label{s.inline} + +\3 + +\begin{desc} +|inline| \qquad(package option)\\ +\texttt{enumerate*}\qquad\texttt{itemize*}\qquad +\texttt{description*} \qquad(environments) +\end{desc} + +With the package option \texttt{inline}, three environments for inline +lists are defined: \texttt{enumerate*}, \texttt{itemize*}, and +\texttt{description*}. They emulate the behaviour of +\textsf{paralist} and \textsf{shortlst} in that labels and settings +are shared with the displayed (ie, ``normal'') lists \texttt{enumerate}, +\texttt{itemize} and \texttt{description}, respectively (however, +remember resuming is based on environment names, not on list types). This applies +only to those created with \texttt{inline} -- inline lists created +with |\newlist| as described below are independent and use their +own labels and settings. + +\begin{desc} +|itemjoin=|\qquad|itemjoin*=| +\qquad|afterlabel=| +\end{desc} + +Format is set with keys \texttt{itemjoin} (default is a space), and +\texttt{afterlabel} (default is |\nobreakspace|, ie, |~|). +An additional key is \texttt{itemjoin*}, which, if set, is used +instead of \texttt{itemjoin} before the last item. So, with +\begin{verbatim} +before=\unskip{: }, itemjoin={{; }}, itemjoin*={{, and }} +\end{verbatim} +the following punctuation between items is used: +\begin{quote} +Blah blah: (a) one; (b) two; (c) three, and (d) four. Blah blah +\end{quote} + +\verb|itemjoin| is ignored in vertical mode (i.e., in mode unboxed +and just after a quote, a displayed list and the like). + +\begin{desc} +|mode=unboxed|\qquad|mode=boxed| +\end{desc} + +Items are boxed, so floats are lost and nested lists are not allowed +(remember many displayed elements are defined as lists). If using +floats or lists inside inline lists is important, use an alternative +``mode'', which you can activate with +\texttt{mode=unboxed} (the default is \texttt{mode=boxes}). With it +floats may be used freely, but misplaced |\item|s are not catched and +\texttt{itemjoin*} is ignored (a warning is written to the log about +this fact). + +\section{Global settings} Global changes, to be applied to all of these list, are also possible: -\begin{itemize} -\item \verb|\setenumerate[level]{format}| -\item \verb|\setitemize[level]{format}| -\item \verb|\setdescription{format}| -\item \verb|\setlist[level]{format}| -\end{itemize} -Where \verb|level| is the list level in \verb|list|, and the -corresponding level in \verb|enumerate| and \verb|itemize|. Without -\verb|level|, the format applies to all levels. Here list does not -mean any list but only the three ones handled by this package. -Example: +\begin{desc} +|\setlist[enumerate,]{}|\\ +|\setlist[itemize,]{}|\\ +|\setlist[description,]{}|\\ +|\setlist[]{}| +\end{desc} +Where || is the list level (one or more) in |list|, and the +corresponding levels in |enumerate| and +|itemize|.\footnote{\verb|\string\setenumerate|, +\verb|\string\setitemize| and \verb|\string\setdescription| are +deprecated.} With no +||, the format applies to all of them. Here list does not +mean any list but only the three ones handled by this package and +those redefined by this package or defined with |\newlist| (see +below). For example: \begin{verbatim} \setlist{noitemsep} \setlist[1]{\labelindent=\parindent} % << Usually a good idea -\setitemize{leftmargin=*} -\setitemize[1]{label=$\triangleleft$} -\setenumerate{labelsep=*, leftmargin=1.5pc} -\setenumerate[1]{label=\arabic*., ref=\arabic*} -\setenumerate[2]{label=\emph{\alph*}), - ref=\theenumi.\emph{\alph*}} -\setenumerate[3]{label=\roman*), ref=\theenumii.\roman*} -\setdescription{font=\sffamily\bfseries} -\end{verbatim} -These setting are read in the following order: list, -list at the current level, enumerate/itemize/description, -and enumerate/itemize at the current level; if a key -has several values, the last one, ie. the most specific -one, is applied. Finally, the -optional argument, if any, is applied. \LaTeX{} provides -a set of macros to change many of these parameters, but -setting them with the package is more consistent and -sometimes more flexible at the cost of being more -``explicit'' (and verbose). - -No attempt has been made (yet) to discriminate the font size -(\verb|\normalsize|, \verb|\small|\dots). Suggestions are -most welcome. - -\subsection{\textsf{enumerate}-like labels} +\setlist[itemize]{leftmargin=*} +\setlist[itemize,1]{label=$\triangleleft$} +\setlist[enumerate]{labelsep=*, leftmargin=1.5pc} +\setlist[enumerate,1]{label=\arabic*., ref=\arabic*} +\setlist[enumerate,2]{label=\emph{\alph*}), + ref=\theenumi.\emph{\alph*}} +\setlist[enumerate,3]{label=\roman*), ref=\theenumii.\roman*} +\setlist[description]{font=\sffamily\bfseries} +\end{verbatim} +These setting are read in the following order: list, list at the +current level, enumerate/itemize/description, and +enumerate/itemize/description at the current level; if a key appears +several times with different values, the last one, i.e., the most +specific one, is applied. If we are resuming a series or a list with +\texttt{resume*}, the saved keys are then applied. Finally, the +optional argument (except \texttt{resume*}), if any, is applied. + +\LaTeX{} provides a set of macros to change many of these parameters, +but setting them with the package is more consistent and sometimes +more flexible at the cost of being more ``explicit'' (and verbose). + +The list specification can contain variables and counters, provided +they are expandable, and counters are \textsf{calc}-savvy, so that if +you load this package you can write things like: +\begin{verbatim} +\newcount{toplist} +\setcount{toplist}{1} +\newcommand{\mylistname}{enumerate} +\setlist[\mylistname,\value{toplist}+1]{labelsep=\itemindent+2em] +\end{verbatim} +This allows defining lists within loops. + +Currently, a way to discriminate the font size is not provided +(|\normalsize|, |\small|\dots). + +\section{\textsf{enumerate}-like labels} +\label{s.short} + +\begin{desc} +|shortlabels| (package option) +\end{desc} With the package option \texttt{shortlabels} you can use an -\textsf{enumerate}-like syntax, where \verb|A|, \verb|a|, \verb|I|, -\verb|i| and \verb|1| stand for \verb|\Alph*|, \verb|\alph*|, -\verb|\Roman*|, \verb|\roman*| and \verb|\arabic*|. This is intended +\textsf{enumerate}-like syntax, where |A|, |a|, |I|, +|i| and |1| stand for |\Alph*|, |\alph*|, +|\Roman*|, |\roman*| and |\arabic*|. This is intended mainly as a sort of compatibility mode with the \textsf{enumerate} package, and therefore the following special rule applies: if the very first option (at any level) is not recognized as a valid key, then it @@ -450,7 +769,7 @@ example: ... \end{enumerate} \end{verbatim} -Although perhaps not so useful, you can omit \verb|label=| in the +Although perhaps not so useful, you can omit |label=| in the itemize environment under similar conditions, too: \begin{verbatim} \begin{itemize}[\textbullet] @@ -458,61 +777,162 @@ itemize environment under similar conditions, too: \end{itemize} \end{verbatim} -In addition, you can define new keys (or redefine them), which is +\begin{desc} +|\SetEnumerateShortLabel{}{}| +\end{desc} + +With this command, you can define new keys (or redefine them), which is particularly useful for enumerate to be adapted to especific -typographical rules or to extend it for non-Latin scrips: -\begin{verbatim} -\SetEnumerateShortLabel{}{} -\end{verbatim} -where \verb|| contains one of the starred versions of +typographical rules or to extend it for non-Latin scrips. Here +|| contains one of the starred versions of counters. For example: \begin{verbatim} \SetEnumerateShortLabel{i}{\textsc{\roman*}} \end{verbatim} -redefines \verb|i| so that items using this key are numbered with -small caps roman numerals. +redefines |i| so that items using this key are numbered with +small caps roman numerals. The key has to be a single letter. -\subsection{Cloning the three basic lists} +\section{Cloning the basic lists} +\label{s.clone} -As of version 2.0 the three lists can be cloned so that you can -define ``logical'' environments behaving like them. To define a -new lists (or redefine a existing one), use \verb|\newlist| (or -\verb|\renewlist|), which the following syntax: -\begin{verbatim} -\newlist{}{}{} -\end{verbatim} -where \verb|| is \verb|enumerate|, \verb|itemize| or -\verb|description|. Then you can (in fact you must, at least the -label) set the new list with \verb|\setlist|: +\begin{desc} +|\newlist{}{}{}|\\ +|\renewlist{}{}{}| +\end{desc} + +The three lists can be cloned so that you can define ``logical'' +environments behaving like them. To define a new lists (or redefine a +existing one), use |\newlist| (or |\renewlist|), where || is +|enumerate|, |itemize| or |description|. + +\begin{desc} +\verb|\setlist[,]{}|\\ +\verb|\setlist*[,]{}| +\end{desc} + +After creating a list, you can (in fact you +must, at least the label) set the new list with |\setlist|: \begin{verbatim} \newlist{ingredients}{itemize}{1} \setlist[ingredients]{label=\textbullet} \newlist{steps}{enumerate}{2} -\setlist[steps,1]{label=(\arabic*)} -\setlist[steps,2]{label=(\arabic*)} +\setlist[steps,1,2]{label=(\arabic*)} \end{verbatim} -The optional argument of \verb|\setlist| has an extended -syntax---names say which lists applies the settings to, and numbers -the level. Do not use this syntax in the three basic lists, but that -above, except if you redefine them. - -\subsection{New counters} - -With +Names in the optional argument of |\setlist| say which lists applies the +settings to, and numbers say the level (it is calc-savvy). Several +lists and/or several levels can be given, and all combinations are +set; e.g.: \begin{verbatim} -\AddEnumerateCounter{}{}{} +\setlist[enumerate,itemize,2,3]{...} \end{verbatim} -a counter representation is ``registered'' so that \textsf{enumitem} +\noindent sets enumerate/2, enumerate/3, itemize/2 and itemize/3. +No number (or 0) means ``all levels'' and no name means ``all lists''; no +optional argument means ``all lists at all levels''. + +The three inline lists have types \texttt{enumerate*}, +\texttt{itemize*}, and \texttt{description*}, which are available +always, even without the package option |inline| (which just defines +three environments with these names). + +The starred form \verb|\setlist*| adds the settings to previous ones. + +\begin{desc} +\verb|\setlistdepth{|\3 +\end{desc} + +By default, \LaTeX{} has a limit of 5 nesting levels, but when +cloning list this value may be too short, and therefore you may want +to set a new value. In levels below the 5th (or the deepest defined by a +class), the settings of the last are used (i.e., \verb|\@listvi|). + +\section{More about counters} + +\subsection{New counter representation} + +\begin{desc} +\verb|\AddEnumerateCounter{}{}{}| +\end{desc} + +``Registers'' a counter representation so that \textsf{enumitem} recognizes it. Intended mainly for non Latin scripts, but also useful in Latin scripts. For example: \begin{verbatim} +\makeatletter \def\ctext#1{\expandafter\@ctext\csname c@#1\endcsname} \def\@ctext#1{\ifcase#1\or First\or Second\or Third\or Fourth\or Fifth\or Sixth\fi} +\makeatother \AddEnumerateCounter{\ctext}{\@ctext}{Second} \end{verbatim} +A starred variant allows to give a number instead of a string as the +widest label; for example, if the widest label is that corresponding +to the value 2:\3 +\begin{verbatim} +\AddEnumerateCounter*{\ctext}{\@ctmoreext}{2} +\end{verbatim} +This variant is to be preferred if the representation is not a plain +string but it is styled, e.g., +with small caps. (The counter names can contain |@| even if not a letter.) -\subsection{Package option \texttt{loadonly}} +\subsection{Restarting \texttt{enumerate}s} + +\begin{desc} +|\restartlist{}|\3 +\end{desc} + +Currently, with +\begin{verbatim} +\setlist[enumerate]{resume} +\end{verbatim} +you can get a continuous numbering through a document. A new command has +been added for restarting the counter in the middle of the document: +\begin{verbatim} +\restartlist{} +\end{verbatim} + +It is based solely in the list name, not the list type, which means +\texttt{enumerate*} as defined with the package option \texttt{inline} +is not the same as \texttt{enumerate}, because its name is different. + +\section{Generic keys and values} + +\begin{desc} +|\SetEnumitemKey{}{}|\3 +\end{desc} + +With this command you can create your own (valueless) keys. For +example: +\begin{verbatim} +\SetEnumitemKey{midsep}{topsep=3pt,partopsep=0pt} +\end{verbatim} + +Keys so defined can then be used like the others. + +\begin{desc} +|\SetEnumitemValue{}{}{}|\3 +\end{desc} + +This commands provides a further abstraction layer for the +|=| pairs. With it you can define logical names which +are translated to the actual value. For example, with: +\begin{verbatim} +\SetEnumitemValue{label}{numeric}{\arabic*.} +\SetEnumitemValue{leftmargin}{standard}{\parindent} +\end{verbatim} +you might say: +\begin{verbatim} +\begin{enumerate}[label=numeric,leftmargin=standard] +\end{verbatim} +So, you can left to the final design what |label=numeric| means. + +\section{Package options} + +Besides \verb|inline|, \verb|ignoredisplayed|, and \verb|shortlabels|, +the following option is available. + +\begin{desc} +\verb|loadonly| +\end{desc} With this package option the package is loaded but the three lists are not redefined. You can create your own lists, yet, or @@ -521,17 +941,19 @@ even redefine the existing ones. \section{Three patterns} Three list layouts could be considered very -frequent. Let us apply the parameters above to define them. +frequent. Let us apply the parameters above to define them. (Below +are samples.) The first pattern aligns the label with the surrounding -\verb|\parindent| while the item body is indented depending -on the label and a fixed \verb|labelsep|: +|\parindent| while the item body is indented depending +on the label and a fixed |labelsep|: \begin{verbatim} labelindent=\parindent, leftmargin=* \end{verbatim} -A fairly frequent variant is when the label is aligned with -the surrounding text: +A fairly frequent variant is aligning the label with the +surrounding text (rememeber |labelindent| is |0pt| by +default): \begin{verbatim} leftmargin=* \end{verbatim} @@ -544,55 +966,56 @@ set with \end{verbatim} The second pattern aligns the item body with the surrounding -\verb|\parindent|. In this case: +|\parindent|. In this case: \begin{verbatim} leftmargin=\parindent \end{verbatim} -A third pattern would be to align the label with \verb|\parindent| -and the item body with \verb|2\parindent|: +A third pattern would be to align the label with |\parindent| +and the item body with |2\parindent|: \begin{verbatim} labelindent=\parindent, leftmargin=2\parindent, itemsep=* \end{verbatim} Again, a variant would be to align the label with the surrounding -text and the itembody with \verb|\parindent|: +text and the itembody with |\parindent|: \begin{verbatim} leftmargin=\parindent, itemsep=* \end{verbatim} -Note here \verb|\parindent| means the global value applied +Note here |\parindent| means the global value applied to normal paragraphs. \section{The trivlist issue} -\LaTeX{} uses a simplified version of \verb|list| named -\verb|trivlist| to set displayed material, like \verb|center|, -\verb|quote|, etc., even if conceptually they are not lists. -Unfortunately, \verb|trivlist| uses the current list settings, which -has the odd side effect that changing the vertical spacing of lists -also changes sometimes the spacing in these environments. +\LaTeX{} uses a simplified version of |list| named |trivlist| to set +displayed material, like |center|, |verbatim|, \verb|tabbing|, +\verb|theorem|, etc., even if conceptually they are not lists. +Unfortunately, |trivlist| uses the current list settings, which has +the odd side effect that changing the vertical spacing of lists also +changes sometimes the spacing in these environments. -This package modifies \verb|trivlist| so that the default settings for -the current level (ie, those set by the corresponding \verb|clo| +This package modifies |trivlist| so that the default settings for +the current level (ie, those set by the corresponding |clo| files) are set again. In standard \LaTeX{} that is usually redundand, but if we want to fine tune lists, not resetting the default values -could be a real issue (particularly if you use the \verb|nolistsep| +could be a real issue (particularly if you use the |nolistsep| option). -A minimal control of vertical spacing has been made possible with +A minimal control of vertical spacing has been made possible +with\footnote{\verb|\string\setdisplayed| is deprecated.} \begin{itemize} -\item \verb|\setdisplayed[level]{format}| +\item |\setlist[trivlist,]{}| \end{itemize} -but \verb|trivlist| itself, which is not used directly very +but |trivlist| itself, which is not used directly very often, does not accept an optional argument. This feature -is not intended as a full-fledge \verb|trivlist| formatter. +is not intended as a full-fledge |trivlist| formatter. -If for some reason you do not want to change \verb|trivlist| +If for some reason you do not want to change |trivlist| and preserve the original definition, you can use the -package option \verb|ignoredisplayed|. +package option |ignoredisplayed|. \section{Samples} @@ -603,15 +1026,19 @@ document again. \else -In these samples we set \verb|\setlist{noitemsep}| +In these samples we set |\setlist{noitemsep}| \setlist{noitemsep} \small -\vskip6pt -\goodbreak -\hrule -\vskip6pt +\newcommand{\newsample}{\vskip6pt\goodbreak\hrule height 1pt\vskip6pt} +\newcommand{\samplesep}{\vskip6pt\goodbreak\hrule\vskip6pt} +\newbox\vsep +\setbox\vsep\hbox{\vrule height 2ex depth 16ex width 1pt} +\dp\vsep0pt +\newcommand\showsep{\leavevmode\llap{\copy\vsep}} + +\newsample \begin{verbatim} En un lugar de la Mancha, de cuyo nombre no quiero acordarme, @@ -626,7 +1053,11 @@ Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s noches, duelos y quebrantos los s\'{a}bados... \end{verbatim} -En un lugar de la Mancha, de cuyo nombre no quiero acordarme, +The rule shows \verb|labelindent|. + +\samplesep + +\showsep En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que viv\'{\i}a un hidalgo de los de \begin{enumerate}[labelindent=\parindent,leftmargin=*] \item lanza en astillero, @@ -637,15 +1068,15 @@ no ha mucho tiempo que viv\'{\i}a un hidalgo de los de Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s noches, duelos y quebrantos los s\'{a}bados... +\newsample -\vskip6pt -\goodbreak -\hrule -\vskip6pt +With |\begin{enumerate}[leftmargin=*] % labelindent=0pt by default|. -With \verb|\begin{enumerate}[leftmargin=*]| +The rule shows \verb|labelindent|. -En un lugar de la Mancha, de cuyo nombre no quiero acordarme, +\samplesep + +\noindent\showsep\hskip\parindent En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que viv\'{\i}a un hidalgo de los de \begin{enumerate}[leftmargin=*] \item lanza en astillero, @@ -656,14 +1087,15 @@ no ha mucho tiempo que viv\'{\i}a un hidalgo de los de Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s noches, duelos y quebrantos los s\'{a}bados... -\vskip6pt -\goodbreak -\hrule -\vskip6pt +\newsample -With \verb|\begin{enumerate}[leftmargin=\parindent]| +With |\begin{enumerate}[leftmargin=\parindent]|. -En un lugar de la Mancha, de cuyo nombre no quiero acordarme, +The rule shows \verb|leftmargin|. + +\samplesep + +\showsep En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que viv\'{\i}a un hidalgo de los de \begin{enumerate}[leftmargin=\parindent] \item lanza en astillero, @@ -674,18 +1106,17 @@ no ha mucho tiempo que viv\'{\i}a un hidalgo de los de Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s noches, duelos y quebrantos los s\'{a}bados... -\vskip6pt -\goodbreak -\hrule -\vskip6pt +\newsample -With -\begin{verbatim} -\begin{enumerate}[labelindent=\parindent, leftmargin=*, - label=\Roman*., widest=IV, align=left] -\end{verbatim} +With |\begin{enumerate}[labelindent=\parindent,|\allowbreak +| leftmargin=*,|\allowbreak| label=\Roman*.,|\allowbreak +| widest=IV,|\allowbreak| align=left]|. -En un lugar de la Mancha, de cuyo nombre no quiero acordarme, +The rule shows \verb|labelindent|. + +\samplesep + +\showsep En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que viv\'{\i}a un hidalgo de los de \begin{enumerate}[labelindent=\parindent, leftmargin=*, label=\Roman*., widest=IV, align=left] @@ -697,14 +1128,13 @@ no ha mucho tiempo que viv\'{\i}a un hidalgo de los de Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s noches, duelos y quebrantos los s\'{a}bados... -\vskip6pt -\goodbreak -\hrule -\vskip6pt +\newsample -With \verb|\begin{enumerate}[label=\fbox{\arabic*}]|. A reference to +With |\begin{enumerate}[label=\fbox{\arabic*}]|. A reference to the first item is \ref{i:first} +\samplesep + En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que viv\'{\i}a un hidalgo de los de \begin{enumerate}[label=\fbox{\arabic*}] @@ -716,26 +1146,25 @@ no ha mucho tiempo que viv\'{\i}a un hidalgo de los de Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s noches, duelos y quebrantos los s\'{a}bados... -\vskip6pt -\goodbreak -\hrule -\vskip6pt +\newsample With nested lists. +\samplesep + \begin{verbatim} En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que viv\'{\i}a un hidalgo de los de -\begin{enumerate}[label=\alph*), labelindent=\parindent, +\begin{enumerate}[label=(\alph*), labelindent=\parindent, leftmargin=*, start=12] - \item lanza en astillero, - \begin{enumerate}[label=\alph{enumi}.\roman*), leftmargin=*, start=8] - \item adarna antigua, - \end{enumerate} - \item roc\'{\i}n flaco, y - \begin{enumerate}[label=\alph{enumi}.\roman*), leftmargin=*, resume] - \item galgo corredor. - \end{enumerate} +\item lanza en astillero, +\begin{enumerate}[label=(\alph{enumi}.\roman*), leftmargin=*, start=7] +\item adarna antigua, +\end{enumerate} +\item roc\'{\i}n flaco, y +\begin{enumerate}[label=(\alph{enumi}.\roman*), leftmargin=*, resume] +\item galgo corredor. +\end{enumerate} \end{enumerate} Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s noches, duelos y quebrantos los s\'{a}bados... @@ -743,25 +1172,21 @@ noches, duelos y quebrantos los s\'{a}bados... En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que viv\'{\i}a un hidalgo de los de -\begin{enumerate}[label=\alph*), labelindent=\parindent, +\begin{enumerate}[label=(\alph*), labelindent=\parindent, leftmargin=*, start=12] \item lanza en astillero, -\begin{enumerate}[label=\alph{enumi}.\roman*), leftmargin=*, start=7] +\begin{enumerate}[label=(\alph{enumi}.\roman*), leftmargin=*, start=7] \item adarna antigua, \end{enumerate} \item roc\'{\i}n flaco, y -\begin{enumerate}[label=\alph{enumi}.\roman*), leftmargin=*, resume] +\begin{enumerate}[label=(\alph{enumi}.\roman*), leftmargin=*, resume] \item galgo corredor. \end{enumerate} \end{enumerate} Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s noches, duelos y quebrantos los s\'{a}bados... -\vskip6pt -\goodbreak -\hrule -\vskip6pt - +\newsample \begin{verbatim} En un lugar de la Mancha, de cuyo nombre no quiero acordarme, @@ -777,6 +1202,8 @@ Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s noches, duelos y quebrantos los s\'{a}bados... \end{verbatim} +\samplesep + En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que viv\'{\i}a un hidalgo de los de \begin{description}[font=\sffamily\bfseries, leftmargin=3cm, @@ -789,12 +1216,11 @@ no ha mucho tiempo que viv\'{\i}a un hidalgo de los de Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s noches, duelos y quebrantos los s\'{a}bados... -\vskip6pt -\goodbreak -\hrule -\vskip6pt +\newsample + +Same, but with |sameline|. -Same, but with \verb|sameline|. +\samplesep En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que viv\'{\i}a un hidalgo de los de @@ -808,14 +1234,13 @@ no ha mucho tiempo que viv\'{\i}a un hidalgo de los de Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s noches, duelos y quebrantos los s\'{a}bados... -\vskip6pt -\goodbreak -\hrule -\vskip6pt +\newsample -Same, but with \verb|multiline|. Note the text overlaps if +Same, but with |multiline|. Note the text overlaps if the item body is too short. +\samplesep + En un lugar de la Mancha, de cuyo nombre no quiero acordarme, no ha mucho tiempo que viv\'{\i}a un hidalgo de los de \begin{description}[font=\sffamily\bfseries, leftmargin=3cm, @@ -823,7 +1248,7 @@ no ha mucho tiempo que viv\'{\i}a un hidalgo de los de \item[Lo primero que ten\'{\i}a el Quijote] lanza en astillero, \item[Lo segundo] adarna antigua, \item[Lo tercero] roc\'{\i}n flaco, y -\item[Y por \'{u}ltimo, lo cuarto] galgo corredor. +\item[Y por \'{u}ltimo, lo cuar] galgo corredor. \end{description} Una olla de algo m\'{a}s vaca que carnero, salpic\'{o}n las m\'{a}s noches, duelos y quebrantos los s\'{a}bados... @@ -836,14 +1261,15 @@ noches, duelos y quebrantos los s\'{a}bados... \subsection{\LaTeX{} lists} -As it is well known, \LaTeX{} predefines three lists: enumerate, -itemize and description. This is a very frequent classification which -one can also find in, say, HTML. However, there is a more general -model based in three fields---namely, label, title, and body---, so -that enumerate and itemize has label (numbered and unnumbered) but -no title, while description has title but no label. In this model, -one can have a description with entries marked with labels, as for -example: +As it is well known, \LaTeX{} predefines three lists: +\texttt{enumerate}, \texttt{itemize} and \texttt{description}. This +is a very frequent classification which can also be found in, say, +HTML. However, there is a more general model based in three +fields---namely, label, title, and body---, so that enumerate and +itemize has label (numbered and unnumbered) but no title, while +description has title but no label. In this model, one can have a +description with entries marked with labels, as for example (of +course, this simple solution is far from satistactory): \begin{verbatim} \newcommand\litem[1]{\item{\bfseries #1,\enspace}} \begin{itemize}[label=\textbullet] @@ -871,20 +1297,96 @@ no ha mucho tiempo que viv\'{\i}a un hidalgo de los de \hrule \vskip6pt -This format in not infrequent at all and I thing any future -development of this package has to take it into account. +This format in not infrequent at all and a tool for defining them is +on the way and at a very advanced stage. It has not been include in +version 3.0 because I'm not sure if the proper place is this package +or \textsf{titlesec} and it is not stable enough yet. \subsection{Known issues} -Description styles other than the default one don't group -labels if they are nested. +\begin{itemize} + +\item +List resuming is based on environment names, and when a +|\newenvironment| contains a list you may want to use |\begin| and +|\end|. Using the corresponding commands, however, is not an error, +but it is your responsability to make sure the result is correct. + +\item +It seems there is no way to catch a misspelled name in |\setlist| +and a meaningless error ``Missing number, treated as zero'' is raised. + +\item The behaviour of mixed boxed labels (including enumerate and +itemize) and unboxed labels is not well-defined. Similarly, resuming +a series and a list at the same time is allowed, too, but again its +behaviour is not well-defined. + +\end{itemize} + +\subsection{What's new in 3.0} + +\begin{itemize} +\item Inline lists, with keys to set how items are joined (ie, the +punctuation between items). Two modes are provided: \verb|boxed| and +\verb|unboxed|. + +\item \verb|\setlist| is \textsf{calc}-savvy (eg, for use in loops), +and you can set diferent lists and levels at once. \item All lengths +related to labels can take the value \verb|*| (and not only +\verb|labelsep| and \verb|leftmargin|). Its behaviour has been made +consistent and there is new value \verb|!| which does not compute the +widest label. + +\item With \verb|\restartlist{}|, list counters can be restarted (in +case you are using \verb|resume|). + +\item \verb|resume*| can be combined with other keys. + +\item Lists can be gathered globally using series, so that they are +considered a single list. To start a series just use +|series=| and then resume it with |resume=| or +|resume*=|. + +\item The ``experimental'' \verb|fullwidth| has been replaced by a new key +\verb|wide|. + +\item|\SetLabelAlign| defines new align values. -You must use the \LaTeX{} syntax for environments, with \verb|\begin| -and \verb|\end|. +\item You can define ``abstract'' values (eg, \verb|label=numeric|) and +new keys. +\end{itemize} + +\begin{itemize} +\item (3.2) \verb|start| and \verb|widest*| are \textsf{calc}-savvy. +\item (3.2) \verb|\value| can be used with \verb|widest*|. +\item (3.2) Some internal restrictions in \verb|\arabic| and the like +has been removed. It is more flexible at the cost of having a more +``relaxed'' error checking. +\end{itemize} +\subsection{Bug fixes} + +\begin{itemize} +\item Star values (eg, \verb|leftmargin=*|) could not be overriden +and new values were ignored. +\item \verb|nolistsep| as the first of several keys was not always +recognized and therefore treated like a short label +(i.e., \verb|nol\roman*stsep|). +\item \verb|labelwidth| did not always work (when there was a prior +\verb|widest| and \verb|*|) +\item With \verb|align=right| the label and the following text could +overlap. +\item \verb|description| did not get the correct list level. +\item At some point (2.x?) \verb|\value*| stopped working. +\item (3.1) Unfortunately, \textsf{xkeyval} ``kills'' +\textsf{keyval}, so the lattest has been replicated in +\textsf{enumitem}. +\item (3.3) Fixes a serious bug -- with \verb|*| neither +\verb|itemize| nor \verb|description| worked. +\end{itemize} \subsection{Acknowledgements} I wish to thank particularly the comments and suggestions from Lars -Madsen, which has found some bugs, too. +Madsen, who has found some bugs, too. \end{document} diff --git a/Master/texmf-dist/tex/latex/enumitem/enumitem.sty b/Master/texmf-dist/tex/latex/enumitem/enumitem.sty index d008eee65be..60b70dbc59e 100644 --- a/Master/texmf-dist/tex/latex/enumitem/enumitem.sty +++ b/Master/texmf-dist/tex/latex/enumitem/enumitem.sty @@ -2,10 +2,10 @@ % | Typeset enumitem.tex to get the documentation. | % +--------------------------------------------------+ % -% Copyright (c) 2003-2009 by Javier Bezos. +% Copyright (c) 2003-2011 by Javier Bezos. % All Rights Reserved. % -% This file is part of the enumitem distribution release 2.2 +% This file is part of the enumitem distribution release 3.3 % ----------------------------------------------------------- % % It may be distributed and/or modified under the @@ -24,215 +24,566 @@ % ~~~~~ % % The tag enit@ is used through the style - -% Tasks: -% -runin -% -ref*, for adding stuff in the same fashion as label* +% +% To do: +% ~~~~~~ +% - ref*, for adding stuff in the same fashion as label* +% - option ams, to force upshape, but I have to investigate +% how to do it. +% - labelled descriptions (ie, label, title, body) +% - A true nextline (far from trivial and perhaps solved with +% labelled descriptions). +% - Improved \AddEnumerateCounter +% - Compatibility with interfaces and zref-enumitem +% - "Pausing" somehow inline boxed text. +% - \@enumctr <-> \@listctr? % % Release % ~~~~~~~ \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{enumitem}[2009/05/18 v2.2 Customized lists] +\ProvidesPackage{enumitem}[2011/07/14 v3.3 Customized lists] -% The package uses a token register very often. To be on the -% safe side, instead of \toks@, etc., a new one is declared: +% +=============================+ +% | EMULATING KEYVAL | +% +=============================+ +% +% "Thanks" to xkeyval, which use the same macros names as +% keyval :-(, the latter has to be replicated in full here +% to ensure it works as intended. The original work if by +% David Carlisle, under license LPPL. Once the code is here, +% it could be optimized by adpting it to the specific needs +% of titlesec (to do). + +\def\enitkv@setkeys#1#2{% + \def\enitkv@prefix{enitkv@#1@}% + \let\@tempc\relax + \enitkv@do#2,\relax,} + +\def\enitkv@do#1,{% + \ifx\relax#1\empty\else + \enitkv@split#1==\relax + \expandafter\enitkv@do\fi} + +\def\enitkv@split#1=#2=#3\relax{% + \enitkv@@sp@def\@tempa{#1}% + \ifx\@tempa\@empty\else + \expandafter\let\expandafter\@tempc + \csname\enitkv@prefix\@tempa\endcsname + \ifx\@tempc\relax + \enitkv@errx{\@tempa\space undefined}% + \else + \ifx\@empty#3\@empty + \enitkv@default + \else + \enitkv@@sp@def\@tempb{#2}% + \expandafter\@tempc\expandafter{\@tempb}\relax + \fi + \fi + \fi} -\newtoks\enit@toks +\def\enitkv@default{% + \expandafter\let\expandafter\@tempb + \csname\enitkv@prefix\@tempa @default\endcsname + \ifx\@tempb\relax + \enitkv@err{No value specified for \@tempa}% + \else + \@tempb\relax + \fi} -\@ifundefined{define@key}{\RequirePackage{keyval}}{}% +\def\enitkv@errx#1{\PackageError{enumitem}{#1}\@ehc} -\newlength{\labelindent} +\let\enitkv@err\enitkv@errx -% Vertical spacing +\def\@tempa#1{% + \def\enitkv@@sp@def##1##2{% + \futurelet\enitkv@tempa\enitkv@@sp@d##2\@nil\@nil#1\@nil\relax##1}% + \def\enitkv@@sp@d{% + \ifx\enitkv@tempa\@sptoken + \expandafter\enitkv@@sp@b + \else + \expandafter\enitkv@@sp@b\expandafter#1% + \fi}% + \def\enitkv@@sp@b#1##1 \@nil{\enitkv@@sp@c##1}} -\define@key{enumitem}{topsep}{% - \setlength{\topsep}{#1}} +\@tempa{ } -\define@key{enumitem}{itemsep}{% - \setlength{\itemsep}{#1}} +\def\enitkv@@sp@c#1\@nil#2\relax#3{\enitkv@toks@{#1}\edef#3{\the\enitkv@toks@}} -\define@key{enumitem}{parsep}{% - \setlength{\parsep}{#1}} +\@ifundefined{KV@toks@} + {\newtoks\enitkv@toks@} + {\let\enitkv@toks@\KV@toks@} -\define@key{enumitem}{partopsep}{% - \setlength{\partopsep}{#1}} +\def\enitkv@key#1#2{% + \@ifnextchar[{\enitkv@def{#1}{#2}}{\@namedef{enitkv@#1@#2}####1}} -% Horizontal spacing +\def\enitkv@def#1#2[#3]{% + \@namedef{enitkv@#1@#2@default\expandafter}\expandafter + {\csname enitkv@#1@#2\endcsname{#3}}% + \@namedef{enitkv@#1@#2}##1} -\define@key{enumitem}{itemindent}{% - \setlength{\itemindent}{#1}} +% +=============================+ +% | DEFINITIONS | +% +=============================+ +% +% (1) The package uses a token register very often. To be on the +% safe side, instead of \toks@, etc., a new one is declared. +% (2) \enit@inbox is the box storing the items in boxed inline +% lists. +% (3) \enit@outerparindent is used to save the outer parindent +% so that it can be used in the key parindent +% (4) \enit@type has three values: 0 = enum, 1 = item, 2 = desc. +% (5) \enit@calc stores which dimen is to be computed: +% 0=labelindent, 1=labelwidth, 2=labelsep, 3=leftmargin, +% 4=itemindent +% (6) \enit@resuming has four values: 0 = none, 1 = series, +% 2 = resume* series (computed in group enumitem-resume), +% 3 = resume* list (ie, with no value). + +\chardef \enit@iv=4 +\newlength\labelindent +\newdimen \enit@outerparindent +\newtoks \enit@toks +\newbox \enit@inbox + +\newif\ifenit@boxmode +\newif\ifenit@sepfrommargin +\newif\ifenit@lblfrommargin +\newif\ifenit@calcwidest +\newif\ifenit@nextline +\newif\ifenit@boxdesc + +% An alias (calc-savvy): + +\let\c@enit@cnt\@tempcnta + +\def\enit@meaning{\expandafter\strip@prefix\meaning} +\def\enit@noexcs#1{\expandafter\noexpand\csname#1\endcsname} + +% Miscelaneous errors +% =================== + +\def\enit@checkerror#1#2{% + \PackageError{enumitem}% + {Unknown value `#2' for key `#1'}% + {See the manual for valid values}} -\define@key{enumitem}{listparindent}{% - \setlength{\listparindent}{#1}} +\def\enit@itemerror{% + \PackageError{enumitem}% + {Misplaced \string\item}% + {Either there is some text before the first\MessageBreak + item or the last item has no text}} -\define@key{enumitem}{labelwidth}{% - \setlength{\labelwidth}{#1}} +\def\enit@noserieserror#1{% + \PackageError{enumitem}% + {Series `#1' not started}% + {You are trying to continue a series\MessageBreak + which has not been started with series}} + +\def\enit@checkseries#1{% + \ifcase\enit@resuming + \PackageError{enumitem}% + {Misplaced key `#1'}% + {`series' and `resume*' must be used\MessageBreak + in the optional argument of lists}% + \fi} -\define@key{enumitem}{labelindent}{% - \setlength{\labelindent}{#1}} +\def\enit@checkseries@m{% + \ifcase\enit@resuming\else + \PackageError{enumitem}% + {Uncompatible series settings}% + {`series' and `resume*' must not be used\MessageBreak + at the same time}% + \fi} -\define@key{enumitem}{rightmargin}{% - \setlength{\rightmargin}{#1}} +\let\enit@toodeep\@toodeep -\define@key{enumitem}{leftmargin}{% - \if*#1% - \def\enit@calcleft{% - \enit@calclabel - \leftmargin\labelwidth - \advance\leftmargin\labelsep - \advance\leftmargin\labelindent - \advance\labelindent-\itemindent}% +\def\@toodeep{% + \ifnum\@listdepth>\enit@listdepth\relax + \enit@toodeep \else - \setlength{\leftmargin}{#1}% + \count@\@listdepth + \global\advance\@listdepth\@ne + \@ifundefined{@list\romannumeral\the\@listdepth}% + {\expandafter\let + \csname @list\romannumeral\the\@listdepth\expandafter\endcsname + \csname @list\romannumeral\the\count@\endcsname}{}% \fi} -\define@key{enumitem}{labelsep}{% - \if*#1% - \def\enit@calcleft{% - \advance\labelindent-\itemindent - \enit@calclabel - \labelsep\leftmargin - \advance\labelsep-\labelwidth - \advance\labelsep-\labelindent}% + +% +=============================+ +% | KEYS | +% +=============================+ +% +% Including code executed by keys. +% +% There are 2 keyval groups: enumitem, and enumitem-delayed. +% The latter is used to make sure a prioritary key is the +% latest one; eg, ref, so that the ref format set by label +% is overriden. So, when this key is found in enumitem, +% nothing is done, except the key/value is moved to +% enumitem-delayed. +% +% A further group (enumitem-resume) catches resume* and +% series in optional arguments in lists. +% +% Vertical spacing +% ================ + +\enitkv@key{enumitem}{topsep}{% + \setlength\topsep{#1}} + +\enitkv@key{enumitem}{itemsep}{% + \setlength\itemsep{#1}} + +\enitkv@key{enumitem}{parsep}{% + \setlength\parsep{#1}} + +\enitkv@key{enumitem}{partopsep}{% + \setlength\partopsep{#1}} + +% Horizontal spacing +% ================== +% +% There are 3 cases: *, ! and a value. The latter also +% cancels widest with the sequence key=* ... key=value +% \string is used, just in case some package changes the +% catcodes. + +\def\enit@calcset#1#2#3{% + \if\string*\string#3% + \enit@calcwidesttrue + \let\enit@calc#2% + \else\if\string!\string#3% + \enit@calcwidestfalse + \let\enit@calc#2% \else - \setlength{\labelsep}{#1}% + \ifnum\enit@calc=#2% + \enit@calcwidestfalse + \let\enit@calc\z@ + \fi + \setlength#1{#3}% + \fi\fi} + +\def\enitkv@enumitem@widest#1{% + \expandafter\let\csname enit@cw@\@enumctr\endcsname\relax + \@namedef{enit@widest@\@enumctr}##1{#1}} + +\def\enitkv@enumitem@widest@default{% + \expandafter\let\csname enit@cw@\@enumctr\endcsname\relax + \expandafter\let\csname enit@widest@\@enumctr\endcsname\relax} + +\enitkv@key{enumitem}{widest*}{% + \setcounter{enit@cnt}{#1}% + \expandafter\edef\csname enit@cw@\@enumctr\endcsname + {\the\c@enit@cnt}% + \expandafter\edef\csname enit@widest@\@enumctr\endcsname##1% + {##1{\the\c@enit@cnt}}} + +\enitkv@key{enumitem}{labelindent*}{% + \enit@lblfrommargintrue + \ifnum\enit@calc=\z@ + \enit@calcwidestfalse + \fi + \setlength\labelindent{#1}% + \advance\labelindent\leftmargin} + +\enitkv@key{enumitem}{labelindent}{% + \enit@lblfrommarginfalse + \enit@calcset\labelindent\z@{#1}} + +\enitkv@key{enumitem}{labelwidth}{% + \enit@calcset\labelwidth\@ne{#1}} + +\enitkv@key{enumitem}{leftmargin}{% + \edef\enit@c{\the\leftmargin}% + \enit@calcset\leftmargin\thr@@{#1}% + \ifenit@lblfrommargin + \advance\labelindent-\enit@c\relax + \advance\labelindent\leftmargin \fi} -\define@key{enumitem}{widest}{% - \expandafter\def - \csname enit@widest\@enumctr\endcsname{#1}} +\enitkv@key{enumitem}{itemindent}{% + \edef\enit@c{\the\itemindent}% + \enit@calcset\itemindent\enit@iv{#1}% + \ifenit@sepfrommargin + \advance\labelsep-\enit@c\relax + \advance\labelsep\itemindent + \fi} -\def\enit@calclabel{% - \begingroup - \enit@calcdefs - \settowidth\labelwidth{\@itemlabel}% - \xdef\enit@a{\labelwidth\the\labelwidth\relax}% - \endgroup - \enit@a} +\enitkv@key{enumitem}{listparindent}{% + \setlength\listparindent{#1}} -\let\enit@calcdefs\@empty +\enitkv@key{enumitem}{rightmargin}{% + \setlength\rightmargin{#1}} -% Used below to gobble \c@ from the internal representation -% of counters. +% labelsep, from itemindent; labelsep*, from leftmargin -\def\@gobblethree#1#2#3{} +\enitkv@key{enumitem}{labelsep*}{% + \enit@sepfrommargintrue + \ifnum\enit@calc=\tw@ + \enit@calcwidestfalse + \let\enit@calc\z@ + \fi + \setlength\labelsep{#1}% + \advance\labelsep\itemindent} -\def\enit@calcdef#1#2#3{% - \let#2#1% - \def#1##1{% - \@ifundefined{enit@widest\expandafter\@gobblethree\string##1}% if no widest key - {#3}% - {\csname enit@widest\expandafter\@gobblethree\string##1\endcsname}}} +\enitkv@key{enumitem}{labelsep}{% + \enit@sepfrommarginfalse + \enit@calcset\labelsep\tw@{#1}} -% Resume and start +% Series, resume and start +% ======================== -\define@key{enumitem}{resume}[]{% - \@nameuse{enit@resume@\@currenvir}\relax} +\enitkv@key{enumitem-resume}{series}{% + \enit@checkseries@m + \let\enit@resuming\@ne + \@ifundefined{enitkv@enumitem@#1}{}% + {\PackageError{enumitem}% + {Invalid series name `#1'}% + {Do not name a series with an existing key}}% + \def\enit@series{#1}} -\define@key{enumitem}{start}[\@ne]{% - \csname c@\@listctr\endcsname#1\relax - \advance\csname c@\@listctr\endcsname\m@ne} +\enitkv@key{enumitem}{series}{% + \enit@checkseries{series}} -\define@key{enumitem}{resume*}[]{% - \PackageError{enumitem}% - {Invalid resume* ignored}% - {resume* has to be the only key in the optional argument}% +\def\enitkv@enumitem@resume#1{% + \edef\enit@series{#1}% + \@nameuse{enit@resume@series@#1}\relax} + +\def\enitkv@enumitem@resume@default{% \@nameuse{enit@resume@\@currenvir}\relax} -% How the label is aligned - -\def\enit@alignleft{% - \def\makelabel##1{\rlap{\enit@format##1}\hss}} +\@namedef{enitkv@enumitem-resume@resume*}#1{% + \enit@checkseries@m + \let\enit@resuming\tw@ + \edef\enit@series{#1}% + \@ifundefined{enit@resumekeys@series@#1}% + {\enit@noserieserror{#1}}% + {\expandafter\let\expandafter\enit@resumekeys + \csname enit@resumekeys@series@#1\endcsname}} + +\@namedef{enitkv@enumitem-resume@resume*@default}{% + \let\enit@resuming\thr@@ + \expandafter\let\expandafter\enit@resumekeys + \csname enit@resumekeys@\@currenvir\endcsname + \@nameuse{enit@resume@\@currenvir}\relax} -\define@key{enumitem}{align}{% - \csname enit@align#1\endcsname} +\enitkv@key{enumitem}{resume*}[]{% + \enit@checkseries{resume*}} + +\newcommand\restartlist[1]{% + \@ifundefined{end#1}% + {\PackageError{enumitem}% + {Undefined list `#1'}% + {No list has been defined with that name.}}% + {\expandafter\let + \csname enit@resume@#1\endcsname\@empty}} + +\enitkv@key{enumitem}{start}[\@ne]{% + \setcounter{\@listctr}{#1}% + \advance\@nameuse{c@\@listctr}\m@ne} % Penalties +% ========= -\define@key{enumitem}{beginpenalty}{% +\enitkv@key{enumitem}{beginpenalty}{% \@beginparpenalty#1\relax} -\define@key{enumitem}{midpenalty}{% +\enitkv@key{enumitem}{midpenalty}{% \@itempenalty#1\relax} -\define@key{enumitem}{endpenalty}{% +\enitkv@key{enumitem}{endpenalty}{% \@endparpenalty#1\relax} -% Font +% Font/Format +% =========== + +\enitkv@key{enumitem}{format}{% + \def\enit@format{#1}} -\define@key{enumitem}{font}[]{% +\enitkv@key{enumitem}{font}{% \def\enit@format{#1}} -% description specific keys +% Description styles +% ================== + +\enitkv@key{enumitem}{style}[normal]{% + \@ifundefined{enit@style@#1}% + {\enit@checkerror{style}{#1}}% + {\enit@nextlinefalse + \enit@boxdescfalse + \@nameuse{enit@style@#1}% + \edef\enit@descstyle{\enit@noexcs{enit@#1style}}}} + +\def\enit@style@standard{% + \enit@boxdesctrue + \enit@calcset\itemindent\enit@iv!} -\define@key{enumitem}{style}[normal]{% - \edef\enit@descstyle{% - \expandafter\noexpand\csname enit@#1style\endcsname}} +\let\enit@style@normal\enit@style@standard -\let\enit@normalstyle\@firstofone +\def\enit@style@unboxed{% + \enit@calcset\itemindent\enit@iv!} + +\def\enit@style@sameline{% + \enit@calcset\labelwidth\@ne!} + +\def\enit@style@multiline{% + \enit@align@parleft + \enit@calcset\labelwidth\@ne!} + +\def\enit@style@nextline{% + \enit@nextlinetrue + \enit@calcset\labelwidth\@ne!} % Labels and refs +% =============== + +% Aligment +% -------- + +\enitkv@key{enumitem}{align}{% + \@ifundefined{enit@align@#1}% + {\enit@checkerror{align}{#1}}% + {\csname enit@align@#1\endcsname}} -\define@key{enumitem}{label}{% - \@nameuse{enit@set\enit@type label}{#1}} +% \nobreak for unboxed label with color. See below. -\define@key{enumitem}{label*}{% +\newcommand\SetLabelAlign[2]{% + \enit@toks{#2}% + \expandafter\edef\csname enit@align@#1\endcsname + {\def\noexpand\enit@align####1{\nobreak\the\enit@toks}}} + +\def\enit@align@right{% + \def\enit@align##1{\nobreak\hss\llap{##1}}} + +\def\enit@align@left{% + \def\enit@align##1{\nobreak##1\hfil}} + +\def\enit@align@parleft{% + \def\enit@align##1{% + \nobreak + \strut\smash{\parbox[t]\labelwidth{\raggedright##1}}}} + +% \enit@ref has three possible definitions: +% (1) \relax, if there is neither label nor ref (ie, use +% LaTeX settings). +% (2) set ref to @itemlabel, if there is label but not ref +% (3) set ref to ref, if there is ref (with or without label) + +\enitkv@key{enumitem}{label}{% + \expandafter\def\@itemlabel{#1}% + \def\enit@ref{\expandafter\enit@reflabel\@itemlabel\z@}} + +\enitkv@key{enumitem}{label*}{% \ifnum\enit@depth=\@ne - \@nameuse{enit@set\enit@type label}{#1}% + \expandafter\def\@itemlabel{#1}% \else % no level 0 \advance\enit@depth\m@ne \enit@toks{#1}% - \edef\enit@a{% - \noexpand\@nameuse{enit@set\enit@type label}{% - \expandafter\noexpand\csname label\enit@prevlabel\endcsname - \the\enit@toks}}% - \enit@a + \expandafter\edef\@itemlabel{% + \enit@noexcs{label\enit@prevlabel}% + \the\enit@toks}% \advance\enit@depth\@ne - \fi} + \fi + \def\enit@ref{\expandafter\enit@reflabel\@itemlabel\z@}} -\def\enit@setenumlabel#1{% - \enit@normlabel{#1}% Returns \enit@a - \expandafter\let\@itemlabel\enit@a -%ie, redefine \labelenumX or \labelitemX. - \ifx\enit@ref\relax\expandafter\enit@reflabel\enit@a\z@\fi} -%ie, only if there is not a previous ref= +% ref is set by label, except if there is an explicit ref +% in the same hierarchy level. Explicit refs above the +% current hierarchy level are overriden by label (besides ref), +% too. Since an explicit ref has preference, it's delayed. + +\enitkv@key{enumitem}{ref}{% + \g@addto@macro\enit@delayedkeys{,ref=#1}} -\def\enit@setitemlabel#1{% - \expandafter\def\@itemlabel{#1}% - \def\enit@a{#1}% - \ifx\enit@ref\relax\enit@reflabel{#1}\z@\fi} +\enitkv@key{enumitem-delayed}{ref}{% + \def\enit@ref{\enit@reflabel{#1}\@ne}} -\let\enit@setdesclabel\enit@setitemlabel - -\define@key{enumitem}{ref}{% - \enit@reflabel{#1}\@ne} +% #2=0 don't "normalize" (ie, already normalized) +% =1 "normalize" (in key ref) +% Used thru \enit@ref -%\expandafter\def\csname c@*\endcsname{\csname c@\@enumctr\endcsname} +\def\enit@reflabel#1#2{% + \ifnum\enit@depth=\@ne\else % no level 0 + \advance\enit@depth\@ne + \@namedef{p@\@enumctr}{}% Don't accumulate labels + \advance\enit@depth\m@ne + \fi + \ifcase#2% + \@namedef{the\@enumctr}{{#1}}% + \else + \enit@normlabel{\csname the\@enumctr\endcsname}{#1}% + \fi} -\newcommand\AddEnumerateCounter[3]{% - \g@addto@macro\enit@labellist{\enit@refstar#1\enit@refstar#2}% - \enit@toks\expandafter{\enit@calcdefs}% - \edef\enit@calcdefs{% - \the\enit@toks - \noexpand\enit@calcdef - \noexpand#2% - \expandafter\noexpand\csname enit@\string#1\endcsname - {#3}}} +% \xxx* in counters (refstar) and widest (calcdef) +% ------------------------------------------------ +% \enit@labellist contains a list of +% \enit@elt{widest}\count\@count\enit@sc@@count +% \enit@elt is either \enit@getwidth or \enit@refstar, defined +% below +% The current implementation is sub-optimal -- labels are stored in +% labellist, counters defined again when processing labels, and +% modifying it is almost impossible. \let\enit@labellist\@empty -\AddEnumerateCounter{\arabic}{\@arabic}{0} -\AddEnumerateCounter{\alph}{\@alph}{m} -\AddEnumerateCounter{\Alph}{\@Alph}{M} -\AddEnumerateCounter{\roman}{\@roman}{viii} -\AddEnumerateCounter{\Roman}{\@Roman}{VIII} +\newcommand\AddEnumerateCounter{% + \@ifstar\enit@addcounter@s\enit@addcounter} + +\def\enit@addcounter#1#2#3{% + \enit@toks\expandafter{% + \enit@labellist + \enit@elt{#3}}% + \edef\enit@labellist{% + \the\enit@toks + \enit@noexcs{\expandafter\@gobble\string#1}% + \enit@noexcs{\expandafter\@gobble\string#2}% + \enit@noexcs{enit@sc@\expandafter\@gobble\string#2}}} + +\def\enit@addcounter@s#1#2#3{% + \enit@addcounter{#1}{#2}% + {\@nameuse{enit@sc@\expandafter\@gobble\string#2}{#3}}} + +% The 5 basic counters: + +\AddEnumerateCounter\arabic\@arabic{0} +\AddEnumerateCounter\alph\@alph{m} +\AddEnumerateCounter\Alph\@Alph{M} +\AddEnumerateCounter\roman\@roman{viii} +\AddEnumerateCounter\Roman\@Roman{VIII} + +% Inline lists +% ============ +% +% Labels +% ------ + +\enitkv@key{enumitem}{itemjoin}{% + \def\enit@itemjoin{#1}} + +\enitkv@key{enumitem}{itemjoin*}{% + \def\enit@itemjoin@s{#1}} + +\enitkv@key{enumitem}{afterlabel}{% + \def\enit@afterlabel{#1}} + +% Mode +% ---- + +\enitkv@key{enumitem}{mode}{% + \@ifundefined{enit@mode#1}% + {\enit@checkerror{mode}{#1}}% + {\csname enit@mode#1\endcsname}} + +\let\enit@modeboxed\enit@boxmodetrue +\let\enit@modeunboxed\enit@boxmodefalse % Short Labels +% ============ \let\enit@marklist\@empty -% shorthand, expansion +% shorthand, expansion: \newcommand\SetEnumerateShortLabel[2]{% \let\enit@a\@empty @@ -255,6 +606,37 @@ \SetEnumerateShortLabel{I}{\Roman*} \SetEnumerateShortLabel{1}{\arabic*} +% This is called \enit@first one,two,three,\@nil\@@nil. If there +% are just one element #2 is \@nil, otherwise we have to remove +% the trailing ,\@nil with enit@first@x +% Called with the keys in \enit@c +% Returns enit@toks + +\def\enit@first#1,#2\@@nil{% + \in@{=}{#1}% Quick test, if contains =, it's key=value + \ifin@\else + \def\enit@a{#1}% + \@ifundefined{enitkv@enumitem@\enit@meaning\enit@a}% + {\ifnum\enit@type=\z@ + \def\enit@elt{\enit@replace\enit@a}% + \enit@marklist % Returns \enit@toks + \else + \enit@toks{#1}% + \fi + \ifx\@nil#2% + \ifx,#1,\else + \edef\enit@c{label=\the\enit@toks}% + \fi + \else + \@temptokena\expandafter{\enit@first@x#2}% + \edef\enit@c{label=\the\enit@toks,\the\@temptokena}% + \fi}% + {}% + \fi + \enit@toks\expandafter{\enit@c}} + +\def\enit@first@x#1,\@nil{#1} + \def\enit@replace#1#2#3{% \enit@toks{}% \def\enit@b##1#2##2\@@nil{% @@ -272,265 +654,637 @@ \expandafter\enit@b#1#2\@nil\@@nil \edef#1{\the\enit@toks}} -% ¿Se podría dar una variante para ref? +% Pre and post code +% ================= -\def\enit@first@x#1,\@nil{#1} +\enitkv@key{enumitem}{before}{% + \def\enit@before{#1}} -% This is called \enit@first one,two,three,\@nil\@@nil. If there -% are just one element #2 is \@nil, otherwise we have to remove -% the trailing ,\@nil with enit@first@x -% Returns toks@ +\enitkv@key{enumitem}{after}{% + \def\enit@after{#1}} -\def\enit@first#1,#2\@@nil{% - \in@{=}{#1}% - \ifin@\else - \def\enit@c{#1}% - \@ifundefined{KV@enumitem@\expandafter\strip@prefix\meaning\enit@c}{% - \def\enit@elt{\enit@replace\enit@c}% - \enit@marklist % Returns \enit@toks - \ifx\@nil#2% - \ifx,#1,\else - \edef\enit@c{label=\the\enit@toks}% - \fi - \else - \@temptokena\expandafter{\enit@first@x#2}% - \edef\enit@c{label=\the\enit@toks,\the\@temptokena}% - \fi}{}% - \fi - \enit@toks\expandafter{\enit@c}} +\enitkv@key{enumitem}{before*}{% + \expandafter\def\expandafter\enit@before\expandafter + {\enit@before#1}} -\let\enit@shl@enum\enit@toks -\let\enit@shl@item\enit@toks -\let\enit@shl@desc\enit@toks +\enitkv@key{enumitem}{after*}{% + \expandafter\def\expandafter\enit@after\expandafter + {\enit@after#1}} -% Labels +% Miscelaneous keys +% ================ + +\enitkv@key{enumitem}{nolistsep}[true]{% + \partopsep=\z@skip + \topsep=\z@ plus .1pt + \itemsep=\z@skip + \parsep=\z@skip} -\def\enit@normlabel#1{% - \begingroup - \enit@labellist - \protected@xdef\enit@a{{#1}}% Added braces as \ref is in the - \endgroup} % global scope. +\enitkv@key{enumitem}{noitemsep}[true]{% + \itemsep=\z@skip + \parsep=\z@skip} -% #2=0 don't "normalize", =1 "normalize" +\enitkv@key{enumitem}{wide}[\parindent]{% + \enit@align@left + \leftmargin\z@ + \labelwidth\z@ + \setlength\labelindent{#1}% + \listparindent\labelindent + \enit@calcset\itemindent\enit@iv!} -\def\enit@reflabel#1#2{% - \def\enit@ref{% - \ifnum\enit@depth=\@ne\else % no level 0 - \advance\enit@depth\@ne - \@namedef{p@\@enumctr}{}% Don't accumulate labels - \advance\enit@depth\m@ne - \fi - \ifcase#2% - \def\enit@a{{#1}}% - \else - \enit@normlabel{#1}% Returns \enit@a - \fi - \expandafter - \let\csname the\@enumctr\endcsname\enit@a}} +% The following is deprecated in favour of wide: -\def\enit@refstar#1{% - \def#1##1{% - \if*##1\@empty - \noexpand#1{\@enumctr}% - \else - \noexpand#1{##1}% - \fi}} +\enitkv@key{enumitem}{fullwidth}[true]{% + \leftmargin\z@ + \labelwidth\z@ + \def\enit@align##1{\hskip\labelsep##1}} + +% "Abstract" layer +% ================ +% +% Named values +% ------------ + +\newcommand\SetEnumitemValue[2]{% Implicit #3 + \@ifundefined{enit@enitkv@#1}% + {\@ifundefined{enitkv@enumitem@#1}% + {\PackageError{enumitem}% + {Wrong key `#1' in \string\SetEnumitemValue}% + {Perhaps you have misspelled it}}{}% + \expandafter\let\csname enit@enitkv@#1\expandafter\endcsname + \csname enitkv@enumitem@#1\endcsname}{}% + \@namedef{enitkv@enumitem@#1}##1{% + \def\enit@a{##1}% + \@ifundefined{enit@enitkv@#1@\enit@meaning\enit@a}% + {\@nameuse{enit@enitkv@#1}{##1}}% + {\@nameuse{enit@enitkv@#1\expandafter\expandafter\expandafter}% + \expandafter\expandafter\expandafter + {\csname enit@enitkv@#1@##1\endcsname}}{}}% + \@namedef{enit@enitkv@#1@#2}} + +% Defining keys +% ------------- + +\newcommand\SetEnumitemKey[2]{% + \@ifundefined{enitkv@enumitem@#1}% + {\enitkv@key{enumitem}{#1}[]{\enitkv@setkeys{enumitem}{#2}}}% + {\PackageError{enumitem}% + {Duplicated key `#1' in \string\SetEnumitemKey}% + {There already existsa key with that name}}} + +% +=============================+ +% | PROCESSING KEYS | +% +=============================+ +% +% Set keys +% ======== \def\enit@setkeys#1{% - \@ifundefined{#1}{}% + \@ifundefined{enit@@#1}{}% {\expandafter\expandafter\expandafter - \enit@setkeys@i\csname#1\endcsname\@@}} + \enit@setkeys@i\csname enit@@#1\endcsname\@@}} + +% The following is used directly in resumeset: \def\enit@setkeys@i#1\@@{% - \@nameuse{enit@shl@\enit@type}{#1}% + \let\enit@delayedkeys\@empty + \enit@shl{#1}% is or returns \enit@toks \expandafter\enit@setkeys@ii\the\enit@toks\@@} \def\enit@setkeys@ii#1\@@{% - \setkeys{enumitem}{#1}% - \ifx\enit@ref\relax\else % Not a logical place, grrr - \let\enit@saveref\enit@ref - \let\enit@ref\relax + \enitkv@setkeys{enumitem}{#1}% + \enit@toks\expandafter{\enit@delayedkeys}% + \edef\enit@a{% + \noexpand\enitkv@setkeys{enumitem-delayed}{\the\enit@toks}}% + \enit@a} + +% Handling * and ! values +% ======================= +% +% \@gobbletwo removes \c from \c@counter. + +\def\enit@getwidth#1#2#3#4{% + \let#4#3% + \def#3##1{% + \@ifundefined{enit@widest\expandafter\@gobbletwo\string##1}% if no widest=key + {#1}% + {\csname enit@widest\expandafter\@gobbletwo\string##1\endcsname{#4}}}} + +\def\enit@valueerror#1{\z@ % if after an assignment, but doesn't catch \ifnum + \PackageError{enumitem}% + {No default \string\value\space for `#1'}% + {You can provide one with widest*}}% + +\let\enit@values\@empty + +\def\enit@calcwidth{% + \ifenit@calcwidest + \ifnum\enit@type=\z@ % ie, enum + \@ifundefined{enit@cw@\@enumctr}% + {\@namedef{enit@cv@\@enumctr}{\enit@valueerror\@enumctr}}% + {\edef\enit@values{% + \enit@values + \@nameuse{c@\@enumctr}\@nameuse{enit@cw@\@enumctr}\relax}% + \expandafter + \edef\csname enit@cv@\@enumctr\endcsname + {\@nameuse{c@\@enumctr}}}% + \fi + \begingroup + \enit@values + \def\value##1{\csname enit@cv@##1\endcsname}% + \let\enit@elt\enit@getwidth + \enit@labellist + \settowidth\labelwidth{\@itemlabel}% + \xdef\enit@a{\labelwidth\the\labelwidth\relax}% + \endgroup + \enit@a + \fi + \advance\dimen@-\labelwidth} + +\def\enit@calcleft{% + \dimen@\leftmargin + \advance\dimen@\itemindent + \advance\dimen@-\labelsep + \advance\dimen@-\labelindent + \ifcase\enit@calc % = 0 = labelindent + \enit@calcwidth + \advance\labelindent\dimen@ + \or % = 1 = labelwidth, so no \enit@calcwidth + \labelwidth\dimen@ + \or % = 2 = labelsep + \enit@calcwidth + \advance\labelsep\dimen@ + \or % = 3 = leftmargin + \enit@calcwidth + \advance\leftmargin-\dimen@ + \or % = 4 =itemindent + \enit@calcwidth + \advance\itemindent-\dimen@ \fi} -% pre y post code +% "Normalizing" labels +% ==================== +% +% Replaces \counter* by \counter{level} (those in \enit@labellist). +% +% #1 is either \csname...\endcsmame or the container \@itemlabel -- +% hence \expandafter -\define@key{enumitem}{before}[1]{% - \def\enit@before{#1}} +\def\enit@refstar@i#1#2{% + \if*#2\@empty + \noexpand#1{\@enumctr}% + \else + \noexpand#1{#2}% + \fi}% -\define@key{enumitem}{after}[1]{% - \def\enit@after{#1}} +\def\enit@refstar#1#2#3#4{% + \def#2{\enit@refstar@i#2}% + \def#3{\enit@refstar@i#3}} -\define@key{enumitem}{before*}[1]{% - \expandafter\def\expandafter\enit@before\expandafter - {\enit@before#1}} +\def\enit@normlabel#1#2{% + \begingroup + \def\value{\enit@refstar@i\value}% + \let\enit@elt\enit@refstar + \enit@labellist + \protected@xdef\enit@a{{#2}}% Added braces as \ref is in the + \endgroup + \expandafter\let#1\enit@a} % global scope. -\define@key{enumitem}{after*}[1]{% - \expandafter\def\expandafter\enit@after\expandafter - {\enit@after#1}} +% Preliminary settings and default values +% ======================================= -% And now, the three environments are redefined. -% First, code shared by enumerate and itemize. - -\newdimen\enit@outerparindent +\def\enit@prelist#1#2#3{% + \let\enit@type#1% + \def\enit@depth{#2}% + \edef\enit@prevlabel{#3\romannumeral#2}% + \advance#2\@ne} -\def\enit@preset{% - \def\makelabel##1{\hss\llap{\enit@format##1}}% +\def\enit@preset#1#2#3{% + \enit@sepfrommarginfalse + \enit@calcwidestfalse + \let\enit@resuming\z@ + \let\enit@series\relax + \enit@boxmodetrue + \def\enit@itemjoin{ }% + \let\enit@itemjoin@s\relax + \let\enit@afterlabel\nobreakspace \let\enit@before\@empty \let\enit@after\@empty - \let\enit@format\@empty - \let\enit@calcleft\relax - \let\enit@widest\@empty + \let\enit@format\@firstofone % and NOT empty + \let\enit@ref\relax \labelindent\z@skip \ifnum\@listdepth=\@ne \enit@outerparindent\parindent \else \parindent\enit@outerparindent \fi - \enit@setkeys{enit@@list}% - \enit@setkeys{enit@@list\romannumeral\@listdepth}} - -\def\enit@resumeset#1#2{% - \def\enit@a{resume*}% - \def\enit@b{#2}% - \ifx\enit@a\enit@b - \enit@toks\expandafter\expandafter\expandafter - {\csname enit@savekeys@\@currenvir\endcsname,resume}% - \else - #1{#2}% Returns toks@ + \enit@setkeys{list}% + \enit@setkeys{list\romannumeral\@listdepth}% + \enit@setkeys{#1}% + \enit@setkeys{#1\romannumeral#2}% + \enit@setresume{#3}} + +% keyval "error" in enumitem-resume: all undefined keys (ie, all +% except resume*) are ignored, but is treated like +% resume*= + +\def\enitkv@err@a#1{% + \@ifundefined{enit@resumekeys@series@\@tempa}{}% + {\@nameuse{enitkv@enumitem-resume@resume*\expandafter}% + \expandafter{\@tempa}}} + +% keyval "error" in the optional argument: all undefined keys are +% passed to the keyval error, but is ignored (already +% processed in enumitem-resume + +\def\enitkv@err@b#1{% + \@ifundefined{enit@resumekeys@series@\@tempa}% + {\enit@savekverr{#1}}% + {}} + +% Process keys in optional argument: + +\def\enit@setresume#1{% + \enit@shl{#1}% Returns enit@toks + \edef\enit@savekeys{\the\enit@toks}% + \let\enit@savekverr\enitkv@errx + \let\enitkv@errx\enitkv@err@a + \edef\enit@b{% + \noexpand\enitkv@setkeys{enumitem-resume}{\the\enit@toks}}% + \enit@b + \let\enitkv@errx\enitkv@err@b + \ifcase\enit@resuming\or\or % = 2 + \expandafter + \enit@setkeys@i\enit@resumekeys,resume=\enit@series\@@ + \or % = 3 + \expandafter + \enit@setkeys@i\enit@resumekeys,resume\@@ \fi - \edef\enit@c{% - \def\noexpand\enit@savekeys{\the\enit@toks}% - \noexpand\setkeys{enumitem}{\the\enit@toks}}% - \enit@c} + \expandafter\enit@setkeys@i\enit@savekeys\@@ + \let\enitkv@errx\enit@savekverr} +% +=============================+ +% | LIST TYPES | +% +=============================+ +% +% Displayed lists +% =============== +% #1 #2 implicit + +\def\enit@dylist{% + \enit@align@right + \list} + +\def\enit@endlist{% + \enit@after + \endlist + \ifx\enit@series\relax\else % discards resume*, too + \ifnum\enit@resuming=\@ne % ie, series + \enit@setresumekeys{series@\enit@series}\global\global + \else % ie, resume, resume* (save count, but not keys) + \enit@setresumekeys{series@\enit@series}\@gobblefour\global + \fi + \enit@afterlist + \fi + \enit@setresumekeys\@currenvir\@empty\@empty + \aftergroup\enit@afterlist} + +% #1 = either \@currenvir or series@ +% #2(keys) #3(counter) are \global, \@gobblefour or \@empty + +\def\enit@setresumekeys#1#2#3{% + \enit@toks\expandafter{\enit@savekeys}% + \xdef\enit@afterlist{% + #2\def\enit@noexcs{enit@resumekeys@#1}{\the\enit@toks}% + \ifnum\enit@type=\z@ % ie, enum + #3\def\enit@noexcs{enit@resume@#1}{% + \csname c@\@listctr\endcsname + \the\csname c@\@listctr\endcsname}% + \fi}} + +% Inline lists +% ============ + +% Definition of \@trivlist inside inline lists. So, when +% \@trivlist is found in any displayed list (including quote, +% center, verbatim...) the default \@item is restored. + +\def\enit@intrivlist{% + \enit@changed@itemfalse + \let\@item\enit@outer@item + \let\par\@@par + \let\@trivlist\enit@outer@triv + \@trivlist} + +% Keep track of \@item and \item changes + +\newif\ifenit@changed@item +\enit@changed@itemfalse + +\newif\ifenit@changeditem +\enit@changeditemfalse + +% List +% ---- + +% Arguments, as before: +% \enitdp@, , , +% About @newlist, see @initem. + +\def\enit@inlist#1#2{% + \ifnum\@listdepth>\enit@listdepth\relax + \@toodeep + \else + \global\advance\@listdepth\@ne + \fi + \let\enit@align\@firstofone + \def\@itemlabel{#1}% + \@nmbrlistfalse + \ifenit@changed@item\else + \enit@changed@itemtrue + \let\enit@outer@triv\@trivlist + \let\@trivlist\enit@intrivlist + \@setpar\@empty + \let\enit@outer@item\@item + \fi + #2\relax + \global\@newlisttrue + \ifenit@boxmode + \ifenit@changeditem\else + \let\enit@outeritem\item + \fi + \let\@item\enit@boxitem + \else + \let\@item\enit@noboxitem + \ifx\enit@itemjoin@s\relax\else + \PackageWarning{enumitem}% + {itemjoin* discarded in mode unboxed\MessageBreak}% + \fi + \fi + \let\enit@calcleft\relax + \ifenit@boxmode + \global\setbox\enit@inbox\hbox\bgroup\color@begingroup + \let\item\enit@endinbox + \enit@changeditemtrue + \fi + \ignorespaces} + +\def\enit@endinlist{% + \ifenit@boxmode + \unskip\color@endgroup\egroup + \ifdim\wd\enit@inbox=\z@ + \enit@itemerror + \else + \ifenit@noinitem\else + \@ifundefined{enit@itemjoin@s}% + {\enit@itemjoin}% + {\enit@itemjoin@s}% + \fi + \unhbox\@labels + \enit@afterlabel + \unhbox\enit@inbox + \fi + \else + \unskip + \if@newlist + \enit@itemerror + \fi + \fi + \enit@after + \global\advance\@listdepth\m@ne + \global\@inlabelfalse + \if@newlist + \global\@newlistfalse + \@noitemerr + \fi + \ifx\enit@series\relax\else % discards resume* list, too + \ifnum\enit@resuming=\@ne % ie, series + \enit@setresumekeys{series@\enit@series}\global\global + \else % ie, resume, resume* (save count, but not keys) + \enit@setresumekeys{series@\enit@series}\@gobblefour\global + \fi + \enit@afterlist + \fi + \enit@setresumekeys\@currenvir\@empty\@empty + \aftergroup\enit@afterlist} + +% \@item: unboxed +% --------------- + +\def\enit@noboxitem[#1]{% + \if@newlist + \leavevmode % ships pending labels out + \global\@newlistfalse + \else + \ifhmode + \unskip + \enit@itemjoin + \else + \noindent + \fi + \fi + \if@noitemarg + \@noitemargfalse + \if@nmbrlist + \refstepcounter{\@listctr}% after \unskip (hyperref) + \fi + \fi + \mbox{\makelabel{#1}}% + \enit@afterlabel + \ignorespaces} + +% \@item: boxed +% ------------ +% +% We don't want \item to be executed locally, because it sets a flag +% (and hyperref adds another flag, too). So, we redefine it inside +% the box to \enit@endinbox which ends the box and then use the actual +% (outer) \item. labels are stored in another box, to detect empty +% boxes, ie, misplaced \item's. Note the 2nd \item ends collecting +% the 1st item and ships it out, while the 3rd \item ends collecting +% the 2nd item, puts the itemjoin and then ships the 2nd item out. +% The flag enit@noinitem keeps track of that. + +\newif\ifenit@noinitem + +\def\enit@endinbox{% + \unskip + \color@endgroup + \egroup + \enit@outeritem} + +\def\enit@boxitem[#1]{% + \if@newlist + \global\@newlistfalse + \ifdim\wd\enit@inbox>\z@ + \enit@itemerror + \fi + \enit@noinitemtrue + \leavevmode % ships pending labels out + \else + \ifhmode\unskip\fi + \ifdim\wd\enit@inbox=\z@ + \enit@itemerror + \else + \ifenit@noinitem + \enit@noinitemfalse + \else + \enit@itemjoin + \fi + \unhbox\@labels + \enit@afterlabel + \unhbox\enit@inbox + \fi + \fi + \if@noitemarg + \@noitemargfalse + \if@nmbrlist + \refstepcounter{\@listctr}% + \fi + \fi + \sbox\@labels{\makelabel{#1}}% + \setbox\enit@inbox\hbox\bgroup\color@begingroup + \let\item\enit@endinbox + \hskip1sp % in case the first thing is \label + \ignorespaces} + +% Pause item +% ---------- +% +% To do. +% +% The three types +% =============== +% +% enumerate and enumerate* +% ------------------------ +% % The following has 4 arguments, which in enumerate are: % \@enumdepth, enum, \thr@@, . % In user defined environments they are: % \enitdp@, , , -\def\enit@enumerate#1#2#3#4{% - \def\enit@depth{#1}% - \def\enit@type{enum}% +\def\enit@enumerate{% + \let\enit@list\enit@dylist + \enit@enumerate@i} + +\@namedef{enit@enumerate*}{% + \let\enit@list\enit@inlist + \enit@enumerate@i} + +\def\enit@enumerate@i#1#2#3#4{% \ifnum#1>#3\relax - \@toodeep + \enit@toodeep \else - \edef\enit@prevlabel{#2\romannumeral#1}% - \advance#1\@ne + \enit@prelist\z@{#1}{#2}% \edef\@enumctr{#2\romannumeral#1}% \expandafter - \list + \enit@list \csname label\@enumctr\endcsname {\usecounter\@enumctr - \let\enit@ref\relax - \let\enit@saveref\relax - \enit@normlabel{\@itemlabel}% Returns \enit@a - \expandafter\let\@itemlabel\enit@a - \enit@preset - \enit@setkeys{enit@@#2}% - \enit@setkeys{enit@@\@enumctr}% - \enit@resumeset\enit@shl@enum{#4}% + \let\enit@calc\z@ + \def\makelabel##1{\enit@align{\enit@format{##1}}}% + \enit@preset{#2}{#1}{#4}% + \enit@normlabel\@itemlabel\@itemlabel + \enit@ref \enit@calcleft - \ifx\enit@ref\relax - \enit@saveref - \else - \enit@ref - \fi \enit@before}% \fi} -\def\enit@endenumerate{% - \enit@after - \endlist - \enit@toks\expandafter{\enit@savekeys}% - \xdef\enit@afterlist{% - \def\expandafter\noexpand - \csname enit@savekeys@\@currenvir\endcsname{\the\enit@toks}% - \def\expandafter\noexpand - \csname enit@resume@\@currenvir\endcsname{% - \csname c@\@listctr\endcsname - \the\csname c@\@listctr\endcsname}}% - \aftergroup\enit@afterlist} - +\let\enit@endenumerate\enit@endlist +\@namedef{enit@endenumerate*}{\enit@endinlist} + +% itemize and itemize* +% -------------------- +% % The following has 4 arguments, which in itemize are: % \@itemdepth, item, \thr@@, . % In user defined environments they are: % \enitdp@, , , + +\def\enit@itemize{% + \let\enit@list\enit@dylist + \enit@itemize@i} + +\@namedef{enit@itemize*}{% + \let\enit@list\enit@inlist + \enit@itemize@i} -\def\enit@itemize#1#2#3#4{% - \def\enit@depth{#1}% - \def\enit@type{item}% +\def\enit@itemize@i#1#2#3#4{% \ifnum#1>#3\relax - \@toodeep + \enit@toodeep \else - \edef\enit@prevlabel{#2\romannumeral#1}% - \advance#1\@ne + \enit@prelist\@ne{#1}{#2}% \edef\@itemitem{label#2\romannumeral#1}% \expandafter - \list + \enit@list \csname\@itemitem\endcsname - {\enit@preset - \enit@setkeys{enit@@#2}% - \enit@setkeys{enit@@#2\romannumeral#1}% - \enit@resumeset\enit@shl@item{#4}% - \enit@calcleft - \enit@before}% + {\let\enit@calc\z@ + \def\makelabel##1{\enit@align{\enit@format{##1}}}% + \enit@preset{#2}{#1}{#4}% + \enit@calcleft + \enit@before}% \fi} -\def\enit@enditemize{% - \enit@after - \endlist - \enit@toks\expandafter{\enit@savekeys}% - \xdef\enit@afterlist{% - \def\expandafter\noexpand - \csname enit@savekeys@\@currenvir\endcsname{\the\enit@toks}}% - \aftergroup\enit@afterlist} +\let\enit@enditemize\enit@endlist +\@namedef{enit@enditemize*}{\enit@endinlist} + +% description and description* +% ---------------------------- +% +% Make sure \descriptionlabel exists: + +\providecommand*\descriptionlabel[1]{% + \hspace\labelsep + \normalfont\bfseries#1} + +\@namedef{enit@description*}{% + \let\enit@list\enit@inlist + \enit@description@i} -\def\enit@description#1#2#3#4{% - \def\enit@depth{#1}% - \def\enit@type{desc}% +\def\enit@description{% + \let\enit@list\enit@dylist + \enit@description@i} + +\def\enit@description@i#1#2#3#4{% \ifnum#1>#3\relax - \@toodeep + \enit@toodeep \else - \list{}% - {\labelwidth\z@ + \enit@list{}% + {\let\enit@type\tw@ + \advance#1\@ne + \labelwidth\z@ + \enit@align@left \let\makelabel\descriptionlabel - \let\enit@descstyle\enit@normalstyle - \let\enit@before\@empty - \let\enit@after\@empty - \let\enit@format\@empty - \labelindent\z@skip - \enit@setkeys{enit@@list}% - \enit@setkeys{enit@@list\romannumeral#1}% - \enit@setkeys{enit@@#2}% - \enit@resumeset\enit@toks{#4}% - \itemindent-\leftmargin - \advance\itemindent\labelindent - \let\enit@makelabel\makelabel + \enit@style@standard + \enit@preset{#2}{#1}{#4}% + \enit@calcleft + \let\enit@svlabel\makelabel \def\makelabel##1{% - \enit@descstyle{\enit@makelabel{\enit@format##1}}}% + \labelsep\z@ + \ifenit@boxdesc + \enit@svlabel{\enit@align{\enit@format{##1}}}% + \else + \nobreak + \enit@svlabel{\enit@format{##1}}% + \aftergroup\enit@postlabel + \fi}% \enit@before}% \fi} -\newcount\enitdp@desc -\enitdp@desc\z@ +\let\enit@enddescription\enit@endlist +\@namedef{enit@enddescription*}{\enit@endinlist} -\def\enit@enddescription{% - \enit@after - \endlist - \enit@toks\expandafter{\enit@savekeys}% - \xdef\enit@afterlist{% - \def\expandafter\noexpand - \csname enit@savekeys@\@currenvir\endcsname{\the\enit@toks}}% - \aftergroup\enit@afterlist} - -% Option ignoredisplayed (see below). +% trivlist +% ======== \def\enit@trivlist{% + \let\enit@type\tw@ \parsep\parskip \csname @list\romannumeral\the\@listdepth\endcsname \@nmbrlistfalse - \enit@setkeys{enit@@triv}% - \enit@setkeys{enit@@triv\romannumeral\@listdepth}% + \enit@setkeys{trivlist}% + \enit@setkeys{trivlist\romannumeral\@listdepth}% \@trivlist \labelwidth\z@ \leftmargin\z@ @@ -538,32 +1292,42 @@ \let\@itemlabel\@empty \def\makelabel##1{##1}} -% description styles - -% the next definition is somewhat tricky because -% labels are boxed. That's fine when the label is -% just placed at the begining of a line of text, -% but when the box is placed without horizontal -% material, leading is killed. Therefore, -% solutions based on the LaTeX Companion are wrong. -% Here, the \everypar in \@item is overriden -% and the label is printed directly, without -% boxing it. +% Description styles +% ================== % -% First, a utility macro - -\def\enit@break{% - \if@nobreak - \@nobreakfalse - \clubpenalty\@M - \else - \clubpenalty\@clubpenalty - \everypar{}% - \fi} - -\def\enit@nextlinestyle#1{% - \hskip-\itemindent - \global\everypar{% +% the next definition is somewhat tricky because labels are boxed. +% That's fine when the label is just placed at the begining of a line +% of text, but when the box is placed without horizontal material, +% leading is killed. So, we need change somehow \box to \unhbox, but +% I don't want to modify \@item. The code below presumes \@item has +% not been changed and arguments gobble the part setting \@labels, +% which is replaced by a new one. +% +% The default value in description is itemindent=!, but some styles +% (those whose item text begin at a fixed place, ie, nextline, +% multiline and sameline) change it to labelwidth=!. +% +% We must be careful with the group and the whatsit added by color to +% boxes. Alignment is applied here and some adjustments in skips are +% necessary to get proper line breaks (including a \nobreak at the +% beginning of \enit@align, ie, after the first whatsit, see above). +% To "pass" the inner group added by color to the box, \enit@postlabel +% ckecks if the following is }. ie, \egroup -- if not, the box has +% not reached yet its end. + +\def\enit@postlabel{% + \@ifnextchar\egroup + {\aftergroup\enit@postlabel}% + {\enit@postlabel@i}} + +\def\enit@postlabel@i#1#2#3#4#5{% + \def\enit@lblpenalty{\penalty\z@\hskip\skip@}% + \ifenit@nextline + \ifdim\wd\@tempboxa>\labelwidth + \def\enit@lblpenalty{\newline\@nobreaktrue}% + \fi + \fi + \everypar{% \@minipagefalse \global\@newlistfalse \if@inlabel @@ -571,212 +1335,230 @@ {\setbox\z@\lastbox \ifvoid\z@ \kern-\itemindent - \fi - \sbox\z@{\hskip\labelindent#1\hskip\labelsep}% - \ifdim\wd\z@>\leftmargin - {\advance\leftskip-\leftmargin - \advance\leftskip\labelindent - \hskip-\labelsep - #1% - \par - \nobreak - \vskip-\parskip}% - \else - \hskip-\leftmargin\hskip-\labelsep\hskip\labelindent - \rlap{#1}% - \hskip\leftmargin\hskip\labelsep\hskip-\labelindent \fi}% - \setbox\@labels\box\voidb@x + \unhbox\@labels + \skip@\lastskip % Save last \labelsep + \unskip % Remove it + \enit@lblpenalty % Restore it, after penalty \fi - \enit@break}} - -\def\enit@multilinestyle#1{% - \dimen@\leftmargin - \advance\dimen@-\labelsep - \advance\dimen@-\labelindent - \sbox\z@{% - \parbox[t]\dimen@{% - \raggedright\hskip-\labelsep#1}}% - \setbox\@labels\box\voidb@x - \dp\z@\z@ - \hskip\labelsep\box\z@ - \hfil} - -\def\enit@unboxedstyle#1{% - \hskip-\itemindent - \global\everypar{% - \@minipagefalse - \global\@newlistfalse - \if@inlabel - \global\@inlabelfalse - {\setbox\z@\lastbox - \ifvoid\z@ - \kern-\itemindent - \fi - \hskip-\leftmargin\hskip-\labelsep\hskip\labelindent - #1% - \hskip\labelsep}% - \setbox\@labels\box\voidb@x + \if@nobreak + \@nobreakfalse + \clubpenalty\@M + \else + \clubpenalty\@clubpenalty + \everypar{}% + \fi}% + \def\enit@a{#1#2#3#4}% + \def\enit@b{\global\setbox\@labels\hbox}% + \ifx\enit@a\enit@b\else + \PackageError{enumitem}% + {Non standard \string\item}% + {A class or a package has redefined \string\item\MessageBreak + and I do not know how to continue}% + \fi + \global\setbox\@labels\hbox{% + \unhbox\@labels + \hskip\itemindent + \hskip-\labelwidth + \hskip-\labelsep + \ifdim\wd\@tempboxa>\labelwidth + \enit@align{\unhbox\@tempboxa}\unskip % Removes (typically) \hfil + \else + \leavevmode\hbox to\labelwidth{\enit@align{\unhbox\@tempboxa}}% \fi - \enit@break}} + \hskip\labelsep}} -\def\enit@samelinestyle#1{% - \hskip-\itemindent - \global\everypar{% - \@minipagefalse - \global\@newlistfalse - \if@inlabel - \global\@inlabelfalse - {\setbox\z@\lastbox - \ifvoid\z@ - \kern-\itemindent - \fi - \sbox\z@{\hskip\labelindent#1\hskip\labelsep}% - \ifdim\wd\z@>\leftmargin - \hskip-\leftmargin - \hskip-\labelsep - \hskip\labelindent - #1% - \hskip\labelsep - \else - \hskip-\leftmargin - \hskip-\labelsep - \hskip\labelindent - \rlap{#1}% - \hskip\leftmargin - \hskip\labelsep - \hskip-\labelindent - \fi}% - \setbox\@labels\box\voidb@x +% +=============================+ +% | (RE)DEFINING LISTS | +% +=============================+ +% +% Set keys/values +% =============== +% Remember \romannumeral0 expands to nothing. +% #1 = list name, #2 = level, #3 = flag if star, #4 = keys/values + +\def\enit@saveset#1#2#3#4{% + \setcounter{enit@cnt}{#2}% + \ifcase#3% + \expandafter + \def\csname enit@@#1\romannumeral\c@enit@cnt\endcsname{#4}% + \or + \expandafter\let\expandafter\enit@b + \csname enit@@#1\romannumeral\c@enit@cnt\endcsname + \ifx\enit@b\relax + \let\enit@b\@empty \fi - \enit@break}} - -% Formatting lists globally. Note \romannumeral0 expands -% to nothing. - -\newcommand\setenumerate[1][0]{% - \expandafter\def\csname enit@@enum\romannumeral#1\endcsname} - -\newcommand\setitemize[1][0]{% - \expandafter\def\csname enit@@item\romannumeral#1\endcsname} - -\newcommand\setdescription{\def\enit@@desc} - -% task: more robust test - -\newcommand\setlist[1][0]{% - \def\enit@b{list}% - \count@\z@\relax - \@for\enit@a:=#1\do{% - \@ifundefined{end\enit@a}% - {\count@=\enit@a}% - {\edef\enit@b{\enit@a}}}% - \expandafter\def\csname enit@@\enit@b\romannumeral\count@\endcsname} + \expandafter\def + \csname enit@@#1\romannumeral\c@enit@cnt\expandafter\endcsname + \expandafter{\enit@b,#4}% + \fi} -\newcommand\setdisplayed[1][0]{% - \expandafter\def\csname enit@@triv\romannumeral#1\endcsname} +% To do: more robust tests (catch wrong names, but not easy) + +% Internally, LaTeX uses a short name for enumerate (enum) +% and itemize (item). To be consistent with this convention, +% a couple of macros provide a "translation". I'm not very +% happy with the current implementation. + +\def\enit@shortenumerate{enum} +\def\enit@shortitemize{item} + +\newcommand\setlist[1][]{% + \@ifstar{\enit@setlist{#1}\@ne}{\enit@setlist{#1}\z@}} + +% #1 list names/levels, #2 keys/values + +\def\enit@setlist#1#2#3{% + \let\enit@eltnames\relax + \let\enit@b\@empty + \let\enit@eltlevels\relax + \let\enit@c\@empty + \protected@edef\enit@a{#1}% + \@for\enit@a:=\enit@a\do{% the 2nd enit@a is first expanded + \@ifundefined{enitdp@\enit@meaning\enit@a}% + {\edef\enit@c{\enit@c\enit@eltlevels{\enit@a}}}% + {\@ifundefined{enit@short\enit@meaning\enit@a}% + \@empty + {\edef\enit@a{\@nameuse{enit@short\enit@a}}}% + \edef\enit@b{\enit@b\enit@eltnames{\enit@a}}}}% + \ifx\enit@b\@empty + \def\enit@b{\enit@eltnames{list}}% + \fi + \ifx\enit@c\@empty + \def\enit@c{\enit@eltlevels{0}}% + \fi + \def\enit@eltnames##1{% + \def\enit@a{##1}% + \enit@c}% + \def\enit@eltlevels##1{% + \enit@saveset\enit@a{##1}#2{#3}}% + \enit@b}% -% A few useful predefined keys - -\define@key{enumitem}{nolistsep}[true]{% - \partopsep=\z@skip - \topsep=\z@ plus .1pt - \itemsep=\z@skip - \parsep=\z@skip} +% Deprecated: -\define@key{enumitem}{noitemsep}[true]{% - \itemsep=\z@skip - \parsep=\z@skip} +\newcommand\setdisplayed[1][0]{\setlist[trivlist,#1]} +\let\enitdp@trivlist\@empty % dummy, let know it exists +\newcommand\setenumerate[1][0]{\setlist[enumerate,#1]} +\newcommand\setitemize[1][0]{\setlist[itemize,#1]} +\newcommand\setdescription[1][0]{\setlist[description,#1]} -\define@key{enumitem}{fullwidth}[true]{% - \leftmargin\z@ - \labelwidth\z@ - \def\makelabel##1{% - \hskip\labelsep\enit@format##1}} +% New lists +% ========= -% User defined enumerate and itemize +% When defining a list, \label... and counters must be defined +% for each level, too: -\def\enit@xset@itemize#1#2{% - \@namedef{label#1\romannumeral\count@}{% +\def\enit@xset@itemize{% + \@namedef{label\enit@c\romannumeral\count@}{% \PackageError{enumitem}{Undefined label}% {You have defined a list, but labels have - not been setup.\MessageBreak Use the label field.}}} + not been setup.\MessageBreak + You can set the label field with \string\setlist.}}} +\@namedef{enit@xset@itemize*}{\enit@xset@itemize} -\def\enit@xset@enumerate#1#2{% - \enit@xset@itemize{#1}{#2}% - \@definecounter{#1\romannumeral\count@}} +\def\enit@xset@enumerate{% + \enit@xset@itemize + \@ifundefined{c@\enit@c\romannumeral\count@}% + {\@definecounter{\enit@c\romannumeral\count@}}{}} +\@namedef{enit@xset@enumerate*}{\enit@xset@enumerate} -\let\enit@xset@description\@gobbletwo +\let\enit@xset@description\@empty +\@namedef{enit@xset@description*}{\enit@xset@description} + +\newcommand\newlist{\enit@newlist\newenvironment} +\newcommand\renewlist{\enit@newlist\renewenvironment} % , , , \def\enit@newlist#1#2#3#4{% + \@ifundefined{enit@xset@#3}% + {\PackageError{enumitem}{Unknown list type `#3')}% + {Valid types are: + enumerate, itemize, description,\messageBreak + enumerate*, itemize*, description*}}% + {}% + \setcounter{enit@cnt}{#4}% \count@\@ne + \@ifundefined{enit@short#2}% + {\def\enit@c{#2}}% + {\edef\enit@c{\csname enit@short#2\endcsname}}% \loop - \@nameuse{enit@xset@#3}{#2}{#4}% - \ifnum\count@<#4 + \@nameuse{enit@xset@#3}% Uses \enit@c + \ifnum\count@<\c@enit@cnt \advance\count@\@ne \repeat \@ifundefined{enitdp@#2}% {\expandafter\newcount\csname enitdp@#2\endcsname}{}% \csname enitdp@#2\endcsname\z@ - \count@#4 - \advance\count@\m@ne + \advance\c@enit@cnt\m@ne \edef\enit@a{% \noexpand#1{#2}[1][]% - {\noexpand\enit@checkenv{#2}% - \expandafter\noexpand\csname enit@#3\endcsname - \expandafter\noexpand\csname enitdp@#2\endcsname - {#2}% - {\the\count@}% + {\enit@noexcs{enit@#3}% + \enit@noexcs{enitdp@#2}% + {\enit@c}% + {\the\c@enit@cnt}% {####1}}% - {\expandafter\noexpand\csname enit@end#3\endcsname}}% + {\enit@noexcs{enit@end#3}}}% \enit@a} +% Changing the default nesting limit +% ---------------------------------- -\newcommand\newlist{\enit@newlist\newenvironment} -\newcommand\renewlist{\enit@newlist\renewenvironment} +\newcommand\setlistdepth{\def\enit@listdepth} +\setlistdepth{5} -\def\enit@checkenv#1{% - \def\enit@a{#1}% - \ifx\enit@a\@currenvir\else - \PackageError{enumitem}{Bad nesting}% - {You are using a non grouping form of a list - environment.\MessageBreak - Use \string\begin/\string\end.}% - \fi}% - -% And options +% +=============================+ +% | PACKAGE OPTIONS | +% +=============================+ \newif\ifenit@loadonly \DeclareOption{ignoredisplayed}{\let\enit@trivlist\trivlist} \DeclareOption{loadonly}{\enit@loadonlytrue} \DeclareOption{shortlabels} - {\def\enit@shl@enum#1{% - \def\enit@c{#1}% - \enit@first#1,\@nil\@@nil}% - \let\enit@shl@item\enit@shl@enum} + {\def\enit@shl#1{% + \ifnum\enit@type=\tw@ + \enit@toks{#1}% + \else + \def\enit@c{#1}% + \enit@first#1,\@nil\@@nil % Returns enit@toks + \fi}} +\DeclareOption{inline} + {\newenvironment{enumerate*}[1][]% + {\@nameuse{enit@enumerate*}\enitdp@enumerate{enum}\thr@@{#1}} + {\@nameuse{enit@endenumerate*}} + \newenvironment{itemize*}[1][]% + {\@nameuse{enit@itemize*}\enitdp@itemize{item}\thr@@{#1}} + {\@nameuse{enit@enditemize*}} + \newenvironment{description*}[1][]% + {\@nameuse{enit@description*}\enitdp@description{description}\@M{#1}} + {\@nameuse{enit@enddescription*}}} + +\let\enit@shl\enit@toks \ProcessOptions \let\trivlist\enit@trivlist +% If there is no loadonly, redefine the basic lists: + \ifenit@loadonly\else +\let\enitdp@enumerate\@enumdepth \renewenvironment{enumerate}[1][] - {\enit@enumerate\@enumdepth{enum}\thr@@{#1}} + {\enit@enumerate\enitdp@enumerate{enum}\thr@@{#1}} {\enit@endenumerate} +\let\enitdp@itemize\@itemdepth \renewenvironment{itemize}[1][] - {\enit@itemize\@itemdepth{item}\thr@@{#1}} + {\enit@itemize\enitdp@itemize{item}\thr@@{#1}} {\enit@enditemize} +\newcount\enitdp@description \renewenvironment{description}[1][] - {\enit@description\z@{desc}\@M{#1}} + {\enit@description\enitdp@description{description}\@M{#1}} {\enit@enddescription} \fi - \endinput -- cgit v1.2.3