%\iffalse -*- doctex -*- \fi
%
%% \RCS$Id: pmn-enum.sty,v 1.2 2004/04/07 22:54:11 turtle Exp $
%% \RCS$Revision: 1.2 $
%% \RCS$Date: 2004/04/07 22:54:11 $
%
%\iffalse metacomment
% -*- swiftex-dtx -*-
%%  $Id: pmn-enum.sty,v 1.2 2004/04/07 22:54:11 turtle Exp $
%%  (C) 2003 Peter Møller Neergaard
%% 
%%  This program may be distributed and/or modified under the
%%  conditions of the LaTeX Project Public License, either version 1.2
%%  of this license or (at your option) any later version.
%%  The latest version of this license is in
%%    http://www.latex-project.org/lppl.txt
%%  and version 1.2 or later is part of all distributions of LaTeX 
%%  version 1999/12/01 or later.
%
% This program consists of the file pmn-enum.sty.
% 
% To print the documentation (which for the moment is uninteresting)
% remove you will have to uncomment all the lines starting with %D%.
% 
%\fi
%
% \CheckSum{10} 
% \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         \~}
%
% \MakeShortVerb{\"}
%
% \title{The \package{pmn-enum} package\thanks
%   {This file has CVS revision \RCSRevision, dated \RCSDate.}}
% \author{Peter Møller Neergaard}
% \maketitle
%
% \begin{abstract}
%   Provides an optional compact enumeration.
% \end{abstract}
% The package provides the  "pmnenumerate" environment that either works
% like a standard "enumerate"  or a more compact format (useful to
% keep a conference paper within the space limit).  For the environment
% to work, there must not be an empty line (resulting in a paragraph
% break) before the \cmd{\item}.  
%
% To use the compact environment, load the package with option
%"compact"; otherwise without any options.
%
% First we announce ourselves to the world and declare the options.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pmn-enum}[2004/03/27 v0.2 pmn-enum]
\DeclareOption{compact}{\PMNCompactEnumtrue}
\newif\ifPMNCompactEnum
\ProcessOptions
%    \end{macrocode}
%
% We either define our special compact environment (if option
% "compact" is chosen); or use the standard "enumerate":
%    \begin{macrocode}
\ifPMNCompactEnum
%    \end{macrocode}
%
% \begin{macro}{\penum@paren@enum}
% \begin{macro}{\penum@paren@enum@i}
%   \mcmd{\penum@paren@enum}\mcs{\meta{the command}} adds parenthesis
%   around the counter output produced by \cs{\meta{the command}}.
%    \begin{macrocode}
\newcommand{\penum@paren@enum}[1]{%
  \expandafter\penum@paren@enum@i\expandafter{#1}{#1}}
\newcommand{\penum@paren@enum@i}[2]{\renewcommand{#2}{(#1)}}
%    \end{macrocode}
%   \cmd{\penum@paren@enum} is used to expand \cs{\meta{the command}}
%   so \cmd{\penum@paren@enum@i} can redefine as \cs{\meta{the
%   command}} as its own expansion parenthesized.
% \changes{v0.2}{2004/04/07}{added}
% \end{macro}^^A \penum@paren@enum@i
% \changes{v0.2}{2004/04/07}{added}
% \end{macro}^^A \penum@paren@enum
%
%  We then define parenthesized versions of the counters.
%    \begin{macrocode}
\penum@paren@enum\theenumi
\penum@paren@enum\theenumii
\penum@paren@enum\theenumiii
%    \end{macrocode}
% \changes{v0.2}{2004/04/07}{adding parenthesis around standard labels}
%
% \begin{macro}{\pmnenumerateitem}
%
%   \mcmd{\pmnenumerateitem} is the \cmd{\item} used inside the
%   compact "pmnenumerate".  It steps the counter and inserts the
%   formatted label.
%    \begin{macrocode}
\newcommand{\pmnenumerateitem}{%
  \ifvmode\PackageError{pmn-enum}{\backslachchar item should not 
be preceded by an empty line}{The compact formatting only works 
if the text is one long paragraph.^^JIf you really want a 
paragraph insert \backslashchar leavevmode before \backslashchar
 item.}
  \else
  \spacefactor=5000
  \fi
  \refstepcounter{\@enumctr}%
  \pmnenum@thecnt\space}
%    \end{macrocode}
% \end{macro}^^A \pmnenumerate
%
% \begin{environment}{pmnenumrate}
%  "pmnenumrate" is mimicked after the setup of "enumerate": it allows
%  only 3 nestings and choose the label formatting based on the level.
%  It defines \cmd{\pmnenum@thecnt} so it prints the counter with the
%  formatting defined by the document class.
%    \begin{macrocode}
\newenvironment{pmnenumerate}{%
  \ifnum \@enumdepth >\thr@@\@toodeep\else
  \leavevmode
  \advance\@enumdepth\@ne
  \edef\@enumctr{enum\romannumeral\the\@enumdepth}%
  \expandafter\let\expandafter\pmnenum@thecnt\csname the\@enumctr\endcsname
  \let\item\pmnenumerateitem
  \usecounter\@enumctr
  \fi}{}
%    \end{macrocode}
%   \cmd{\leavevmode} is used to ensure that we are in horizontal mode.        
%   \cmd{\usecounter} is \LaTeX's standard way of initializing a list counter.
% \end{environment}
% 
%  If the "compact" option is not chosen, this is just the standard
%  "enumerate" environment.
%    \begin{macrocode}
\else%
\let\pmnenumerate\enumerate
\let\endpmnenumerate\endenumerate
\fi%
%    \end{macrocode}
% We need to manipulate the character code of space so we open a group
% \StopEventually
%
% 
% And then commands to typeset the documentation.  All enclosed in
% "<*documentation>"$\ldots$"</documentation>" so we exclude it if we
% ever make a \package{docstrip} file.  For now, we simply stop input
% with \cmd{\endinput} so the file can be used directly as a package
% file.
%    \begin{macrocode}
%<*documentation>
\endinput
\documentclass{pmn-ldoc} 
\newcommand{\docdate}{2004/03/27}
\usepackage[latin1]{inputenc}
 % \OnlyDescription
 % \DisableCrossrefs
\begin{document}
  \DocInput{pmn-enum.sty}
\end{document}
%</documentation>
%    \end{macrocode}
% \Finale \sloppy \PrintChanges
