%%
%% This is file `chemscheme.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% chemscheme.dtx  (with options: `package')
%%  ----------------------------------------------------------------
%%  The chemstyle bundle --- Schemes and style for chemistry
%%  Maintained by Joseph Wright
%%  E-mail: joseph.wright@morningstar2.co.uk
%%  Released under the LaTeX Project Public License v1.3 or later
%%  See http://www.latex-project.org/lppl.txt
%%  ----------------------------------------------------------------
%% 
\NeedsTeXFormat{LaTeX2e}
\def\csh@id$#1: #2.#3 #4 #5-#6-#7 #8 #9${%
    #5/#6/#7\space v1.4a\space}
\ProvidesPackage{chemscheme}
  [\csh@id $Id: chemscheme.dtx 48 2008-07-31 19:22:43Z joseph $
   Support for chemical schemes]
\RequirePackage{kvoptions,psfrag,iflang}
\SetupKeyvalOptions{
  family=csh,
  prefix=csh@}
\newif\ifcsh@bpchem
\define@key{csh}{tracking}
  {\csh@bpchemtrue
   \lowercase{\edef\@tempa{#1}}%
   \def\@tempb{bpchem}%
   \ifx\@tempa\@tempb\else
     \def\@tempb{chemcompounds}%
     \ifx\@tempa\@tempb
       \csh@bpchemfalse
     \else
       \PackageError{chemscheme}
         {Unknown value `#1' for option numbers}
         {The `tracking' option accepts values `bpchem'
          and `chemcompounds'}%
     \fi
   \fi}
\DeclareVoidOption{chemcompounds}{\csh@bpchemfalse}
\DeclareVoidOption{bpchem}{\csh@bpchemtrue}
\DeclareVoidOption{chapter}
  {\PackageInfo{chemscheme}
    {Ignoring obsolete option `chapter'}}
\define@key{csh}{floats}
  {\lowercase{\renewcommand*{\csh@fltpkg}{#1}}%
   \def\@tempa{floatrow}%
   \ifx\csh@fltpkg\@tempa\else
     \def\@tempa{float}%
     \ifx\csh@fltpkg\@tempa\else
       \def\@tempa{memoir}%
       \ifx\csh@fltpkg\@tempa
         \@ifclassloaded{memoir}{}
           {\PackageWarning{chemscheme}
            {You asked for floats to be created using memoir,
             \MessageBreak but have used a different document
             class\MessageBreak Using floatrow instead}%
            \renewcommand*{\csh@fltpkg}{floatrow}}%
       \else
         \PackageError{chemscheme}
           {Unknown value `#1' for option numbers}
           {The `floats' option accepts values `float',
            `floatrow' and `memoir'}%
       \fi
     \fi
   \fi}
\@ifpackageloaded{floatrow}
  {\newcommand*{\csh@fltpkg}{floatrow}%
   \define@key{csh}{floats}
     {\PackageInfo{chemscheme}{Package floatrow already
      loaded\MessageBreak Option `floats' disabled}}}
  {\@ifpackageloaded{float}
     {\newcommand*{\csh@fltpkg}{float}%
      \define@key{csh}{floats}
        {\PackageInfo{chemscheme}{Package float already
         loaded\MessageBreak Option `floats' disabled}}}
     {\@ifclassloaded{memoir}
        {\newcommand*{\csh@fltpkg}{memoir}}
        {\newcommand*{\csh@fltpkg}{floatrow}}}}
\ProcessKeyvalOptions{csh}
\newcommand*{\csh@load@memoir}{}
\newcommand*{\csh@load@float}{%
  \@ifpackageloaded{float}{}
    {\let\newfloat\@undefined}
  \RequirePackage{float,caption}}
\newcommand*{\csh@load@floatrow}{%
  \@ifpackageloaded{floatrow}{}
    {\let\newfloat\@undefined}
  \RequirePackage{floatrow,caption}}
\csname csh@load@\csh@fltpkg\endcsname
\newcommand*{\schemename}{Scheme}
\newcommand*{\listschemename}{List of Schemes}
\newcommand*{\csh@makesch@memoir}{%
  \AtBeginDocument{\csh@mksch@memoir}}
\newcommand*{\csh@mksch@memoir}{%
  \newfloat[chapter]{scheme}{los}{\schemename}
  \kill@lastcounter{losdepth}
  \renewcommand*{\thescheme}{\thechapter.\@arabic\c@scheme}
  \addtodef{\@smemfront}{}{\counterwithout{scheme}{chapter}}
  \addtodef{\@smemmain}{}{%
    \ifartopt\else
      \counterwithin{scheme}{chapter}
    \fi}
  \addtodef{\backmatter}{}{%
    \ifartopt\else
      \counterwithout{scheme}{chapter}%
      \setcounter{scheme}{0}%
    \fi}
  \ifartopt
    \counterwithout{scheme}{chapter}%
  \fi
  \newlistof{listofschemes}{los}{\listschemename}
  \kill@lastcounter{losdepth}
  \newlistentry[chapter]{scheme}{los}{0}
  \cftsetindents{scheme}{0em}{2.3em}
  \addtodef{\insertchapterspace}{}%
    {\addtocontents{los}{\protect\addvspace{10pt}}}
  \@ifundefined{c@losdepth}%
    {\newcounter{losdepth}\setcounter{losdepth}{1}}{}}
\newcommand*{\csh@makesch@float}{%
  \AtBeginDocument{\csh@mksch@float}}
\newcommand*{\csh@mksch@float}{%
  \@ifundefined{chapter}
    {\newfloat{scheme}{tbp}{los}}
    {\newfloat{scheme}{tbp}{los}[chapter]%
     \csh@fixchapter}%
  \floatname{scheme}{\schemename}
  \newcommand*{\listofschemes}{%
    \listof{scheme}{\listschemename}}}
\newcommand*{\csh@makesch@floatrow}{%
  \@ifundefined{chapter}
    {\DeclareNewFloatType{scheme}
      {fileext=los,placement=tbp,name=Scheme}}
    {\DeclareNewFloatType{scheme}
      {fileext=los,placement=tbp,name=Scheme,within=chapter}%
     \csh@fixchapter}%
  \newcommand*{\listofschemes}{%
    \listof{scheme}{\listschemename}}}
\newcommand*{\csh@fixchapter}{%
  \@ifundefined{KOMAScriptVersion}
    {\renewcommand*{\thescheme}{%
       \ifnum\c@chapter>\z@ \thechapter.\fi \@arabic\c@scheme}}
    {}%
    \let\csh@chapter\@chapter
    \renewcommand{\@chapter}{%
      \addtocontents{los}{\protect\addvspace{10\p@}}%
      \csh@chapter}}
\csname csh@makesch@\csh@fltpkg\endcsname
\def\@tempa{floatrow}
\ifx\@tempa\csh@fltpkg
  \newcommand*{\floatcontentscentre}{%
    \floatsetup{objectset=centering}}
  \newcommand*{\floatcontentscenter}{%
    \floatsetup{objectset=centering}}
  \newcommand*{\floatcontentsright}{%
    \floatsetup{objectset=raggedleft}}
  \newcommand*{\floatcontentsleft}{%
    \floatsetup{objectset=raggedright}}
\else
  \let\csh@floatboxreset\@floatboxreset
  \renewcommand*{\@floatboxreset}{%
    \csh@everyfloat
    \csh@floatboxreset}
  \newcommand*{\floatcontentscentre}{%
    \let\csh@everyfloat\centering}
  \newcommand*{\floatcontentscenter}{%
    \let\csh@everyfloat\centering}
  \newcommand*{\floatcontentsleft}{%
    \let\csh@everyfloat\relax}
  \newcommand*{\floatcontentsright}{%
    \let\csh@everyfloat\raggedleft}
\fi
\floatcontentsleft
\newif\ifcsh@babel
\@ifpackageloaded{babel}
  {\csh@babeltrue}
  {}
\@ifclassloaded{memoir}{}
  {\@ifpackageloaded{babel}
     {\IfLanguageName{french}
        {\let\floatc@plain\FB@makecaption}
        {\IfLanguageName{frenchb}
          {\let\floatc@plain\FB@makecaption}
          {}}}
  {}}
\AtBeginDocument{
  \@ifpackageloaded{babel}
    {\addto{\captionsngerman}{%
       \renewcommand*{\schemename}{Schema}}
     \addto{\captionsngerman}{%
       \renewcommand*{\listschemename}{Schemenverzeichnis}}
     \addto{\captionsgerman}{%
       \renewcommand*{\schemename}{Schema}}
     \addto{\captionsgerman}{%
       \renewcommand*{\listschemename}{Schemenverzeichnis}}
     \addto{\captionsfrench}{%
       \renewcommand*{\schemename}{\scshape Sch\`eme}}
     \addto{\captionsfrench}{%
       \renewcommand*{\listschemename}{Table des sch\`emes}}
     \addto{\captionsfrenchb}{%
       \renewcommand*{\schemename}{\scshape Sch\`eme}}
     \addto{\captionsfrenchb}{%
       \renewcommand*{\listschemename}{Table des sch\`emes}}
     \expandafter\selectlanguage\expandafter{\languagename}
     \@ifclassloaded{memoir}{}
       {\IfLanguageName{french}
          {\ifcsh@babel\else
             \let\floatc@plain\FB@makecaption
           \fi}
          {\IfLanguageName{frenchb}
            {\ifcsh@babel\else
               \let\floatc@plain\FB@makecaption
             \fi}
          {}}}
      {}}{}}
\newcommand*{\schemerefmarker}{TMP}
\newcommand*{\schemerefformat}{\textsf}
\ifcsh@bpchem
  \RequirePackage{bpchem}
  \let\csh@label\CNlabel
\else
  \RequirePackage{chemcompounds}
  \let\csh@label\compound
\fi
\newcount\csh@num
\newcommand*{\schemeref}{%
  \advance\csh@num\@ne
  \@ifnextchar[%]
    {\csh@schemeref}
    {\csh@schemeref[\schemerefmarker\the\csh@num]}}
\def\csh@schemeref[#1]#2{%
  \psfrag{#1}[b][b]
    {\schemerefformat{\csh@label{#2}}}}
\def\csh@schemerefsub[#1]#2#3{%
  \psfrag{#1}[b][b]
    {\schemerefformat{\CNlabelsub{#2}{#3}}}}
\newcommand*{\chemschemeref}[1]{\schemeref[#1]}
\ifcsh@bpchem
  \newcommand*{\schemerefsub}{%
    \advance\csh@num\@ne
    \@ifnextchar[%]
      {\csh@schemerefsub}
      {\csh@schemerefsub[\schemerefmarker\the\csh@num]}}
  \newcommand*{\chemschemerefsub}[1]{\schemerefsub[#1]}
\else
  \newcommand*{\schemerefsub}[3][]{%
    \advance\csh@num\@ne
    \PackageWarning{chemscheme}
      {`chemcompound' option active\MessageBreak
       Command \string\chemschemerefsub\space not used
       \MessageBreak Please alter your source to \MessageBreak
       \string\chemschemeref}}
  \newcommand*{\chemschemerefsub}{\schemerefsub}
\fi
\endinput
%%
%% End of file `chemscheme.sty'.
