% \iffalse
% File paralist.dtx
% Copyright 1998-2017 Bernd Schandl
% Copyright 2013 Julian Gilbey (modifications in v2.4)
% email schandl@gmx.com
%
% Documentation and documented source code for the paralist package.
%
% See the README file for instructions.
%
% This file can be redistributed and/or modified under the terms
% of the LaTeX Project Public License distributed from CTAN
% archives in the directory macros/latex/base/lppl.txt; either
% version 1 of the license, or (at your option) any later version.
%
% \fi
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
% \iffalse
%<*dtx>
          \ProvidesFile{paralist.dtx}%
%</dtx>
%<package>\ProvidesPackage{paralist}%
%<driver>\ProvidesFile{paralist.drv}%
% \fi
%         \ProvidesFile{paralist.dtx}%
          [2017/01/22 v2.7 Extended list environments]
% \iffalse
%<*driver>
\documentclass[11pt]{ltxdoc}
\usepackage[defblank,neverdecrease]{paralist}

%% Comment out the next line if you want the documentation for the source code.
\OnlyDescription

%% Uncomment the next two lines for a change history. 
%% See also the instructions above.
%% \AtBeginDocument{\RecordChanges}
%% \AtEndDocument{\PrintChanges}

%% Uncomment the next two lines for a command index. 
%% See also the instructions above.
%% \AtBeginDocument{\CodelineIndex}
%% \AtEndDocument{\setcounter{IndexColumns}{2}\PrintIndex}

\begin{document}
  \DocInput{paralist.dtx}
