%%
%% This is file `chemscheme.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% chemscheme.dtx  (with options: `package')
%%  ----------------------------------------------------------------
%%  The chemscheme package --- Support for chemical schemes
%%  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}
\ProvidesPackage{chemscheme}%
  [2007/10/04 v1.3 Support for chemical schemes]
\RequirePackage{psfrag,iflang}
\@ifclassloaded{memoir}{}
  {\RequirePackage{float,caption}}
\newif  \ifchemsch@bpchem    \chemsch@bpchemfalse
\DeclareOption{chemcompounds}{\chemsch@bpchemfalse}
\DeclareOption{bpchem}{\chemsch@bpchemtrue}
\DeclareOption{chapter}%
  {\PackageInfo{chemscheme}%
  {Ignoring obsolete option `chapter'}}
\ProcessOptions
\newcommand*{\schemename}{Scheme}
\newcommand*{\listschemename}{List of Schemes}
\@ifclassloaded{memoir}{%
  \AtBeginDocument{%
    \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
  }
}{%
  \AtBeginDocument{%
    \@ifundefined{chapter}{%
      \newfloat{scheme}{tbp}{los}%
    }{%
      \newfloat{scheme}{tbp}{los}[chapter]
      \@ifundefined{KOMAScriptVersion}{%
        \renewcommand*{\thescheme}%
          {\ifnum\c@chapter>\z@ \thechapter.\fi \@arabic\c@scheme}
      }{}
      \let\chemsch@orig@chapter\@chapter
      \def\chemsch@chapter{%
        \addtocontents{los}{\protect\addvspace{10\p@}}%
          \chemsch@orig@chapter}
      \let\@chapter\chemsch@chapter
    }
  }
}
\@ifclassloaded{memoir}
  {\AtBeginDocument{%
    \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}}{}%
    }
  }
  {\floatname{scheme}{\schemename}
    \newcommand*{\listofschemes}{\listof{scheme}{\listschemename}}}
\newcommand*{\floatcontentscentre}%
  {\let\chemsch@everyfloat\centering}
\let\floatcontentscenter\floatcontentscentre
\newcommand*{\floatcontentsleft}%
  {\let\chemsch@everyfloat\relax}
\newcommand*{\floatcontentsright}%
  {\let\chemsch@everyfloat\raggedleft}
\let\chemsch@floatboxreset\@floatboxreset
\floatcontentsleft
\def\@floatboxreset{\chemsch@everyfloat\chemsch@floatboxreset}
\newif  \ifchemsch@babel    \chemsch@babelfalse
\@ifpackageloaded{babel}
  {\chemsch@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}
        {\ifchemsch@babel\else
          \let\floatc@plain\FB@makecaption
        \fi}
        {\IfLanguageName{frenchb}
          {\ifchemsch@babel\else
            \let\floatc@plain\FB@makecaption
          \fi}
          {}}}
      {}
  }{}
}
\newcommand*{\schemerefmarker}{TMP}
\newcommand*{\schemerefformat}{\textsf}
\ifchemsch@bpchem
  \RequirePackage{bpchem}
  \let\chemsch@label\CNlabel
\else
  \RequirePackage{chemcompounds}
  \let\chemsch@label\compound
\fi
\newcount\chemsch@num
\newcommand*{\schemeref}{%
  \advance\chemsch@num\@ne%
  \@ifnextchar[%
    {\chemsch@schemeref}
    {\chemsch@schemeref[\schemerefmarker\the\chemsch@num]}
}
\def\chemsch@schemeref[#1]#2{%
  \wlog{Replaing #1 by #2}%
  \psfrag{#1}[b][b]%
  {\schemerefformat{\chemsch@label{#2}}}%
}
\def\chemsch@schemerefsub[#1]#2#3{%
  \psfrag{#1}[b][b]%
  {\schemerefformat{\CNlabelsub{#2}{#3}}}%
}
\newcommand*{\chemschemeref}[1]{%
  \schemeref[#1]%
}
\ifchemsch@bpchem
  \newcommand*{\schemerefsub}{%
    \advance\chemsch@num\@ne%
    \@ifnextchar[%
      {\chemsch@schemerefsub}
      {\chemsch@schemerefsub[\schemerefmarker\the\chemsch@num]}
  }
  \newcommand*{\chemschemerefsub}[1]{%
    \schemerefsub[#1]%
  }
\else
  \newcommand*{\schemerefsub}[3][]{%
    \advance\chemsch@num\@ne%
    \PackageWarning{chemscheme}%
    {`chemcompound' option active\MessageBreak
      Command \protect\chemschemerefsub\space not used \MessageBreak
      Please alter your source to \MessageBreak
      \protect\chemschemeref}}
  \newcommand*{\chemschemerefsub}[1]{\schemerefsub}%
\fi
\endinput
%%
%% End of file `chemscheme.sty'.
