%%
%% This is file `alnumsec.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% alnumsec.dtx  (with options: `alnumsec')
%% 
%% Copyright (C) 2003-2007 Frank Küster (frank@kuesterei.ch)
%% 
%% --------------------------------------------------------------------------
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% 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.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%% 
%% This work has the LPPL maintenance status "maintained".
%% 
%% This Current Maintainer of this work is Frank Küster.
%% 
%% This work consists of the files README, alnumsec.ins, alnumsec.dtx,
%% and the derived file alnumsec.sty.
%% 
\ProvidesPackage{alnumsec}
            [2007/07/27 v0.03 alphanumeric section numbers with
            ordinary sectioning commands]
\newif\ifusepreviouslevels\usepreviouslevelsfalse%
\DeclareOption{usehighlevels}{\usepreviouslevelstrue}%
\ProcessOptions%
\RequirePackage{ifthen}%
\providecommand*{\@greek}[1]{\ifcase#1\relax\or$\alpha$\or$\beta$\or
  $\gamma$\or$\delta$\or$\varepsilon$\or$\zeta$\or$\eta$\or$\vartheta$\or
  $\iota$\or$\kappa$\or$\lambda$\or$\mu$\or$\nu$\or$\xi$\or$o$\or$\pi$\or
  $\rho$\or$\sigma$\or$\tau$\or$\upsilon$\or$\varphi$\or$\chi$\or$\psi$\or
  $\omega$\else\@ctrerr\fi}%