\end{document}
%</driver>
% \fi
% 
% \changes{v1.0 (1998/10/09)}{}{Initial version}
% \changes{v1.1 (1998/10/18)}{}{Added some examples}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Most of the package and the 
%   documentation rewritten}
% \changes{v1.5 (1999/03/15)}{1999/03/15}{Released under LPPL}
% \changes{v1.7 (1999/04/01)}{1999/03/31}{Use \cs{GetFileInfo}}
% \changes{v1.9 (2000/03/05)}{2000/03/05}{Email and WWW changed}
% \changes{v2.2 (2001/09/30)}{2001/09/30}{WWW changed}
% \changes{v2.2a (2001/10/02)}{2001/10/02}{Minor documentation changes}
% \changes{v2.3 (2002/03/10)}{2002/03/10}{Several changes in code}
% \changes{v2.3a (2002/03/10)}{2002/03/10}{Couple of changes}
% \changes{v2.3b (2002/03/18)}{2002/03/18}{Fix handling of flags}
% \changes{v2.4 (2013/06/09)}{2013/06/09}{Extra option for label width (JDG)}
% \changes{v2.5 (2015/12/30)}{2015/12/30}{Fix excess space introduced in v2.4}
% \changes{v2.6 (2016/08/07)}{2016/08/07}{Fix of inparaitem and inparadesc}
% \changes{v2.7 (2017/01/22)}{2017/01/22}{Fix of labelwidth problem introduced in v2.4}
%
% \GetFileInfo{paralist.dtx}
% \CheckSum{1059}
%
% \makeatletter
% \renewenvironment{theglossary}{%
%    \glossary@prologue \GlossaryParms \let\item\@idxitem \ignorespaces}{}
% \makeatother
%
% \MakeShortVerb{\|}
%
% \let\package\textsf
% \let\tab\indent
% \IndexMin3cm
%
% \title{\package{paralist}\thanks{Package version \fileversion{} of 
%     \filedate{}.} \\ Extended List Environments}
% \author{Bernd Schandl \\ {\small |schandl@gmx.com|}}
% \date{Printed on \today}
% \maketitle
%
% \begin{abstract}
%   This package provides some new list environments. Itemized and enumerated 
%   lists can be typeset within paragraphs, as paragraphs and in a compact
%   version. Most environments have optional arguments to format the labels.
%   Additionally, the \LaTeX\ environments |itemize| and |enumerate| can be 
%   extended to use a similar optional argument.
% \end{abstract}
%
% \section{Introduction}
% 
% In a posting to |comp.text.tex| in May 1998, someone asked about the 
% possibility of an enumerated environment that 
% \begin{inparaenum}[(a)]
%   \item can be used within paragraphs,
%   \item takes care of enumeration and
%   \item has items that can be referenced. \label{pl2}
% \end{inparaenum}
% Another posting mentioned the package \package{theapa} as
% a possible solution. Now that I was looking for that kind of environment and
% found those old postings, I had a look at \package{theapa} and decided to
% take out the part about list environments and rewrite it a little bit. 
%
% Over time, compact versions of |enumerate|, |itemize| and |description| have 
% been added and optional arguments for most environments make it possible to 
% define a special way of formatting the labels.
%
% \section{Package Options}
%
% Certain parts of the package are only executed if appropriate options are 
% specified.
% \begin{compactdesc}
%  \renewcommand*\makelabel[1]{\hspace\labelsep
%    \normalfont\mdseries\sffamily #1}
%   \item[newitem/olditem] With \textsf{newitem} (set by default), the \LaTeX\ 
%     environment |itemize| will be redefined to have an optional argument to 
%     specify the format of the label. See Section~\ref{sec:format}. 
%     Specifying \textsf{olditem} will leave |itemize| as it is.
%   \item[newenum/oldenum] With \textsf{newenum} (set by default), the \LaTeX\ 
%     environment |enumerate| will be redefined to have an optional argument 
%     to specify the format of the label. See Section~\ref{sec:format}. 
%     Specifying \textsf{oldenum} will leave |enumerate| as it is.
%   \item[alwaysadjust] The width of the labels of the environments
%     |compactenum|, |enumerate|, |compactitem| and |itemize| is always
%     adjusted to the actual label. For the default labels, this means that
%     the label width is usually decreased. 
%   \item[neveradjust] The width of the labels is never adjusted, not even for
%     environments where you defined the labels manually using the optional
%     argument. This option is ignored if option \textsf{alwaysadjust} is used
%     as well.
%   \item[neverdecrease] If the width of the labels is adjusted, this option
%     avoids the decrease of the width. Here is an example why this might make
%     sense. If no \textsf{\dots adjust} option is specified, then the
%     indentation of the \cs{item} in |\begin{enumerate}| and
%     |\begin{enumerate}[1.]| is different although they have the same
%     labels. 
%   \item[defblank] The two environments |inparablank| and |asparablank| will
%     be defined. See Section~\ref{sec:blank}. 
%   \changes{v2.0 (2001/03/03)}{2001/03/03}{New options \textsf{pointlessenum}
%     and \textsf{pointedenum}} 
%   \item[pointlessenum] The items in the enumerated environments are labeled
%     and referenced as in ``1'', ``1.1'', ``1.1.1''  and ``1.1.1.1''. See
%     also Section~\ref{sec:format}. 
%   \item[pointedenum] The items in the enumerated environments are labeled
%     as in ``1.'', ``1.1.'', ``1.1.1.'' and ``1.1.1.1.'' and referenced
%     without the trailing point. See also Section~\ref{sec:format}. This 
%     option is ignored if \textsf{pointlessenum} is used.
%   \item[flushright] The labels in the four lists mentioned above are set
%     flush right. As this is the \LaTeX\ default, this is also the default
%     for this package.
%   \item[flushleft] The labels in the four lists mentioned above are set
%     flush left.
%   \changes{v1.9 (2000/03/05)}{2000/03/05}{New options
%     \textsf{cfg}/\textsf{nocfg}}
%   \item[cfg] The configuration file |paralist.cfg| is loaded if it
%     exists. (default) 
%   \item[nocfg] The configuration file is not loaded.
% \end{compactdesc}
% The option \textsf{increaseonly} is deprecated; use \textsf{neverdecrease} 
% instead.
%
% \section{Formatting the Labels}
% \label{sec:format}
%
% All the itemized and enumerated environments have optional arguments to 
% specify the format of the labels. The following examples will only work if 
% you have loaded \package{paralist} \emph{without} the options 
% \textsf{olditem} and \textsf{oldenum}.
%
% Using the \LaTeX\ standard classes, |itemize| uses the following symbols 
% for the labels of the four list levels: {\textbullet} 
% {\normalfont\bfseries \textendash} {\textasteriskcentered} 
% {\textperiodcentered}. If you want to change this for a particular 
% environment, just say something like\\
% \tab|\begin{itemize}[$\star$]|\\
% and $\star$ will be used instead of the default symbol.
%
% The optional argument of the enumerated environment is a little more 
% complicated,  but whoever has worked with David Carlisle's 
% \package{enumerate} package can skip the rest of the section since exactly 
% the same mechanism (and almost the same code) is used. 
%
% The tokens |A|, |a|, |I|, |i|, and |1| can be used in the optional argument 
% to produce the counter with one of the styles \cs{Alph}, \cs{alph}, 
% \cs{Roman}, \cs{roman} and \cs{arabic}.\footnote{%
%   The set of tokens can be extended. Look for \cs{pl@hook} in the code 
%   section.} 
% These letters may be surrounded by any other string involving any other 
% \TeX\ expression. However, the tokens |A a I i 1| must be inside a |{ }| 
% group if they should not be taken as special. A few examples follow.\\
% \tab|\begin{enumerate}[(i)]|\\
% produces the labels (i), (ii), (iii) \dots\\
% \tab|\begin{enumerate}[{example} a)]|\\
% produces example a), example b), example c) \dots\\
% \tab|\begin{enumerate}[{A}-1]|\\
% produces A-1, A-2, A-3 \dots\\
% \tab|\begin{enumerate}[\bfseries {Item} I]|\\
% produces \textbf{Item I}, \textbf{Item II}, \textbf{Item III} \dots
%
% Note that in the last example |[\textbf{Item I}]| does not work because
% the special token |I| is inside a group.
%
% The \cs{ref} command produces only the counter without the surrounding text,
% so in the examples above you would get i, a, 1 and I respectively if you
% referenced the first item.
%
% If the labels use roman (as in the first example above), an attempt
% is made to determine the widest necessary label, assuming the
% maximum item number is at most~7.  If this is not the case, and the
% labels might be wider than this, one can use a second optional
% argument specifying the widest label number, for example:\\
% \tab|\begin{enumerate}[(i)][8]|\\
% which will produce the labels (i), (ii), \dots, (vii), (viii), (ix)
% and so on, with everything up to (xvi) fitting
% comfortably.\footnote{This feature was introduced in version 2.4 of
% this package, and it would be wise therefore, if using this
% feature in portable documents, to specify
% \texttt{\char`\\usepackage\char`\{paralist\char`\}[2013/06/09]}
% when loading the package.}
% 
% \DescribeMacro{\pointedenum}
% \DescribeMacro{\pointlessenum}
% There are also two package options and two corresponding macros to format
% the labels and references of enumerated environments. The option
% \textsf{pointedenum} and the macro |\pointedenum| format the labels as in
% ``1.'', ``1.1.'', ``1.1.1.'' and ``1.1.1.1.'' and the references without the
% trailing point. The option \textsf{pointlessenum} and the macro
% |\pointlessenum| do not use the trailing point in the labels either.
%
% While the package options make a global change, the macros can be used for a
% local change or to define a special environment, for example\\
% \tab|\newenvironment{myenum}%|\\
% \tab|  {\pointedenum\begin{enumerate}}%|\\
% \tab|  {\end{enumerate}}|\\
% Note that |\begin{enumerate}| is used \emph{after} |\pointedenum|, otherwise
% the optional argument of enumerate would not work (in case you want to use 
% them within the same environment which doesn't really make sense). 
%
% \DescribeMacro{\paradescriptionlabel}
% In the document classes, the label format for the |description| environment
% is defined as\\
% \tab|\newcommand*\descriptionlabel[1]{%|\\
% \tab|  \hspace\labelsep\normalfont\bfseries #1}|.\\
% This is also used by |compactdesc|. For the environments |inparadesc| and
% |asparadesc|, there is a separate macro called \cs{paradescriptionlabel}
% defined (almost) like this:\\ 
% \tab|\newcommand*\paradescriptionlabel[1]{%|\\
% \tab|  \normalfont\bfseries #1}|.
%
%
% \section{Defaults for Labels and Margins}
% 
% If you want your lists labeled differently than the \LaTeX\ default
% throughout your document, it is a bit awkward to use the optional argument 
% of the environments all the time. Therefore three macros are provided
% to define the labels and the left margins of the list environments. 
%
% Note that the macros defining the labels do \emph{not} adapt the left
% margins of the list environments because this may have unexpected side
% effects. If you want that change, you have to explicitly use
% \cs{setdefaultleftmargin}.  
%
% If in any of the following three macros an argument is empty, then
% the according label or margin is left unchanged.
%
% \DescribeMacro{\setdefaultitem}
% The default labels of itemized environments can be set by using the macro
% \cs{setdefaultitem} which needs four arguments. To get the \LaTeX\ default 
% labels say\\
% \tab|\setdefaultitem{\textbullet}%|\\
% \tab|  {\normalfont\bfseries \textendash}%|\\
% \tab|  {\textasteriskcentered}{\textperiodcentered}|\\
% (which is of course silly because you don't need to do anything if you want 
% to stick with the default labels). If you want a triangle 
% ($\,\triangleright$) instead of the endash for level two just say\\
% \tab|\setdefaultitem{}{$\triangleright$}{}{}|.
%
% \DescribeMacro{\setdefaultenum}
% The labels of enumerated lists are formatted  with \cs{setdefaultenum} 
% using the mechanism described in Section~\ref{sec:format}. The \LaTeX\ 
% default labels could be defined by\\
% \tab|\setdefaultenum{1.}{(a)}{i.}{A.}|.\\
% If you want capital Roman letters for level three, just say\\
% \tab|\setdefaultenum{}{}{I.}{}|.
%
% \DescribeMacro{\setdefaultleftmargin}
% To change the left margin of the lists, use \cs{setdefaultleftmargin}.
% The length \cs{leftmargin}$\,n$ specifies the indentation of a list of level
% $n$ with respect to the list of level $n-1$ or the surrounding text 
% (if $n=1$). The environments that use \cs{leftmargin}$\,n$ are (at least)
% |enumerate|, |compactenum|, |itemize| and |compactitem| (maybe a few more
% that I am not aware of). The \LaTeX\ settings could be defined by\\
% \tab|\setdefaultleftmargin{2.5em}{2.2em}{1.87em}{1.7em}{1em}{1em}|.\\
% In \textsf{twocolumn} mode \LaTeX\ uses a smaller margin for the first,
% fifth and sixth level which could be defined by\\
% \tab|\setdefaultleftmargin{2em}{}{}{}{.5em}{.5em}|.
%
% The macros \cs{defaultitem}, \cs{defaultenum} and |\defaultleftmargin|
% should not be used anymore. They are only kept for backward compatibility
% with package versions~$<2.1$.  
%
% If some of your changes should appear in \emph{every} document that uses 
% \package{paralist}, put them in a file |paralist.cfg| which is read at the 
% end of the package in case it exists (unless you specified the option
% \textsf{nocfg}).
%
% \section{New Environments}
%
% \subsection{Enumerated Environments}
%
% \DescribeEnv{asparaenum}
% The environment |asparaenum| is an enumerated environment in which the 
% items are formatted as separate paragraphs.
%
% As an example, we use |asparaenum| within this paragraph.
% \begin{asparaenum}
%   \item Every \cs{item} is basically set as a separate paragraph. The second
%     line is \emph{not} indented (this is a feature, not a bug).
%   \item The next \cs{item} looks like this and is labeled. \label{pl1}
% \end{asparaenum}
% The example was produced by the following piece of code:
%\begin{verbatim}
%   \begin{asparaenum}
%     \item Every ...
%     \item The next ... \label{pl1}
%   \end{asparaenum} 
%\end{verbatim}
% By saying |\ref{pl1}| we get \ref{pl1}.
%
% \DescribeEnv{inparaenum}
% The |inparaenum| environment formats an enumerated list within a paragraph, 
% just like the one in the introduction. 
%
% The example in the introduction was set by the following commands:
%\begin{verbatim}
%   ... of an enumerated environment that 
%   \begin{inparaenum}[(a)]
%     \item can be used within paragraphs,
%     \item takes care of enumeration and
%     \item has items that can be referenced. \label{pl2}
%   \end{inparaenum}
%   Another posting mentioned ... 
%\end{verbatim}
% By saying |\ref{pl2}| we get \ref{pl2}.
%
% \DescribeEnv{compactenum}
% The |compactenum| environment is just a compact version of the standard 
% |enumerate| environment. All the vertical skips are set to zero (actually
% they are adjustable, see Section~\ref{sec:Finetuning}).
%
% \subsection{Itemized Environments}
%
% \DescribeEnv{asparaitem}
% The |asparaitem| environment is very similar to |asparaenum|. It just uses
% symbols instead of enumerating the items. The environment has an optional
% argument which specifies the symbol. For an example see 
% Section~\ref{sec:Nesting-Environments}.
%
% \DescribeEnv{inparaitem}
% Similar to |inparaenum| I  added an environment |inparaitem| which also
% has an optional argument. I don't really know why anybody would use it, but
% I added it because of symmetry. 
%
% \DescribeEnv{compactitem}
% The |compactitem| environment is again just a compact version of the 
% standard |itemize| environment with all the vertical skips set to zero. 
% So by using this environment 
% \begin{compactitem}[$\circ$]
%   \item you can save some space and
%   \item specify the symbol.
%   \item Let me add a longer item so that you can see that we have a different
%     indentation than in the |asparaitem| environment.
% \end{compactitem}
% The code of the example above is
%\begin{verbatim}
%   \begin{compactitem}[$\circ$]
%     \item you can save some space and
%     \item specify the symbol.
%     \item Let me add ...
%   \end{compactitem} 
%\end{verbatim}
%
% \subsection{Descriptive Environments}
%
% \DescribeEnv{asparadesc}
% The |asparadesc| environment is again very similar to |asparaenum|. It just
% uses the optional arument of \cs{item} as the ``intro'' for the paragraph.
%
% \DescribeEnv{inparadesc}
% Again similar to |inparaenum|, I added an environment |inparadesc|. Probably
% nobody would use it but I added it because of symmetry. 
%
% \DescribeEnv{compactdesc}
% The |compactdesc| environment is copied from the \LaTeX{} standard classes 
% with all the vertical skips set to zero. By the way, does anybody know why
% |description| has to be defined by the document class and is not defined in
% |ltlists.dtx|?
%
% \subsection{Blank Environments}
% \label{sec:blank}
%
% Someone requested list environments that print their items as if there was no
% list. It seems that this makes entering structured data a little easier in
% LyX. Since not everybody needs these (odd) environments they are only
% defined if the package is loaded with the option \textsf{defblank}. The
% following two environments do not have optional arguments because there is
% no label to format.
%
% \DescribeEnv{asparablank}
% Every item is formatted just as if it was a regular paragraph. If you want
% to use the optional argument of \cs{item}, you have to add some white space
% at the end because \cs{labelsep} is set to zero. Use something like\\
% \tab|\item[\textbullet\hspace{.5em}]|
%
% \DescribeEnv{inparablank}
% The items are set 
% \begin{inparablank}
%   \item just as regular text. 
%   \item The ``white space problem'' mentioned in the last paragraph 
%   \item is handled automatically. 
% \end{inparablank}
% If I didn't tell you, you wouldn't know that this paragraph is set using the 
% following construction:
%\begin{verbatim}
%   ... are set
%   \begin{inparablank}
%     \item just as ...
%     \item The ...
%     \item is handled ...
%   \end{inparablank}
%   If I didn't ... 
%\end{verbatim}
%
%\section{Nesting Environments}
%\label{sec:Nesting-Environments}
%
% All the environments can be nested just as the standard list environments 
% although the results might sometimes not be as expected. For example, it's
% probably not a good idea to call another list environment within a
% |inpara...| environment, but why should anyone want to do this? The maximal
% nesting level is six (four of the same kind), just as for the \LaTeX\
% environments.  
%
% This paragraph is 
% \begin{asparaitem}[$\star$]
%   \item an example for the usage of |asparaitem| and its optional argument,
%   \item and a demonstration that
%     \begin{inparaenum}[(i)]
%       \item you can use |inparaenum| within |asparaitem| and
%       \item you can still reference it. \label{pl3}
%     \end{inparaenum}
% \end{asparaitem}
% The reference was in subitem (\ref{pl3}).
% The code of the last example is
%\begin{verbatim}
%   \begin{asparaitem}[$\star$]
%     \item an example ...
%     \item and a demonstration that
%       \begin{inparaenum}[(i)]
%         \item you can use ...
%         \item can still ... \label{pl3}
%       \end{inparaenum}
%   \end{asparaitem}
%   The reference was in subitem (\ref{pl3}). 
%\end{verbatim}
%
%\section{Fine-Tuning}
%\label{sec:Finetuning}
%
% Ok, I already hear someone saying ``Your compact lists are a nice idea,
% but I'd like to have it a little less compact.'' Here is a solution. The
% following skips can be adjusted using \cs{setlength} and affect the 
% spacing of the |compact...| environments. The names are chosen similar to
% the \LaTeX{} names, so I just copy the explanation from |ltlists.dtx|.
% \begin{compactdesc}
% \item[\cs{pltopsep}:]  Space between first item and preceding paragraph.
% \item[\cs{plpartopsep}:] Extra space added to \cs{topsep} when
%   environment starts a new paragraph (is called in vmode).
% \item[\cs{plitemsep}:] Space between successive items.
% \item[\cs{plparsep}:] Space between paragraphs within an item -- the
%   \cs{parskip} for this environment.
% \end{compactdesc}
% Actually, the two |...topsep| skips are added before \emph{and after} the
% list.
%
% The default value for all of them is 0\,pt. It is probably a good idea to
% define them depending on the font size if they are non-zero, i.\,e.\ using 
% units such as |ex| or |em|.
%
% \section{Bugs and Wishes}
%
% No bugs \dots that I know of.
%
% \changes{v2.3 (2002/03/10)}{2002/03/10}{Describe incombatibility with
%   \package{babel}} 
% Well, there is actually one issue if you use the \package{babel} package
% with one of the options \textsf{acadian}, \textsf{canadien},
% \textsf{francais}, \textsf{frenchb} or \textsf{french} (which all do
% essentially the same). Since it redefines the itemize environment 
% at the \cs{start\{document\}}, the definition of |itemize| made by
% \package{paralist} is lost. There are three possible fixes:
% \begin{compactenum} 
% \item Accept the |itemize| environment without optional argument.~|:(|
% \item Use \cs{FrenchItemizeSpacingfalse} after loading \package{babel} which
%   will avoid the redefinition of |itemize| by \package{babel}.~|:/|
% \item Figure out a way to combine the code in \package{babel} and
%   \package{paralist} and send the solution to me.~|:)|
% \end{compactenum}
%
% Feel free to let me know about any problems, suggestions and wishes you have
% concerning this package and its documentation. Praise is welcome, 
% too |;-)| The most recent version of this package can always be found on
% CTAN or at |http://schandl.gmxhome.de/paralist/|. 
%
% \section{Acknowledgments}
%
% I want to thank all the users who helped me with their
% comments finding bugs and extending the package. A big ``Thank you'' goes to
% David Carlisle, because there wouldn't be any optional arguments for the 
% enumerated environments without the code from his
% \package{enumerate} package. Some pieces of code of the |inpara...|
% environments are inspired by Mogens Lemvig Hansen's \package{shortlst} 
% package.
%
% \StopEventually
%
% \section{Implementation}
%
% At the beginning of this file, the |\ProvidesPackage| macro was executed. 
% So we only need to state that we need \LaTeXe.
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
%    \end{macrocode}
%
% \subsection{Package Options}
%
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Package options added}
% \changes{v1.3 (1999/01/19)}{1999/01/18}{Option \textsf{increaseonly} added}
% \changes{v2.1 (2001/09/20)}{2001/09/16}{Options \textsf{olditem} and
%   \textsf{oldenum} added}
% \changes{v2.1 (2001/09/20)}{2001/09/16}{Options \textsf{newitem} and
%   \textsf{newenum} are set by default}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Options \textsf{alwaysadjust},
%   \textsf{neveradjust} and \textsf{neverdecrease} added; option 
%   \textsf{increaseonly} only kept for compatibility}
% \changes{v2.1 (2001/09/20)}{2001/09/16}{Options \textsf{flushleft} and
%   \textsf{flushright} added}
% First we define the package options. The option \textsf{increaseonly} is
% only kept for compatibility.
%    \begin{macrocode}
\newif\if@plnewitem\@plnewitemtrue
\newif\if@plnewenum\@plnewenumtrue
\newif\if@plalwaysadjust\@plalwaysadjustfalse
\newif\if@plneveradjust\@plneveradjustfalse
\newif\if@plneverdecrease\@plneverdecreasefalse
\newif\if@pldefblank\@pldefblankfalse
\newif\if@plpointedenum\@plpointedenumfalse
\newif\if@plpointlessenum\@plpointlessenumfalse
\newif\if@plflushright\@plflushrighttrue
\newif\if@plloadcfg\@plloadcfgtrue
\DeclareOption{newitem}{\@plnewitemtrue}
\DeclareOption{olditem}{\@plnewitemfalse}
\DeclareOption{newenum}{\@plnewenumtrue}
\DeclareOption{oldenum}{\@plnewenumfalse}
\DeclareOption{alwaysadjust}{\@plalwaysadjusttrue}
\DeclareOption{neveradjust}{\@plneveradjusttrue}
\DeclareOption{neverdecrease}{\@plneverdecreasetrue}
\DeclareOption{increaseonly}{\@plneverdecreasetrue
  \PackageWarningNoLine{Paralist}{Option increaseonly deprecated. 
    \MessageBreak Use option neverdecrease instead}}
\DeclareOption{defblank}{\@pldefblanktrue}
\DeclareOption{pointedenum}{\@plpointedenumtrue}
\DeclareOption{pointlessenum}{\@plpointlessenumtrue}
\DeclareOption{cfg}{\@plloadcfgtrue}
\DeclareOption{nocfg}{\@plloadcfgfalse}
\DeclareOption{flushright}{\@plflushrighttrue}
\DeclareOption{flushleft}{\@plflushrightfalse}
\ExecuteOptions{newitem,newenum,cfg,flushright}
\ProcessOptions\relax
%    \end{macrocode}
% \changes{v2.3 (2002/03/10)}{2002/03/07}{Option \textsf{alwaysadjust}
%   overwrites \textsf{neveradjust}} 
% Make sure that \textsf{alwaysadjust} overwrites \textsf{neveradjust}.
%    \begin{macrocode}
\if@plalwaysadjust\@plneveradjustfalse\fi
%    \end{macrocode}
%
% \subsection{New Skips}
%
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Counters \texttt{asparaenum} and
%   \texttt{inparaenum} removed}
% The new skips are all set to zero.
% \changes{v1.1 (1998/10/18)}{}{Skips to adjust spacing in \texttt{compact...}
%   environments defined}
%    \begin{macrocode}
\newlength{\pltopsep}
\newlength{\plpartopsep}
\newlength{\plitemsep}
\newlength{\plparsep}
\setlength{\pltopsep}{0pt}
\setlength{\plpartopsep}{0pt}
\setlength{\plitemsep}{0pt}
\setlength{\plparsep}{0pt}
%    \end{macrocode}
%
% \subsection{Little ``Helper'' Macros}
%
% \begin{macro}{\if@empty}
% \changes{v1.4 (1999/01/27)}{1999/01/19}{New macro}
% A small macro to detect whether |#1| is empty.
%    \begin{macrocode}
\def\if@empty#1#2#3{%
  \def\@tempa{#1}%
  \ifx\@tempa\@empty#2\else#3\fi}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pl@item}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{New macro \cs{pl@item} used for all
%   \texttt{inpara...} environments}
% \changes{v1.7 (1999/04/01)}{1999/04/01}{Use \cs{nobreakspace} instead of 
%   \texttt{\textasciitilde}}
% \changes{v1.7 (1999/04/01)}{1999/04/01}{Put argument in group to keep 
%   e.\,g.~font changes local}
% \changes{v2.1 (2001/09/20)}{2001/09/16}{Use \cs{makelabel}}
% The following macro is used for all \texttt{inpara...} environments.
% It adds space after the label only when the label has a positive width.
%    \begin{macrocode}
\def\pl@item[#1]{%
  \if@noitemarg
    \@noitemargfalse
    \if@nmbrlist
      \refstepcounter{\@listctr}%
    \fi
  \fi
  \settowidth{\@tempdima}{#1}%
  \ifdim\@tempdima>\z@\makelabel{{#1}}\nobreakspace\fi
  \ignorespaces
  }
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\paradescriptionlabel}
% \changes{v2.1 (2001/09/20)}{2001/09/16}{New macro}
% Similar to the \LaTeX\ macro \cs{descriptionlabel} we define a macro
% for the description environments in and as paragraphs.
%    \begin{macrocode}
\def\paradescriptionlabel#1{{\normalfont\bfseries #1}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\enumlabel}
% \changes{v2.1 (2001/09/20)}{2001/09/16}{New macro}
% \changes{v2.2 (2001/09/30)}{2001/09/23}{Use \cs{hfil} instead of \cs{hss}
%   for flushleft} 
% \changes{v2.2 (2001/09/30)}{2001/09/30}{No need for \cs{llap} in flushright}
% Similar to the \LaTeX\ macro \cs{descriptionlabel} we define a macro
% for the enumerated environments depending on whether the label should be set
% flush left or flush right.
%    \begin{macrocode}
\if@plflushright
  \def\enumlabel#1{\hss#1}
\else
  \def\enumlabel#1{#1\hfil}
\fi
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\itemlabel}
% \changes{v2.1 (2001/09/20)}{2001/09/16}{New macro}
% \changes{v2.2 (2001/09/30)}{2001/09/23}{Use \cs{hfil} instead of \cs{hss}
%   for flushleft} 
% \changes{v2.2 (2001/09/30)}{2001/09/30}{No need for \cs{llap} in flushright}
% Similar to the \LaTeX\ macro \cs{descriptionlabel} we define a macro
% for the itemized environments depending on whether the label should be set
% flush left or flush right.
%    \begin{macrocode}
\if@plflushright
  \def\itemlabel#1{\hss#1}
\else
  \def\itemlabel#1{#1\hfil}
\fi
%    \end{macrocode}
% \end{macro}
%
% \subsection{Adjusting the Label Width}
%
% The width of the label is only adjusted either if the format of the label
% was specified manually and the option \textsf{neveradjust} was \emph{not}
% used or if the option \textsf{alwaysadjust} was used. Then
% |\leftmargin|$\,n$ is set to the width of the label plus |\labelsep|.
% The width of the label is only decreased if the option 
% \textsf{neverdecrease} was \emph{not} used.
%
% \changes{v2.3 (2002/03/10)}{2002/03/07}{New flags to decide on label width
%   adjustment} 
% \changes{v2.4 (2013/06/09)}{2013/06/09}{New flags to decide on wide
%   label width} 
% First we need some flags to indicate whether the label was redefined by the
% environment and whether the label should be adjusted.
%    \begin{macrocode}
\newif\if@plmylabel\@plmylabelfalse
\newif\if@pldoadjust\@pldoadjustfalse
%    \end{macrocode}
%
% \begin{macro}{\@adjust@enum@labelwidth}
% \changes{v1.3 (1999/01/19)}{1999/01/18}{Depending on option
%   \textsf{increaseonly}, \cs{leftmargin}$\,n$ may only be increased} 
% \changes{v2.1 (2001/09/20)}{2001/09/16}{New macro}
% \changes{v2.3 (2002/03/10)}{2002/03/07}{Use new flags}
% \changes{v2.4 (2013/06/09)}{2013/06/09}{Allow arbitrary widest label}
% For the enumerated environments, the counter is first set by default
% to 7 so that we get the width of `vii' if Roman numbering is in
% force.  However, this 7 can be replaced by an arbitrary number as an
% option if this is not large enough.
%    \begin{macrocode}
\def\@adjust@enum@labelwidth{%
  \if@plneveradjust\else
    \if@plalwaysadjust\@pldoadjusttrue\else
      \if@plmylabel\@pldoadjusttrue\fi
    \fi
  \fi
  \if@pldoadjust
    \setcounter{\@enumctr}{\@enum@widestlabel}%
    \settowidth{\@tempdima}{%
      \csname label\@enumctr\endcsname\hspace{\labelsep}}%
%    \end{macrocode}
% \changes{v2.3 (2002/03/10)}{2002/03/10}{Use \cs{@listdepth} for $n$ in
%   \cs{leftmargin}$\,n$} 
% The \cs{leftmargin}$\,n$ has to be adjusted (where $n$ is \cs{@listdepth})
% but we first have to increase \cs{@listdepth} by one since the list has not
% yet started. This is reset right afterwards.
%    \begin{macrocode}
    \advance\@listdepth by 1\relax
    \if@plneverdecrease
      \ifdim\@tempdima >
        \csname leftmargin\romannumeral\@listdepth\endcsname
          \csname leftmargin\romannumeral\@listdepth\endcsname
            \@tempdima
      \fi
    \else
      \csname leftmargin\romannumeral\@listdepth\endcsname
        \@tempdima
    \fi
    \advance\@listdepth by -1\relax
  \fi
  \@pldoadjustfalse
  \@plmylabelfalse}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@adjust@item@labelwidth}
% \changes{v1.3 (1999/01/19)}{1999/01/18}{\cs{leftmargin}$\,n$ adapted 
%   according to the width of the symbol}
% \changes{v1.3 (1999/01/19)}{1999/01/18}{Depending on option 
%   \textsf{increaseonly}, \cs{leftmargin}$\,n$ may only be increased} 
% \changes{v2.1 (2001/09/20)}{2001/09/16}{New macro}
% \changes{v2.3 (2002/03/10)}{2002/03/07}{Use new flags}
% For itemized labels, no counter needs to be set. The label is hidden in a
% macro the name of which is stored in \cs{@itemitem}.
%    \begin{macrocode}
\def\@adjust@item@labelwidth{%
  \if@plneveradjust\else
    \if@plalwaysadjust\@pldoadjusttrue\else
      \if@plmylabel\@pldoadjusttrue\fi
    \fi
  \fi
  \if@pldoadjust
    \settowidth{\@tempdima}{%
      \csname\@itemitem\endcsname\hspace{\labelsep}}%
%    \end{macrocode}
% \changes{v2.3 (2002/03/10)}{2002/03/10}{Use \cs{@listdepth} for $n$ in
%   \cs{leftmargin}$\,n$} 
% The \cs{leftmargin}$\,n$ has to be adjusted (where $n$ is \cs{@listdepth})
% but we first have to increase \cs{@listdepth} by one since the list has not
% yet started. This is reset right afterwards.
%    \begin{macrocode}
    \advance\@listdepth by 1\relax
    \if@plneverdecrease
      \ifdim\@tempdima >
        \csname leftmargin\romannumeral\@listdepth\endcsname
          \csname leftmargin\romannumeral\@listdepth\endcsname
            \@tempdima
      \fi
    \else
      \csname leftmargin\romannumeral\@listdepth\endcsname
        \@tempdima
    \fi
    \advance\@listdepth by -1\relax
  \fi
  \@pldoadjustfalse
  \@plmylabelfalse}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Label of Enumerated Environments}
%
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Added optional argument to all
%   enumerated environments}
% It follows all the stuff for the optional argument of the enumerated
% environments. The code and most of its documentation is basically 
% copied from David Carlisle's \package{enumerate} package.
%
% \begin{macro}{\pl@lab}
% First we define an internal token register which is used to build up
% the label command from the optional argument.
%    \begin{macrocode}
\newtoks\pl@lab
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pl@qmark}
% This just expands to a `?'. \cs{ref} will produce this, if no counter
% is printed.
%    \begin{macrocode}
\def\pl@qmark{?}
%    \end{macrocode}
% \end{macro}
% The next four macros build up the command that will print the 
% label. They each gobble one token or group from the optional argument
% and add corresponding tokens to the register |\pl@lab|. They each end
% with a call to |\pl@loop|, which starts the processing of the next
% token.
% \begin{macro}{\pl@label}
% \changes{v1.8 (1999/04/29)}{1999/04/28}{Count the number of tokens}
% Add the counter to the label. Argument |#2| will be one of the `special'
% tokens |A a I i 1|, and is thrown away. |#1| will be a command
% like \cs{Roman}. In every call \cs{@tempcnta} is increased, so we can 
% check at the end that exactly one counter was defined.
%    \begin{macrocode}
\def\pl@label#1#2{%
  \edef\pl@the{\noexpand#1{\@enumctr}}%
  \pl@lab\expandafter{\the\pl@lab\csname the\@enumctr\endcsname}%
  \advance\@tempcnta1 
  \pl@loop}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pl@space}
