From 8f0c39ea0736ec81b5d289f9699c5343cc3c88e3 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sun, 7 Jun 2009 23:22:28 +0000
Subject: chemstyle 2 (6jun09)

git-svn-id: svn://tug.org/texlive/trunk@13659 c570f23f-e606-0410-a88d-b1316a301751
---
 .../texmf-dist/tex/latex/chemstyle/chemscheme.sty  | 534 ++++++++++++---------
 1 file changed, 301 insertions(+), 233 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/chemstyle/chemscheme.sty')

diff --git a/Master/texmf-dist/tex/latex/chemstyle/chemscheme.sty b/Master/texmf-dist/tex/latex/chemstyle/chemscheme.sty
index 461cbe2cb76..3f4e61317ae 100644
--- a/Master/texmf-dist/tex/latex/chemstyle/chemscheme.sty
+++ b/Master/texmf-dist/tex/latex/chemstyle/chemscheme.sty
@@ -4,256 +4,324 @@
 %%
 %% 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.3c or later
-%%  See http://www.latex-project.org/lppl.txt
-%%  ----------------------------------------------------------------
+%% 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}
-\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}
+  [2009/06/06 v2.0 Schemes for chemistry]
+\RequirePackage{kvoptions,psfrag}
 \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}}
+  family=cst,
+  prefix=cst@
+}
+\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}
+      \counterwithin{scheme}{chapter}%
+    \fi
+  }%
   \addtodef{\backmatter}{}{%
     \ifartopt\else
       \counterwithout{scheme}{chapter}%
       \setcounter{scheme}{0}%
-    \fi}
+    \fi
+  }%
+  \newlistentry[chapter]{scheme}{los}{0}%
+  \cftsetindents{scheme}{0em}{2.3em}%
+  \addtodef{\insertchapterspace}{}{%
+    \addtocontents{los}{\protect\addvspace{10pt}}%
+  }%
   \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}
+}
+\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\else
+  \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}%
+    }%
+    \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\csh@everyfloat\centering}
+    \let\cst@everyfloat\centering
+  }
   \newcommand*{\floatcontentscenter}{%
-    \let\csh@everyfloat\centering}
+    \let\cst@everyfloat\centering
+  }
   \newcommand*{\floatcontentsleft}{%
-    \let\csh@everyfloat\relax}
+    \let\cst@everyfloat\relax
+  }
   \newcommand*{\floatcontentsright}{%
-    \let\csh@everyfloat\raggedleft}
-\fi
+    \let\cst@everyfloat\raggedleft
+  }
+}
 \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
+\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-2009 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,
+%% 
 %%
 %% End of file `chemscheme.sty'.
-- 
cgit v1.2.3