\providecommand*{\@doublegreek}[1]{\@greek{#1}{\@greek{#1}}}
\providecommand*{\@doublealph}[1]{\@alph{#1}{\@alph{#1}}}
\newcounter{alnumsec@level}%
\newcounter{fk@secdepth}%
\newcounter{fk@secstart}%
\newcounter{fk@changelevel}\setcounter{fk@changelevel}{20}%
\def\otherseparators#1{%
  \setcounter{fk@changelevel}{#1}
}
\def\alnumsectionlevels#1#2{%
  \setcounter{fk@secstart}{#1}
  \setcounter{alnumsec@level}{#1}%
  \fk@countlevels#2,\relax,%
  \setcounter{fk@secdepth}{\value{alnumsec@level}}%
  \addtocounter{fk@secdepth}{-1}
}
\def\fk@countlevels#1,{%
  \ifx\relax#1%
    \empty%
  \else%
    \expandafter\def\csname fk@levelname\thealnumsec@level\endcsname{#1}%
    \stepcounter{alnumsec@level}%
    \expandafter\fk@countlevels%
  \fi%
}
\def\alnumsecstyle#1{%
  \setcounter{alnumsec@level}{\value{fk@secstart}}%
  \fk@scanstyle#1\relax%
  \setcounter{secnumdepth}{\value{alnumsec@level}}%
  \addtocounter{secnumdepth}{-1}%
  \setcounter{alnumsec@level}{\value{fk@secstart}}%
  \fk@assignstyle%
}%
\def\fk@scanstyle#1{%
  \ifx\relax#1%
    \relax%
  \else%
    \ifnum\c@alnumsec@level>\c@fk@secdepth%
      \PackageError{alnumsec}{%
        more numbering levels than sectioning levels}{%
        You have specified \thealnumsec@level\space different
        numbering styles.\MessageBreak However, only
        \thefk@secdepth\space sectioning commands have been defined,
        down to \csname fk@levelname\thefk@secdepth\endcsname.
      }%
    \else%
      \fk@whichstyle{#1}%
      \stepcounter{alnumsec@level}%
    \fi%
    \expandafter\fk@scanstyle%
  \fi%
}
\newif\iffk@letterknown\fk@letterknownfalse
\def\fk@whichstyle#1{%
  \if R#1%
    \fk@defsecstyle{\thealnumsec@level}{\@Roman}{Roman}%
    \fk@letterknowntrue
  \fi%
  \if r#1%
    \fk@defsecstyle{\thealnumsec@level}{\@roman}{roman}%
    \fk@letterknowntrue
  \fi%
  \if n#1%
    \fk@defsecstyle{\thealnumsec@level}{\@arabic}{arabic}%
    \fk@letterknowntrue
  \fi%
  \if a#1%
    \fk@defsecstyle{\thealnumsec@level}{\@arabic}{arabic}%
    \fk@letterknowntrue
  \fi%
  \if L#1%
    \fk@defsecstyle{\thealnumsec@level}{\@Alph}{Letter}%
    \fk@letterknowntrue
  \fi%
  \if l#1%
    \fk@defsecstyle{\thealnumsec@level}{\@alph}{letter}%
    \fk@letterknowntrue
  \fi%
  \if g#1%
    \fk@defsecstyle{\thealnumsec@level}{\@greek}{greek}%
    \fk@letterknowntrue
  \fi%
  \if d#1%
    \fk@defsecstyle{\thealnumsec@level}{\@doublealph}{doubleletter}%
    \fk@letterknowntrue
  \fi%
  \if b#1%
    \fk@defsecstyle{\thealnumsec@level}{\@doublegreek}{doublegreek}%
    \fk@letterknowntrue
  \fi%
  \iffk@letterknown\else%
    \PackageError{alnumsec}{unknown specifier: #1}{%
      You have given #1 as specifier for the numbering
      scheme.\MessageBreak
      Only the following are known:\MessageBreak
      nrRLldgb
    }
  \fi
}
\def\fk@defsecstyle#1#2#3{%
  \edef\fk@seclevel{\csname fk@levelname#1\endcsname}%
  \expandafter\def\csname fk@\thealnumsec@level num\endcsname{#2}%
  \ifnum\c@alnumsec@level<\c@fk@changelevel%
    \expandafter\def%
      \csname fk@pre@\thealnumsec@level\expandafter\endcsname\expandafter{%
      \csname fk@pre@#3\endcsname}%
    \expandafter\def%
      \csname fk@post@\thealnumsec@level\expandafter\endcsname\expandafter{%
      \csname fk@post@#3\endcsname}%
  \else%
    \expandafter\def%
      \csname fk@lower@pre@\thealnumsec@level\expandafter\endcsname\expandafter{%
      \csname fk@lower@pre@#3\endcsname}%
    \expandafter\def%
      \csname fk@lower@post@\thealnumsec@level\expandafter\endcsname\expandafter{%
      \csname fk@lower@post@#3\endcsname}%
  \fi%
}%
\def\fk@assignstyle{%
  \edef\fk@secname{\csname fk@levelname\thefk@secstart\endcsname}%
  \expandafter\@namedef{the\fk@secname\expandafter}\expandafter{%
    \csname fk@pre@\thealnumsec@level\expandafter\endcsname%
    \csname fk@\thefk@secstart num\expandafter\endcsname%
    \csname c@\fk@secname\expandafter\endcsname%
    \csname fk@post@\thealnumsec@level\expandafter\endcsname%
  }%
  \whiledo{%
    \c@alnumsec@level<\c@secnumdepth%
  }{%
    \stepcounter{alnumsec@level}%
    \let\fk@previoussecname\fk@secname%
    \edef\fk@secname{%
      \csname fk@levelname\thealnumsec@level\endcsname}%
    \ifusepreviouslevels%
      \ifnum\c@alnumsec@level<\c@fk@changelevel%
        \expandafter\@namedef{the\fk@secname\expandafter}\expandafter{%
          \csname the\fk@previoussecname\expandafter\endcsname
          \csname fk@pre@\thealnumsec@level\expandafter\endcsname%
          \csname fk@\thealnumsec@level num\expandafter\endcsname%
          \csname c@\fk@secname\expandafter\endcsname%
          \csname fk@post@\thealnumsec@level\endcsname}%
      \else%
        \expandafter\@namedef{the\fk@secname\expandafter}\expandafter{%
          \csname the\fk@previoussecname\expandafter\endcsname
          \csname fk@lower@pre@\thealnumsec@level\expandafter\endcsname%
          \csname fk@\thealnumsec@level num\expandafter\endcsname%
          \csname c@\fk@secname\expandafter\endcsname%
          \csname fk@lower@post@\thealnumsec@level\endcsname}%
      \fi%
    \else%
      \expandafter\@namedef{p@\fk@secname\expandafter}\expandafter{%
        \csname p@\fk@previoussecname\expandafter\endcsname
        \csname the\fk@previoussecname\endcsname}%
      \ifnum\c@alnumsec@level<\c@fk@changelevel%
        \expandafter\@namedef{the\fk@secname\expandafter}\expandafter{%
          \csname fk@pre@\thealnumsec@level\expandafter\endcsname%
          \csname fk@\thealnumsec@level num\expandafter\endcsname%
          \csname c@\fk@secname\expandafter\endcsname%
          \csname fk@post@\thealnumsec@level\endcsname}%
      \else%
        \expandafter\@namedef{the\fk@secname\expandafter}\expandafter{%
          \csname fk@lower@pre@\thealnumsec@level\expandafter\endcsname%
          \csname fk@\thealnumsec@level num\expandafter\endcsname%
          \csname c@\fk@secname\expandafter\endcsname%
          \csname fk@lower@post@\thealnumsec@level\endcsname}%
      \fi%
    \fi%
  }%
}
\def\define@surroundstyle#1{%
  \@namedef{surround#1}{%
    \@ifnextchar [{%]
      \csname opt@surround#1\endcsname}{%
      \csname nopt@surround#1\endcsname}%
  }%
  \@namedef{opt@surround#1}[##1]{%
    \@ifnextchar [{%]
      \csname dopt@surround#1\endcsname[##1]}{%
      \csname @opt@surround#1\endcsname[##1]}
  }
  \@namedef{dopt@surround#1}[##1][##2]##3##4{%
    \@namedef{fk@lower@pre@#1}{##1}%
    \@namedef{fk@lower@post@#1}{##2}%
    \@namedef{fk@pre@#1}{##3}%
    \@namedef{fk@post@#1}{##4}%
  }
  \@namedef{@opt@surround#1}[##1]##2##3{%
    \relax
    \@namedef{fk@lower@pre@#1}{##1}%
    \@namedef{fk@pre@#1}{##2}%
    \@namedef{fk@post@#1}{##3}%
    \expandafter\let%
      \csname fk@lower@post@#1\expandafter\endcsname%
      \csname fk@post@#1\endcsname%
  }
  \@namedef{nopt@surround#1}##1##2{%
    \@namedef{fk@pre@#1}{##1}%
    \@namedef{fk@post@#1}{##2}%
    \expandafter\let%
      \csname fk@lower@pre@#1\expandafter\endcsname%
      \csname fk@pre@#1\endcsname%
    \expandafter\let%
      \csname fk@lower@post@#1\expandafter\endcsname%
      \csname fk@post@#1\endcsname%
  }
}
\define@surroundstyle{Roman}
\define@surroundstyle{roman}
\define@surroundstyle{Letter}
\define@surroundstyle{letter}
\define@surroundstyle{arabic}
\define@surroundstyle{doubleletter}
\define@surroundstyle{greek}
\define@surroundstyle{doublegreek}
\newif\iffk@chapterdefined%
\@ifundefined{chapter}{%
  \fk@chapterdefinedfalse%
  \setcounter{fk@secstart}{1}%
  \setcounter{fk@secdepth}{5}%
  \alnumsectionlevels{1}{section,subsection,subsubsection,paragraph,subparagraph}%
}{%
  \fk@chapterdefinedtrue%
  \setcounter{fk@secstart}{0}%
  \setcounter{fk@secdepth}{5}%
  \alnumsectionlevels{0}{chapter,section,subsection,subsubsection,paragraph,subparagraph}%
}
\iffk@chapterdefined%
  \def\fk@pre@chapter{}%
  \def\fk@post@chapter{.}%
\fi
\surroundRoman{}{.}
\surroundroman{}{.}
\surroundarabic{}{.}
\surroundLetter{}{.}
\surroundletter[(]{}{)}
\surroundgreek[(]{}{)}
\surrounddoubleletter[(]{}{)}
\surrounddoublegreek[(]{}{)}
\endinput
%%
%% End of file `alnumsec.sty'.