% \begin{macro}{\pl@sp@ce}
% Add a space to the label. The tricky bit is to gobble the space token,
% as you can not do this with a macro argument.
%    \begin{macrocode}
\def\pl@space{\afterassignment\pl@sp@ce\let\@tempa= }
\def\pl@sp@ce{\pl@lab\expandafter{\the\pl@lab\space}\pl@loop}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\pl@group}
% Add a |{ }| group to the label.
%    \begin{macrocode}
\def\pl@group#1{\pl@lab\expandafter{\the\pl@lab{#1}}\pl@loop}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pl@other}
% Add anything else to the label.
%    \begin{macrocode}
\def\pl@other#1{\pl@lab\expandafter{\the\pl@lab#1}\pl@loop}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pl@loop}
% \begin{macro}{\pl@loop@}
% The body of the main loop.
% Eating tokens this way instead of using |\@tfor| lets you see
% spaces and \emph{all} braces. |\@tfor| would treat |a| and
% |{a}| as  special, but not |{{a}}|.
%    \begin{macrocode}
\def\pl@loop{\futurelet\pl@temp\pl@loop@}
\def\pl@loop@{%
  \ifx A\pl@temp         \def\@tempa{\pl@label\Alph  }\else
  \ifx a\pl@temp         \def\@tempa{\pl@label\alph  }\else
  \ifx i\pl@temp         \def\@tempa{\pl@label\roman }\else
  \ifx I\pl@temp         \def\@tempa{\pl@label\Roman }\else
  \ifx 1\pl@temp         \def\@tempa{\pl@label\arabic}\else
  \ifx \@sptoken\pl@temp \let\@tempa\pl@space         \else
  \ifx \bgroup\pl@temp   \let\@tempa\pl@group         \else
  \ifx \@@@\pl@temp      \let\@tempa\@gobble          \else  
                         \let\@tempa\pl@other
%    \end{macrocode}
% Hook for possible extensions.
%    \begin{macrocode}
                         \pl@hook
                 \fi\fi\fi\fi\fi\fi\fi\fi
%    \end{macrocode}
% \end{macro}
% Process the current token, then look at the next.
%    \begin{macrocode}
  \@tempa}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pl@hook}
