% \iffalse
% File paralist.dtx
% Copyright 1998-1999 Bernd Schandl
% email bschand@math.clemson.edu
% www   http://www.math.clemson.edu/~bschand/paralist
%
% 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
% \CheckSum{746}
%% \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}%
          [1999/04/29 v1.8 Some new list environments (BS)]
% \iffalse
%<*driver>
\documentclass[11pt]{ltxdoc}
\usepackage[defblank]{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}}
%
%
% \GetFileInfo{paralist.dtx}
%
% \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{}.}
%   \\ Some New List Environments}
% \author{Bernd Schandl \\ {\small |bschand@math.clemson.edu|}}
% \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}
%   \item[\mdseries\textsf{newitem}] The \LaTeX\ environment |itemize| will be 
%     redefined to have an optional argument to specify the format of the label. 
%     See Section~\ref{sec:format}.
%   \item[\mdseries\textsf{newenum}] The \LaTeX\ environment |enumerate| will be 
%     redefined to have an optional argument to specify the format of the label. 
%     See Section~\ref{sec:format}.
%   \item[\mdseries\textsf{increaseonly}] If an optional argument for one of the
%     enumerated lists is used, \cs{leftmargin}$\,n$, i.\,e.\ the indentation of the
%     \cs{item} text, is made just wide enough for the label. Therefore
%     |\begin{enumerate}| and |\begin{enumerate}[1.]| have different indentation.
%     If this option is specified though, \cs{leftmargin}$\,n$ is never decreased.
%   \item[\mdseries\textsf{defblank}] The two environments |inparablank| and 
%     |asparablank| will be defined. See Section~\ref{sec:blank}.
% \end{compactdesc}
%
% \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 loaded
% \package{paralist} with the options \textsf{newitem} and \textsf{newenum}.
%
% 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.
%
% \section{Defaults for Labels and Margins}
% 
% If you want your lists labeled differently from 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
% if a wide label is specified because this may have side effects on other
% list environments. If you want that change you have to explicitly use
% \cs{defaultleftmargin}.
%
% If in any of the following three macros an argument is empty then
% the according label or margin is left unchanged.
%
% \DescribeMacro{\defaultitem}
% The default labels for itemized environments can be set by using the macro
% \cs{defaultitem} which gets four arguments. To get the \LaTeX\ default labels 
% say\\
% \tab|\defaultitem{\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|\defaultitem{}{$\triangleright$}{}{}|.
%
% \DescribeMacro{\defaultenum}
% The labels for the enumerated lists are formatted  with \cs{defaultenum} using
% the mechanism described in Section~\ref{sec:format}. The \LaTeX\ default labels
% could be defined by\\
% \tab|\defaultenum{1.}{(a)}{i.}{A.}|.\\
% If you want capital Roman letters for level three just say\\
% \tab|\defaultenum{}{}{I.}{}|.
%
% \DescribeMacro{\defaultleftmargin}
% To change the left margin of the lists use \cs{defaultleftmargin}.
% 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|\defaultleftmargin{2.5em}{2.2em}{1.87em}{1.7em}|.\\
% In \textsf{twocolumn} mode \LaTeX\ uses a smaller margin for the first level which
% could be defined by\\
% \tab|\defaultleftmargin{2em}{}{}{}|.
%
% 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.
%
% \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 one 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{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. 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 four, 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 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.
%
% 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 newest version of this package can always be found on CTAN or at
% |http://www.math.clemson.edu/~bschand/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}
% \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{v1.6 (1999/03/27)}{1999/03/27}{Removed \cs{DeclareOption*}}
% First we define the package options.
%    \begin{macrocode}
\newif\if@newitem\@newitemfalse
\newif\if@newenum\@newenumfalse
\newif\if@defblank\@defblankfalse
\newif\if@increaseonly\@increaseonlyfalse
\DeclareOption{newitem}{\@newitemtrue}
\DeclareOption{newenum}{\@newenumtrue}
\DeclareOption{defblank}{\@defblanktrue}
\DeclareOption{increaseonly}{\@increaseonlytrue}
\ProcessOptions\relax
%    \end{macrocode}
% \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}
% \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}
% 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@{#1}\nobreakspace\fi
  \ignorespaces
  }
