%%
%% This is file `chemscheme.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% chemstyle.dtx  (with options: `chemscheme')
%% ----------------------------------------------------------------
%% The chemstyle bundle --- Schemes and style for chemistry
%% E-mail: joseph.wright@morningstar2.co.uk
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{chemscheme}
  [2011/01/05 v2.0k Schemes for chemistry]
\RequirePackage{kvoptions,psfrag}
\SetupKeyvalOptions{
  family=cst,
  prefix=cst@
}
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname XeTeXrevision\endcsname\relax
\else
  \PackageWarning{chemscheme}
    {XeTeX in use: \string\schemeref\space will not work}
\fi
\@ifclassloaded{achemso}
  {
    \PackageWarning{chemscheme}
      {%
        The chemscheme package should not\MessageBreak
        be used with the achemso class:\MessageBreak
        loading chemscheme will abort%
      }
    \endinput
  }
  {}
\DeclareBoolOption[true]{chemcompounds}
\DeclareComplementaryOption{bpchem}{chemcompounds}
\DeclareBoolOption[true]{floatrow}
\define@key{cst}{tracking}[chemcompounds]{%
  \edef\KVO@param{#1}%
  \@onelevel@sanitize\KVO@param
  \ifx\KVO@param\cst@opt@bpchem
    \expandafter\cst@chemcompoundsfalse
  \else
    \ifx\KVO@param\cst@opt@chemcompounds
      \expandafter\expandafter\expandafter\cst@chemcompoundstrue
    \else
      \expandafter\expandafter\expandafter\cst@opt@ref@error
    \fi
  \fi
}
\newcommand*\cst@opt@bpchem{bpchem}
\newcommand*\cst@opt@chemcompounds{chemcompounds}
\newcommand*\cst@opt@ref@error{%
  \PackageWarning{chemscheme}{%
    Value `\KVO@param' is not supported by\MessageBreak
    option `tracking'%
  }%
}
\newif\ifcst@memoir
\define@key{cst}{floats}{%
  \edef\KVO@param{#1}%
  \cst@floatrowtrue
  \cst@memoirfalse
  \ifx\KVO@param\cst@opt@float
    \expandafter\cst@floatrowfalse
  \else
    \ifx\KVO@param\cst@opt@floatrow\else
      \ifx\KVO@param\cst@opt@memoir
        \expandafter\expandafter\expandafter\expandafter
        \expandafter\expandafter\expandafter\cst@memoirtrue
      \else
        \expandafter\expandafter\expandafter\expandafter
        \expandafter\expandafter\expandafter\cst@opt@floats@error
      \fi
    \fi
  \fi
}
\newcommand*\cst@opt@float{float}
\newcommand*\cst@opt@floatrow{floatrow}
\newcommand*\cst@opt@memoir{memoir}
\newcommand*\cst@opt@floats@error{%
  \PackageWarning{chemscheme}{%
    Value `\KVO@param' is not supported by\MessageBreak
    option `floats'%
  }%
}
\newcommand*\cst@float@pkg{}
\newcommand*\cst@float@execute{}
\newcommand*\cst@float@load{%
  \IfFileExists{floatrow.sty}{}{%
    \ifcst@floatrow
      \expandafter\cst@floatrowfalse
    \fi
  }%
  \ifcst@floatrow
    \expandafter\cst@float@load@floatrow
  \else
    \expandafter\cst@float@load@float
  \fi
}
\newcommand*\cst@float@load@float{%
  \RequirePackage{float}
  \def\cst@float@pkg{float}
  \def\cst@float@execute{\AtBeginDocument}
}
\newcommand*\cst@float@load@floatrow{%
  \RequirePackage{floatrow}
  \def\cst@float@pkg{floatrow}
  \def\cst@float@execute{\@firstofone}
}
\newcommand*\cst@float@chapter@hook{}
\newcommand*\cst@float@chapter{}
\ifx\@chapter\@undefined\else
  \let\cst@float@chapter\@chapter
  \def\@chapter{%
    \cst@float@chapter@hook
    \cst@float@chapter
  }
\fi
\newcommand*\cst@float@chapter@fix{%
  \g@addto@macro{\cst@float@chapter@hook}{%
    \addtocontents{los}{\protect\addvspace{10\p@}}%
  }%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname KOMAScriptVersion\endcsname\relax
    \@namedef{thescheme}{%
      \ifnum\c@chapter>\z@\relax
        \thechapter.%
      \fi
      \arabic{scheme}%
    }%
  \fi
}
\newcommand*\cst@float@make@float{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname chapter\endcsname\relax
    \newfloat{scheme}{tbp}{los}%
  \else
    \newfloat{scheme}{tbp}{los}[chapter]%
    \expandafter\cst@float@chapter@fix
  \fi
  \floatname{scheme}{\schemename}%
  \newcommand*\listofschemes{%
    \listof{scheme}{\listschemename}%
  }%
}
\newcommand*\cst@float@make@floatrow{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname chapter\endcsname\relax
    \DeclareNewFloatType{scheme}{%
      fileext   = los,
      placement = tbp,
      name      = Scheme
    }%
  \else
    \DeclareNewFloatType{scheme}{%
      fileext   = los,
      placement = tbp,
      name      = Scheme,
      within    = chapter
    }%
    \cst@float@chapter@fix
  \fi
  \newcommand*\listofschemes{%
    \listof{scheme}{\listschemename}%
  }%
}
\newcommand*\cst@float@make@memoir{%
  \newfloat[chapter]{scheme}{los}{\schemename}%
  \newlistof{listofschemes}{los}{\listschemename}%
  \addtodef{\@smemfront}{}{\counterwithout{scheme}{chapter}}%
  \addtodef{\@smemmain}{}{%
    \ifartopt\else
      \counterwithin{scheme}{chapter}%
    \fi
  }%
  \addtodef{\backmatter}{}{%
    \ifartopt\else
      \counterwithout{scheme}{chapter}%
      \setcounter{scheme}{0}%
    \fi
  }%
  \newlistentry[chapter]{scheme}{los}{0}%
  \cftsetindents{scheme}{0em}{2.3em}%
  \addtodef{\insertchapterspace}{}{%
    \addtocontents{los}{\protect\addvspace{10pt}}%
  }%
  \ifartopt
    \counterwithout{scheme}{chapter}%
  \fi
}
\ProcessKeyvalOptions{cst}
\@ifpackageloaded{floatrow}{%
  \def\cst@float@pkg{floatrow}
  \def\cst@float@execute{\@firstofone}
}{%
  \@ifpackageloaded{float}{%
    \def\cst@float@pkg{float}
    \def\cst@float@execute{\AtBeginDocument}
  }{%
    \@ifclassloaded{memoir}{%
      \def\cst@float@pkg{memoir}
      \def\cst@float@execute{\AtBeginDocument}
    }{%
      \@ifpackageloaded{chemstyle}{}{%
        \cst@float@load
      }%
    }%
  }%
}
\ifx\cst@float@pkg\cst@opt@memoir
  \let\newfloat\@undefined
\fi
\@ifpackageloaded{chemstyle}{}{%
  \cst@float@execute{\@nameuse{cst@float@make@\cst@float@pkg}}
}
\@ifpackageloaded{floatrow}{}{%
  \newcommand*\schemename{Scheme}
}
\newcommand*\listschemename{List of Schemes}
\AtBeginDocument{%
  \@ifpackageloaded{babel}{%
    \addto{\captionsfrench}{%
      \def\listschemename{Table des sch\`emes}%
      \def\schemename{{\scshape Sch\`eme}}%
    }%
    \addto{\captionsgerman}{%
      \def\listschemename{Schemenverzeichnis}%
      \def\schemename{Schema}%
    }%
    \addto{\captionsngerman}{%
      \def\listschemename{Schemenverzeichnis}%
      \def\schemename{Schema}%
    }%
    \expandafter\selectlanguage\expandafter{\languagename}%
  }{}%
}
\@ifpackageloaded{floatrow}{%
  \newcommand*\floatcontentscentre{%
    \floatsetup{objectset=centering}%
  }
  \newcommand*\floatcontentscenter{%
    \floatsetup{objectset=centering}%
  }
  \newcommand*\floatcontentsright{%
    \floatsetup{objectset=raggedleft}%
  }
  \newcommand*\floatcontentsleft{%
    \floatsetup{objectset=raggedright}%
  }
}{%
  \newcommand*\cst@floatboxreset{}
  \newcommand*\cst@everyfloat{}
  \let\cst@floatboxreset\@floatboxreset
  \def\@floatboxreset{%
    \cst@everyfloat
    \cst@floatboxreset
  }
  \newcommand*{\floatcontentscentre}{%
    \let\cst@everyfloat\centering
  }
  \newcommand*{\floatcontentscenter}{%
    \let\cst@everyfloat\centering
  }
  \newcommand*{\floatcontentsleft}{%
    \let\cst@everyfloat\relax
  }
  \newcommand*{\floatcontentsright}{%
    \let\cst@everyfloat\raggedleft
  }
}
\floatcontentsleft
\newcommand*\schemerefmarker{TMP}
\newcommand*\schemerefformat{\textsf}
\newcount\cst@ref@count
\newcommand*\cst@ref@label{}
\newcommand*\cst@ref@load{%
  \ifcst@chemcompounds
    \RequirePackage{chemcompounds}
    \let\cst@ref@label\compound
  \else
    \RequirePackage{bpchem}
    \let\cst@ref@label\CNlabel
  \fi
}
\@ifpackageloaded{chemstyle}{}{%
  \cst@ref@load
}
\DeclareRobustCommand*\schemeref[2]
  [\schemerefmarker\the\cst@ref@count]{%
  \advance\cst@ref@count\@ne\relax
  \psfrag{#1}[b][b]{%
    \schemerefformat{\cst@ref@label{#2}}%
  }%
}
\DeclareRobustCommand*\chemschemeref[1]{%
  \schemeref[#1]%
}
\DeclareRobustCommand*\schemerefsub[3]
  [\schemerefmarker\the\cst@ref@count]{%
  \advance\cst@ref@count\@ne\relax
  \psfrag{#1}[b][b]{%
    \schemerefformat{\CNlabelsub{#2}{#3}}%
  }%
}
\DeclareRobustCommand*\chemschemerefsub[1]{%
  \schemerefsub[#1]%
}
\newcommand*\cst@ref@check@sub{%
  \@ifpackageloaded{bpchem}{}{%
    \def\schemerefsub[3][]{%
      \PackageWarning{chemscheme}{%
        \string\schemerefsub\space not available unless bpchem
        \MessageBreak package is loaded
      }%
    }%
  }%
}
\AtBeginDocument{\cst@ref@check@sub}

%% 
%% Copyright (C) 2006-2011 by
%%   Joseph Wright <joseph.wright@morningstar2.co.uk>
%% 
%% It may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License (LPPL), either version 1.3c of
%% this license or (at your option) any later version.  The latest
%% version of this license is in the file:
%% 
%%    http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status) by
%%   Joseph Wright.
%% 
%% This work consists of the file  chemstyle.dtx and
%%                                 chemstyle.cdx,
%%           and the derived files chemstyle.pdf,
%%                                 chemstyle.ins,
%%                                 chemstyle.sty,
%%                                 chemscheme.sty,
%%                                 and a number of .cfg files.
%% 
%%
%% End of file `chemscheme.sty'.