% \changes{v1.6 (1999/03/27)}{1999/03/26}{Added extension hook}
% Hook for possible extensions.
% Some packages may want to extend the number of special characters
% that are associated with counter representations. You can use 
% e.\,g.~Greek or Russian characters. Here is an example of a footnote
% symbol counter, triggered by |*|.
%
% To enable a new counter type based on a letter, you just need
% to add a new |\ifx| clause similar to the code above. To make
% |*| trigger footnote symbol counting do the following.
%
% Initialize the hook, in case the package is loaded before 
% \package{paralist}.\\
% \tab|\providecommand\pl@hook{}|
%
% Add to the hook a new |\ifx| clause that associates |*| with the
% |\fnsymbol| counter command.
%\begin{verbatim}
%   \g@addto@macro\pl@hook{%
%     \ifx *\pl@temp
%       \def\@tempa{\pl@label\fnsymbol}%
%     \fi}
%\end{verbatim}
% This code sequence should work whether it is loaded before or after
% the \package{paralist} package. Any number of new counter types may be added
% in this way.
%
% At this point we just need to initialize the hook, taking care not
% to overwrite any definitions another package may already have added.
%    \begin{macrocode}
\providecommand\pl@hook{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@enumlabel@}
% \changes{v1.8 (1999/04/29)}{1999/04/28}{Use token counter and take care
%   of extra bracket}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Adjustment of label width moved to 
%   a separate macro} 
% \changes{v2.3 (2002/03/10)}{2002/03/07}{Set new flags}
% The following macro handles the optional argument of an enumerated
% environment. Its first argument is the macro that should be called 
% after \cs{@enumlabel@} has done the job, the second one is the
% optional argument from the calling environment.
%    \begin{macrocode}
\def\@enumlabel@#1[#2]{%
%    \end{macrocode}
% The flag is set that the environment redefines its label.
%    \begin{macrocode}
  \@plmylabeltrue
