% \newcommand{\lastedit}{2013-12-18 18:19:26 by stolfilocal}

\makeatletter \endlinechar=-1

  % Algorithm bodies. 

  % Example of use:
  % \begin{algorithm}
  %   ...statement of what the algorithm does ...
  % \end{algoritm}
  % \begin{algbody}
  %   \step \label{st.init} $X \gets 0$.
  %   \step While $X < 10$, do:
  %     \begin{block}
  %       \step \label{s.inc} $ X \gets 2 X + 1$.
  %       \step If $X$ is odd:
  %          \begin{block}
  %            ...
  %          \end{block}
  %       \step Print $X$.
  %     \end{block}
  % \end{algbody}
  % 
  % Notes:
  % 
  % * Steps are numbered sequentially, regardless of indentation. 
  % 
  % * This file does not define the {algorithm} environment
  %   because clients may want to define it in various ways,
  %   such as
  %     \newtheorem{algorithm}{Procedure}
  %     \newtheorem{algorithm}{Algorithm}
  %     \newtheorem{algorithm}{Algoritmo}
  %   etc.

  % Program step counter
  \newcounter{algstepnum}
  \newlength{\algstepindent}
  \setlength{\algstepindent}{1.75em}
  
  \newenvironment{algbody}
    {
      \renewcommand{\theenumi}{\arabic{enumi}}
      \renewcommand{\p@enumi}{}
      \renewcommand{\labelenumi}{\arabic{algstepnum}.}
      % 
      \def\step{\refstepcounter{algstepnum}\item}
      \def\comment##1{\item[\hbox to 0pt{\kern -10pt [ \textit{##1} ]\hss}]}
      \list
        {}
	{ 
          \setlength{\leftmargin}{1em}
          \setlength{\rightmargin}{1em}
          
          \setlength{\listparindent}{0pt}
	  \setlength{\itemindent}{0pt}
	  \setlength{\topsep}{0pt}
          \setlength{\partopsep}{0pt}

          \setlength{\labelwidth}{0em}
          \setlength{\labelsep}{0em}
          \setlength{\itemsep}{0pt}
          \setcounter{algstepnum}{0}
          \def\baselinestretch{1.0}
        }
        \item[]
        \begin{block}
    }
    {
        \end{block}
      \endlist
      \vspace{1.5ex}
    }

  \newenvironment{block}
    {
      \list
        {\hbox to 0pt{\arabic{algstepnum}.\hss}}
        { 
          \setlength{\leftmargin}{\algstepindent}
          \setlength{\rightmargin}{0em}
          \setlength{\labelwidth}{0em}
          \setlength{\labelsep}{\algstepindent}
          \setlength{\itemsep}{2pt}
        }
    }
    {
      \endlist
    }

\makeatother \endlinechar=`\^^M