%    \end{macrocode}
% \end{macro}
% \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}
% 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}
% 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}
% Define |\labelenum|$\,n$ and |\theenum|$\,n$.
%    \begin{macrocode}
  \expandafter\edef\csname label\@enumctr\endcsname{\the\pl@lab}%
  \expandafter\let\csname the\@enumctr\endcsname\pl@the
%    \end{macrocode}
% Set the counter to 7 so that we get the width of `vii' if Roman
% numbering is in force; then set |\leftmargin|$\,n$ to the width of the
% label plus |\labelsep|. 
% \changes{v1.3 (1999/01/19)}{1999/01/18}{Depending on option \textsf{increaseonly}
%   \cs{leftmargin}$\,n$ may only be increased} 
% If the option \textsf{increaseonly} was specified, |\leftmargin|$\,n$ is 
% never decreased.
%    \begin{macrocode}
  \csname c@\@enumctr\endcsname7
  \if@increaseonly
    \settowidth{\@tempdima}{\the\pl@lab\hspace{\labelsep}}%
    \ifdim\@tempdima > 
      \csname leftmargin\romannumeral\@enumdepth\endcsname
        \csname leftmargin\romannumeral\@enumdepth\endcsname
          \@tempdima
    \fi
  \else
    \expandafter\settowidth
      \csname leftmargin\romannumeral\@enumdepth\endcsname
      {\the\pl@lab\hspace{\labelsep}}%
  \fi
%    \end{macrocode}
% Finally call the macro that finishes the \cs{begin} part of the
% calling environment.
%    \begin{macrocode}
  #1}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@itemlabel@}
% The handling of the optional argument of itemized environments is a lot easier.
% \changes{v1.3 (1999/01/19)}{1999/01/18}{\cs{leftmargin}$\,n$ adapted according to 
%   the width of the symbol}
%     \begin{macrocode}
\def\@itemlabel@#1[#2]{%
  \def\pl@itemitem{#2}%  
  \def\@itemitem{pl@itemitem}%
  \if@increaseonly
    \settowidth{\@tempdima}{#2\hspace{\labelsep}}%
    \ifdim\@tempdima > 
      \csname leftmargin\romannumeral\@itemdepth\endcsname
        \csname leftmargin\romannumeral\@itemdepth\endcsname
          \@tempdima
    \fi
  \else
    \expandafter\settowidth
      \csname leftmargin\romannumeral\@itemdepth\endcsname
      {#2\hspace{\labelsep}}%
  \fi
  #1}
%    \end{macrocode}
% \end{macro}
% \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}
% 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
  \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}
% 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
  \@ifnextchar[{\@enumlabel@{\@compactenum@}[}{\@compactenum@}} 
\def\@compactenum@{%
  \expandafter\list\csname label\@enumctr\endcsname{%
    \usecounter{\@enumctr}%
    \parsep\plparsep
    \itemsep\plitemsep
    \topsep\pltopsep
    \partopsep\plpartopsep
    \def\makelabel##1{\hss\llap{##1}}}}
\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}
% If the user has requested it we redefine the |enumerate| environment.
%    \begin{macrocode}
\if@newenum
  \def\enumerate{%
    \ifnum \@enumdepth >\thr@@ 
      \@toodeep
    \else
      \advance\@enumdepth \@ne
      \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
    \fi
    \@ifnextchar[{\@enumlabel@{\@enumerate@}[}{\@enumerate@}} 
  \def\@enumerate@{%
    \expandafter\list\csname label\@enumctr\endcsname{%
      \usecounter{\@enumctr}%
      \def\makelabel##1{\hss\llap{##1}}}}
\fi % \if@newenum
%    \end{macrocode}
% \end{environment}
% \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}
% Again the same as |inparaenum| without the counter stuff, but
% with an optional argument. 
%    \begin{macrocode}
\def\inparaitem{%
  \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
  \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@}}
\def\@compactitem@{%
  \expandafter\list\csname\@itemitem\endcsname{%
    \parsep\plparsep
    \itemsep\plitemsep
    \topsep\pltopsep
    \partopsep\plpartopsep
    \def\makelabel##1{\hss\llap{##1}}}}
\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@newitem
  \def\itemize{%
    \ifnum \@itemdepth >\thr@@
      \@toodeep
    \else
      \advance\@itemdepth\@ne
      \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
    \fi
    \@ifnextchar[{\@itemlabel@{\@itemize@}}{\@itemize@}}
  \def\@itemize@{%
    \expandafter\list\csname\@itemitem\endcsname{%
      \def\makelabel##1{\hss\llap{##1}}}}
\fi % \if@newitem
%    \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}
% \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@defblank
  \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 % \if@defblank
%    \end{macrocode}
% \end{environment}
% Here are the macros to define the default labels and left margins
% for itemized and enumerated environments.
% \begin{macro}{\defaultitem}
% \changes{v1.4 (1999/01/27)}{1999/01/19}{New macro}
% The macro for the item labels just redefines \cs{labelitem}$\,n$.
%    \begin{macrocode}
\def\defaultitem#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}{\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@}}
% The macro to define the enumerated labels uses the same mechanism
% as the optional argument of the enumerated environments. We first
% save the \cs{leftmargin}$\,n$, then set \cs{@enumctr} to |enum|$\,n$,
% let \cs{@enumlabel@} format the counter and finally restore
% \cs{leftmargin}$\,n$. Since we don't want \cs{@enumlabel@} to call 
% any other macro at its end we specify \cs{relax} as its first
% argument. As explained above we have to add the extra bracket |[|
% to avoid losing braces |{}| around the whole argument.
%    \begin{macrocode}
\def\defaultenum#1#2#3#4{%
  \if@empty{#1}{}{%
    \@tempdimb\leftmargini
    \def\@enumctr{enumi}%
    \@enumlabel@{\relax}[[#1]%
    \leftmargini\@tempdimb}%
  \if@empty{#2}{}{%
    \@tempdimb\leftmarginii
    \def\@enumctr{enumii}%
    \@enumlabel@{\relax}[[#2]%
    \leftmarginii\@tempdimb}%
  \if@empty{#3}{}{%
    \@tempdimb\leftmarginiii
    \def\@enumctr{enumiii}%
    \@enumlabel@{\relax}[[#3]%
    \leftmarginiii\@tempdimb}%
  \if@empty{#4}{}{%
    \@tempdimb\leftmarginiv
    \def\@enumctr{enumiv}%
    \@enumlabel@{\relax}[[#4]%
    \leftmarginiv\@tempdimb}%
  \relax}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\defaultleftmargin}
% \changes{v1.4 (1999/01/27)}{1999/01/19}{New macro}
% Finally a macro to define all the left margins for the lists.
%    \begin{macrocode}
\def\defaultleftmargin#1#2#3#4{%
  \if@empty{#1}{}{\leftmargini#1}%
  \if@empty{#2}{}{\leftmarginii#2}%
  \if@empty{#3}{}{\leftmarginiii#3}%
  \if@empty{#4}{}{\leftmarginiv#4}%
  \relax}
%    \end{macrocode}
% \end{macro}
% \changes{v1.6 (1999/03/27)}{1999/03/26}{Read configuration file in case it exists}
% Read the file |paralist.cfg| if it exists.
%    \begin{macrocode}
\InputIfFileExists{paralist.cfg}{%
  \typeout{Using the configuration file paralist.cfg}}{}
%</package>
%    \end{macrocode}
%
% \Finale


 