%    \end{macrocode}
% We initialize the number of counter-defining tokens to 0.
% Then \cs{pl@lab} and \cs{pl@the} are initialized. Later, \cs{pl@the}
% will be used to define \cs{theenum}\,$n$.
%    \begin{macrocode}
  \@tempcnta0
  \pl@lab{}%
  \let\pl@the\pl@qmark
%    \end{macrocode}
% Now we analyze the second argument using a loop. 
% As we will explain in the definition of |asparaenum|, we had to add an
% extra bracket |[| to the second argument, which we have to gobble
% before we start processing it. The macro
% \cs{@@@} is never expanded (or even defined), it is just used to detect
% the end of the token list.
%    \begin{macrocode}
  \expandafter\pl@loop\@gobble#2\@@@
%    \end{macrocode}
% If there was no special token or several special tokens we issue a 
% warning. 
%    \begin{macrocode}
  \ifnum\@tempcnta=1\else
    \PackageWarning{paralist}{Incorrect label; no or multiple 
      counters.\MessageBreak The label is: \@gobble#2}%
  \fi
%    \end{macrocode}
% \changes{v2.5 (2015/12/30)}{2015/12/30}{Add \%\ in last line to avoid excess space}
% Define |\labelenum|$\,n$ and |\theenum|$\,n$.  And here we define a
% macro |\@enumwidestlabel@| so that if the document has |[|$n$|]| after
% the beginning of the enumerate environment, the label width will be
% determined by typesetting $n$ instead of the default 7.
%    \begin{macrocode}
  \expandafter\edef\csname label\@enumctr\endcsname{\the\pl@lab}%
  \expandafter\let\csname the\@enumctr\endcsname\pl@the
  \@ifnextchar[{\@enumwidestlabel@{#1}}{\@enumwidestlabel@{#1}[7]}%
}
\def\@enumwidestlabel@#1[#2]{%
  \def\@enum@widestlabel{#2}%
%    \end{macrocode}
% Finally call the macro that finishes the \cs{begin} part of the
% calling environment.
%    \begin{macrocode}
  #1}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Label of the Itemized Environment}
%
% \begin{macro}{\@itemlabel@}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Adjustment of label width moved to 
%   a separate macro} 
% \changes{v2.3 (2002/03/10)}{2002/03/07}{Set new flags}
% The handling of the optional argument of itemized environments is a lot 
% easier.
%     \begin{macrocode}
\def\@itemlabel@#1[#2]{%
  \@plmylabeltrue
  \def\pl@itemitem{#2}%
  \def\@itemitem{pl@itemitem}%
  #1}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Enumerated Environments}
%
% \begin{environment}{asparaenum}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Rewritten}
% \changes{v1.8 (1999/04/29)}{1999/04/28}{Add extra bracket to optional 
%   argument}
% The first environment formats the enumerated items as paragraphs.
% Most of the skips are set to zero, the items are indented as if
% they were paragraphs and |\makelabel| is redefined so that it 
% just prints the counter.
%    \begin{macrocode}
\def\asparaenum{%
  \ifnum\@enumdepth>\thr@@
    \@toodeep
  \else
    \advance\@enumdepth\@ne
    \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
  \fi 
%    \end{macrocode}
% In the following line the second bracket |[| seems to be superfluous.
% Here is why we need it. If \TeX\ finds an argument in curly braces
% then it strips of the braces before handing the argument to the 
% macro \cs{@enumlabel@}. So the optional argument |[{\bfseries a}]|
% would be accepted, although the counter is in a group. By adding
% the bracket to the argument we will never have braces around the
% whole argument. In the macro \cs{@enumlabel@} the bracket is
% gobbled before the processing of the argument starts.
%    \begin{macrocode}
  \@ifnextchar[{\@enumlabel@{\@asparaenum@}[}{\@asparaenum@}} 
\def\@asparaenum@{%
  \expandafter\list\csname label\@enumctr\endcsname{%
    \usecounter{\@enumctr}%
    \labelwidth\z@
    \labelsep.5em
    \leftmargin\z@
    \parsep\parskip
    \itemsep\z@
    \topsep\z@
    \partopsep\parskip
    \itemindent\parindent
    \advance\itemindent\labelsep
    \def\makelabel##1{##1}}}
\let\endasparaenum\endlist
%    \end{macrocode}
% \end{environment}
% \begin{environment}{inparaenum}
% \changes{v1.0a (1998/10/13)}{}{Corrected definition of \cs{theinparaenum}}
% \changes{v1.1 (1998/10/18)}{}{Make space after number non-breaking}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Rewritten}
% \changes{v1.8 (1999/04/29)}{1999/04/28}{Add extra bracket to optional 
%   argument}
% \changes{v2.1 (2001/09/20)}{2001/09/16}{Define \cs{makelabel}}
% Now the enumerated environment within a paragraph. Since it is 
% not really a list we have to redefine |\@item|. 
%    \begin{macrocode}
\def\inparaenum{%
  \ifnum\@enumdepth>\thr@@
    \@toodeep
  \else
    \advance\@enumdepth\@ne
    \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
  \fi
  \@ifnextchar[{\@enumlabel@{\@inparaenum@}[}{\@inparaenum@}}
\def\@inparaenum@{%
  \usecounter{\@enumctr}%
  \def\@itemlabel{\csname label\@enumctr\endcsname}% 
  \let\@item\pl@item
  \def\makelabel##1{##1}%
  \ignorespaces}
\let\endinparaenum\ignorespacesafterend
%    \end{macrocode}
% \end{environment}
% \begin{environment}{compactenum}
% \changes{v1.1 (1998/10/18)}{}{Environment added}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Rewritten}
% \changes{v1.8 (1999/04/29)}{1999/04/28}{Add extra bracket to optional 
%   argument}
% \changes{v2.7 (2017/01/22)}{2017/01/22}{\cs{@enum@widestlabel@} must 
%   be initialized in case \cs{@enumlabel@} is not called}
% For the |compactenum| environment all vertical skips have to
% be set to the \cs{pl...} values.
%    \begin{macrocode}
\def\compactenum{%
  \ifnum\@enumdepth>\thr@@
    \@toodeep
  \else
    \advance\@enumdepth\@ne
    \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
  \fi
  \def\@enum@widestlabel{7}%
  \@ifnextchar[{\@enumlabel@{\@compactenum@}[}{\@compactenum@}} 
%    \end{macrocode}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Adjustment of label width done in
%   \cs{@compactenum@}}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Set label width according to left
%   margin} 
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Use \cs{enumlabel}}
% \changes{v2.3a (2002/03/10)}{2002/03/10}{Use \cs{@listdepth} for $n$ in
%   \cs{leftmargin}$\,n$} 
% The width of the label is adjusted before starting the list if necessary.
%    \begin{macrocode}
\def\@compactenum@{%
  \@adjust@enum@labelwidth
  \expandafter\list\csname label\@enumctr\endcsname{%
    \usecounter{\@enumctr}%
    \parsep\plparsep
    \itemsep\plitemsep
    \topsep\pltopsep
    \partopsep\plpartopsep
    \labelwidth
      \csname leftmargin\romannumeral\@listdepth\endcsname
    \advance\labelwidth-\labelsep
    \let\makelabel\enumlabel}}
\let\endcompactenum\endlist
%    \end{macrocode}
% \end{environment}
% \begin{environment}{enumerate}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Added}
% \changes{v1.8 (1999/04/29)}{1999/04/28}{Add extra bracket to optional 
%   argument}
% \changes{v2.7 (2017/01/22)}{2017/01/22}{\cs{@enum@widestlabel@} must 
%   be initialized in case \cs{@enumlabel@} is not called}
% If the user has requested it, we redefine the |enumerate| environment.
%    \begin{macrocode}
\if@plnewenum
  \def\enumerate{%
    \ifnum \@enumdepth >\thr@@ 
      \@toodeep
    \else
      \advance\@enumdepth \@ne
      \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
    \fi
    \def\@enum@widestlabel{7}%    
    \@ifnextchar[{\@enumlabel@{\@enumerate@}[}{\@enumerate@}} 
%    \end{macrocode}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Adjustment of label width done in
%   \cs{@enumerate@}}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Set label width according to left
%   margin}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Use \cs{enumlabel}}
% \changes{v2.3a (2002/03/10)}{2002/03/10}{Use \cs{@listdepth} for $n$ in
%   \cs{leftmargin}$\,n$} 
% The width of the label is adjusted before starting the list if necessary.
%    \begin{macrocode}
  \def\@enumerate@{%
    \@adjust@enum@labelwidth
    \expandafter\list\csname label\@enumctr\endcsname{%
      \usecounter{\@enumctr}%
      \labelwidth
        \csname leftmargin\romannumeral\@listdepth\endcsname
      \advance\labelwidth-\labelsep
      \let\makelabel\enumlabel}}
\fi
%    \end{macrocode}
% \end{environment}
%
% \subsection{Itemized Environments}
%
% \begin{environment}{asparaitem}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Rewritten}
% This is pretty much the same as |asparaenum|. We just don't need
% a counter. 
%    \begin{macrocode}
\def\asparaitem{%
  \ifnum\@itemdepth>\thr@@
    \@toodeep
  \else
    \advance\@itemdepth\@ne
    \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
  \fi
  \@ifnextchar[{\@itemlabel@{\@asparaitem@}}{\@asparaitem@}}
\def\@asparaitem@{%
  \expandafter\list\csname\@itemitem\endcsname{%
    \labelwidth\z@
    \labelsep.5em
    \leftmargin\z@
    \parsep\parskip
    \itemsep\z@
    \topsep\z@
    \partopsep\parskip
    \itemindent\parindent
    \advance\itemindent\labelsep
    \def\makelabel##1{##1}}}
\let\endasparaitem\endlist
%    \end{macrocode}
% \end{environment}
% \begin{environment}{inparaitem}
% \changes{v1.1 (1998/10/18)}{}{Make space after symbol non-breaking}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Rewritten}
% \changes{v2.1 (2001/09/20)}{2001/09/16}{Define \cs{makelabel}}
% \changes{v2.6 (2016/08/07)}{2016/08/07}{Insert \cs{@nmbrlistfalse} to avoid increasing the enum counter}
% Again the same as |inparaenum| without the counter stuff but with an
% optional argument.  
%    \begin{macrocode}
\def\inparaitem{%
  \@nmbrlistfalse
  \ifnum\@itemdepth>\thr@@
    \@toodeep
  \else
    \advance\@itemdepth\@ne
    \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
  \fi
  \@ifnextchar[{\@itemlabel@{\@inparaitem@}}{\@inparaitem@}}
\def\@inparaitem@{%
  \def\@itemlabel{\csname\@itemitem\endcsname}%
  \let\@item\pl@item
  \def\makelabel##1{##1}%
  \ignorespaces}
\let\endinparaitem\ignorespacesafterend
%    \end{macrocode}
% \end{environment}
% \begin{environment}{compactitem}
% \changes{v1.1 (1998/10/18)}{}{Environment added}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Rewritten}
% The |compactitem| environment is basically the same as the \LaTeX{} 
% original. All the vertical skips are set to the \cs{pl...} values.
%    \begin{macrocode}
\def\compactitem{%
  \ifnum\@itemdepth>\thr@@
    \@toodeep
  \else
    \advance\@itemdepth\@ne
    \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
  \fi
  \@ifnextchar[{\@itemlabel@{\@compactitem@}}{\@compactitem@}}
%    \end{macrocode}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Adjustment of label width done in
%   \cs{@compactitem@}}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Set label width according to left
%   margin} 
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Use \cs{itemlabel}}
% \changes{v2.3a (2002/03/10)}{2002/03/10}{Use \cs{@listdepth} for $n$ in
%   \cs{leftmargin}$\,n$} 
% The width of the label is adjusted before starting the list if necessary.
%    \begin{macrocode}
\def\@compactitem@{%
  \@adjust@item@labelwidth
  \expandafter\list\csname\@itemitem\endcsname{%
    \parsep\plparsep
    \itemsep\plitemsep
    \topsep\pltopsep
    \partopsep\plpartopsep
    \labelwidth
      \csname leftmargin\romannumeral\@listdepth\endcsname
    \advance\labelwidth-\labelsep
    \let\makelabel\itemlabel}}
\let\endcompactitem\endlist
%    \end{macrocode}
% \end{environment}
% \begin{environment}{itemize}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Added}
% If the user has requested it, we redefine the |itemize| environment.
%    \begin{macrocode}
\if@plnewitem
  \def\itemize{%
    \ifnum \@itemdepth >\thr@@
      \@toodeep
    \else
      \advance\@itemdepth\@ne
      \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
    \fi
    \@ifnextchar[{\@itemlabel@{\@itemize@}}{\@itemize@}}
%    \end{macrocode}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Adjustment of label width done in
%   \cs{@itemize@}}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Set label width according to left
%   margin} 
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Use \cs{itemlabel}}
% \changes{v2.3a (2002/03/10)}{2002/03/10}{Use \cs{@listdepth} for $n$ in
%   \cs{leftmargin}$\,n$} 
% The width of the label is adjusted before starting the list if necessary.
%    \begin{macrocode}
  \def\@itemize@{%
    \@adjust@item@labelwidth
    \expandafter\list\csname\@itemitem\endcsname{%
      \labelwidth
        \csname leftmargin\romannumeral\@listdepth\endcsname
      \advance\labelwidth-\labelsep
      \let\makelabel\itemlabel}}
\fi
%    \end{macrocode}
% \end{environment}
%
% \subsection{Descriptive Environments}
%
% \begin{environment}{asparadesc}
% \changes{v2.1 (2001/09/20)}{2001/09/16}{New environment}
% A bit easier than |asparaenum| since the label handling is easier.
%    \begin{macrocode}
\def\asparadesc{%
  \list{}{%
    \labelwidth\z@
    \labelsep.5em
    \leftmargin\z@
    \parsep\parskip
    \itemsep\z@
    \topsep\z@
    \partopsep\parskip
    \itemindent\parindent
    \advance\itemindent\labelsep
    \let\makelabel\paradescriptionlabel}}
\let\endasparadesc\endlist
%    \end{macrocode}
% \end{environment}
% \begin{environment}{inparadesc}
% \changes{v2.1 (2001/09/20)}{2001/09/16}{New environment}
% \changes{v2.6 (2016/08/07)}{2016/08/07}{Insert \cs{@nmbrlistfalse} to avoid increasing the enum counter}
% Again a bit easier than |inparaenum| since the label handling is easier.
%    \begin{macrocode}
\def\inparadesc{%
  \@nmbrlistfalse
  \let\@itemlabel\@empty
  \let\@item\pl@item
  \let\makelabel\paradescriptionlabel
  \ignorespaces}
\let\endinparadesc\ignorespacesafterend
%    \end{macrocode}
% \end{environment}
% \begin{environment}{compactdesc}
% \changes{v1.1 (1998/10/18)}{}{Environment added}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Rewritten}
% The |compactdesc| environment is copied from |article.cls| with the skips
% set to the \cs{pl...} skips. 
%    \begin{macrocode}
\def\compactdesc{%
  \list{}{%
    \parsep\plparsep
    \itemsep\plitemsep
    \topsep\pltopsep
    \partopsep\plpartopsep
    \labelwidth\z@
    \itemindent-\leftmargin
    \let\makelabel\descriptionlabel}}
\let\endcompactdesc\endlist
%    \end{macrocode}
% \end{environment}
%
% \subsection{Blank Environments}
%
% \begin{environment}{asparablank}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Added}
% This list formats its entries as if there was no list. Thus no test for
% the list depth is performed. To avoid unnecessary white space, \cs{labelsep}
% is set to zero. If the optional argument of \cs{item} is used, some
% separating space has to inserted ``by hand''.
%    \begin{macrocode}
\if@pldefblank
  \def\asparablank{%
    \list{}{%
      \labelwidth\z@
      \labelsep\z@  
      \leftmargin\z@
      \parsep\parskip
      \itemsep\z@
      \topsep\z@
      \partopsep\parskip
      \itemindent\parindent
      \advance\itemindent\labelsep
      \def\makelabel##1{##1}}}
  \let\endasparablank\endlist
%    \end{macrocode}
% \end{environment}
% \begin{environment}{inparablank}
% \changes{v1.2 (1999/01/10)}{1999/01/07}{Added}
% The |inparablank| environment handles the ``white space problem'' 
% automatically.
%    \begin{macrocode}
  \def\inparablank{%
    \let\@itemlabel\@empty
    \let\@item\pl@item
    \ignorespaces}
  \let\endinparablank\ignorespacesafterend
\fi
%    \end{macrocode}
% \end{environment}
%
% \subsection{Setting Defaults}
%
% Here are the macros to define the default labels and left margins
% for itemized and enumerated environments.
% \begin{macro}{\setdefaultitem}
% \changes{v2.1 (2001/09/20)}{2001/09/19}{New macro}
% The macro for the item labels just redefines \cs{labelitem}$\,n$.
%    \begin{macrocode}
\def\setdefaultitem#1#2#3#4{%
  \if@empty{#1}{}{\def\labelitemi{#1}}%
  \if@empty{#2}{}{\def\labelitemii{#2}}%
  \if@empty{#3}{}{\def\labelitemiii{#3}}%
  \if@empty{#4}{}{\def\labelitemiv{#4}}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\defaultitem}
% \changes{v1.4 (1999/01/27)}{1999/01/19}{New macro}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Macro deprecated and only kept for
%   compatibility} 
% This macro is deprecated and only kept for backward compatibility.
%    \begin{macrocode}
\def\defaultitem{%
  \PackageWarning{Paralist}{Macro \protect\defaultitem\space
    deprecated. \MessageBreak Use macro \protect\setdefaultitem
    \space instead!! \MessageBreak Used}
  \setdefaultitem} 
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setdefaultenum}
% \changes{v2.1 (2001/09/20)}{2001/09/19}{New macro}
% \changes{v2.3b (2002/03/18)}{2002/03/18}{Fix handling of flags}
% The macro to define the enumerated labels uses the same mechanism
% as the optional argument of the enumerated environments. First, we set
% \cs{@enumctr} to |enum|$\,n$, then \cs{@enumlabel@} is used to format the
% counter. As explained above we have to add the extra bracket |[| to avoid
% losing braces |{}| around the whole argument. Note that the state of
% \cs{if@alwaysadjust} has to be saved and restored.
%    \begin{macrocode}
\newif\if@pltemp
\def\setdefaultenum#1#2#3#4{%
  \if@plneveradjust\@pltemptrue\else\@pltempfalse\fi
  \@plneveradjusttrue
  \if@empty{#1}{}{%
    \def\@enumctr{enumi}%
    \@enumlabel@{\relax}[[#1]}%
  \if@empty{#2}{}{%
    \def\@enumctr{enumii}%
    \@enumlabel@{\relax}[[#2]}%
  \if@empty{#3}{}{%
    \def\@enumctr{enumiii}%
    \@enumlabel@{\relax}[[#3]}%
  \if@empty{#4}{}{%
    \def\@enumctr{enumiv}%
    \@enumlabel@{\relax}[[#4]}%
  \if@pltemp\@plneveradjusttrue\else\@plneveradjustfalse\fi
  \@plmylabelfalse
  \relax}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\defaultenum}
% \changes{v1.4 (1999/01/27)}{1999/01/19}{New macro}
% \changes{v1.8 (1999/04/29)}{1999/04/28}{Add extra bracket to argument of
%   \cs{@enumlabel@}}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Macro deprecated and only kept for
%   compatibility} 
% This macro is deprecated and only kept for backward compatibility.
%    \begin{macrocode}
\def\defaultenum{%
  \PackageWarning{Paralist}{Macro \protect\defaultenum\space
    deprecated. \MessageBreak Use macro \protect\setdefaultenum
    \space instead!! \MessageBreak Used}
  \setdefaultitem} 
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\setdefaultleftmargin}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{New macro}
% Finally a macro to define all the left margins for the lists. 
%    \begin{macrocode}
\def\setdefaultleftmargin#1#2#3#4#5#6{%
  \if@empty{#1}{}{\leftmargini#1}%
  \if@empty{#2}{}{\leftmarginii#2}%
  \if@empty{#3}{}{\leftmarginiii#3}%
  \if@empty{#4}{}{\leftmarginiv#4}%
  \if@empty{#5}{}{\leftmarginv#5}%
  \if@empty{#6}{}{\leftmarginvi#6}%
  \relax}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\defaultleftmargin}
% \changes{v1.4 (1999/01/27)}{1999/01/19}{New macro}
% \changes{v2.1 (2001/09/20)}{2001/09/17}{Macro deprecated and only kept for
%   compatibility} 
% This macro is deprecated and only kept for backward compatibility.
%    \begin{macrocode}
\def\defaultleftmargin#1#2#3#4{%
  \setdefaultleftmargin{#1}{#2}{#3}{#4}{}{}%
  \PackageWarning{Paralist}{Macro \protect\defaultleftmargin
    \space deprecated. \MessageBreak Use macro 
    \protect\setdefaultleftmargin\space instead!! 
    \MessageBreak But note that it has six arguments! 
    \MessageBreak Used}}
%    \end{macrocode}
% \end{macro}
%
% \subsection{Points or no Points?}
%
% \begin{macro}{\pl@pointxxxenum}
% \changes{v2.0a (2001/03/03)}{2001/03/03}{New macro}
% We define macros for the options \textsf{pointlessenum} and
% \textsf{pointedenum}. First the common part consisting of the format of the
% counters itself and the references. The references to an item of level N is
% generated by using |\p@enumN\theenumN|, so we have to make all |\p@enumN|'s
% do nothing. 
%    \begin{macrocode}
\def\pl@pointxxxenum{%
  \def\theenumi{\arabic{enumi}}%
  \def\theenumii{\theenumi.\arabic{enumii}}%
  \def\theenumiii{\theenumii.\arabic{enumiii}}%
  \def\theenumiv{\theenumiii.\arabic{enumiv}}%
  \def\p@enumi{}%
  \def\p@enumii{}%
  \def\p@enumiii{}%
  \def\p@enumiv{}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\pl@pointedenum}
% \changes{v2.0a (2001/03/03)}{2001/03/03}{New macro}
% \begin{macro}{\pl@pointlessenum}
% \changes{v2.0a (2001/03/03)}{2001/03/03}{New macro}
% The format of the labels either adds a point or it doesn't.
%    \begin{macrocode}
\def\pl@pointedenum{%
  \def\labelenumi{\theenumi.}%
  \def\labelenumii{\theenumii.}%
  \def\labelenumiii{\theenumiii.}%
  \def\labelenumiv{\theenumiv.}}
\def\pl@pointlessenum{%
  \def\labelenumi{\theenumi}%
  \def\labelenumii{\theenumii}%
  \def\labelenumiii{\theenumiii}%
  \def\labelenumiv{\theenumiv}}
%    \end{macrocode}
% \end{macro} \end{macro}
% \begin{macro}{\pointedenum}
% \changes{v2.0a (2001/03/03)}{2001/03/03}{New macro}
% \begin{macro}{\pointlessenum}
% \changes{v2.0a (2001/03/03)}{2001/03/03}{New macro}
% Now the user level macros to turn the new feature on.
%    \begin{macrocode}
\def\pointedenum{\pl@pointxxxenum\pl@pointedenum}
\def\pointlessenum{\pl@pointxxxenum\pl@pointlessenum}
%    \end{macrocode}
% \end{macro} \end{macro}
% The options just use those user level macros globally.
%    \begin{macrocode}
\if@plpointedenum\pointedenum\fi
\if@plpointlessenum\pointlessenum\fi
%    \end{macrocode}
%
% \subsection{Configuration File}
%
% \changes{v1.6 (1999/03/27)}{1999/03/26}{Read configuration file in case it 
%   exists}
% Read the file |paralist.cfg| if it exists and the |nocfg| was not given.
%    \begin{macrocode}
\if@plloadcfg
  \InputIfFileExists{paralist.cfg}{%
    \PackageInfo{Paralist}{%
      Using the configuration file paralist.cfg}}{}
\fi
%</package>
%    \end{macrocode}
%
% \Finale