%% chemcono.sty
   %% Copyright 1996,1999 Stefan Schulz

   % This program can redistributed and/or modified under the terms
   % of the LaTeX Project Public License Distributed from CTAN
   % archives in directory macros/latex/base/lppl.txt; either
   % version 1 of the License, or any later version.
%%%
%%% Acknowledgement: Definitions extracted from latex.ltx and article.cls
%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     author          = "Stefan Schulz",
%%%     version         = "1.3",
%%%     date            = "9 SEP 1999",
%%%     filename        = "chemcono.sty",
%%%     address         = "Institut fuer Organische Chemie, Technische Universitaet
%%%                        Braunschweig, Hagenring 30, D-38106
%%%                        Hamburg, Germany"
%%%     email           = "stefan.schulz@tu-bs.de
%%%     codetable       = "ISO/ASCII",
%%%     keywords        = "chemical compound numbering",
%%%     supported       = "maybe",
%%%     abstract        = "LaTeX style file for using compound numbers
%%%            in chemistry documents. It works like
%%%            \cite and the \thebibliography, using \fcite
%%%            and \theffbibliography instead. It allows compound
%%%            names in documents to be numbered and does not
%%%            affect the normal citation routines.
%%%            Very helpful for writing chemistry papers.
%%%                        This style does:
%%%                        - Compound-numbering. Any compound gets a number
%%%                          using \fcite, bold face as default. This number
%%%              is printed every time you type \fcite.
%%%                        - The compounds are numbered according to the
%%%              entries in the \theffbibliography.
%%%                        - The \ffbibliography generates an chapter with
%%%                          the heading 'Compound numbers'.
%%%                        See comments and examples below.",
%%%  }
%%% ====================================================================
%
% HISTORY:
%
% Writing chemistry papers, very often a consecutive numbering for compounds
% according to their appearance in the text is required. First, I have no
% knowledge of any basic Tex. I extracted the definitions for \cite and
% \thebibliography from latex.ltx and article.cls and replaced every
% occurrence of the string cit by ffcit
% and bib by ffbib. In addition, I also performed some small formatting
% changes. Thus, this package  worked nicely
% in a document with 300 compound numbers and 700 citations in latex209 and latex2e.
%
% Version 1.0
% Latex209.
%
% Version 1.1
% Same thing for Latex2e.
%
% Version 1.2
% Now works with Latex2e of 1996/06/01
%
% Version 1.3
% Added option [tight]. Saves space in the compound number list. Default is [normal].
%
% USAGE:
% Load package chemcono. For every compound, use \fcite like \cite for citations.
% After a \clearpage at the end of your document use theffbibliography like
% the normal thebibliography, with \ffbibitem instead of \bibitem:
%     \begin{theffbibliography}{99}
%     \ffbibitem{f1} danaidone
%     \ffbibitem{f2} thio ether
%     \end{theffbibliography}
% After compilation and printout, discard the last page.
% If you want other formatting than bold face numbers, use
% \renewcommand{\fcite}[1]{\underline{\ffcite{#1}}}
% which gives in this case  an underlined number.
% Look at example.tex.
% The formatting of the ffbibliography can be made tight to save space by the option [tight].
%
% I have added the file drftcono.sty, which bases on the drftcite.sty file from D. Arseneau.
% When using drftcono.sty, you get the tags of the compound numbers instead the real numbers in the text.
% In the compound number section, small superscripts show which label has been used first, second,
% and so on. You have to load drftcono.sty after chemcono.sty. For the final version, just comment
% out drftcono.sty as in example.tex.
% I also added a file showkeysff.sty, which shows labels in the margin as in showkeys, but the \fcite tags
% are also added. I was not able to include counting of occurrence present in drftcono
% in the showkeysff package, which would be highly desirable.
%
%
% COMPLICATIONS:
% You must not use identical labels for \fcite and \cite. Otherwise Latex gets
% confused. As a hint, I identify every compound label by a preceding f as in
% \fcite{f1}, and every citation label with a c, like \cite{c1}.
%
% FUTURE:
% I would like to have the option for removing the printout of
% theffbibliography. Than one would not need to discard the last page.
% Because I have no knowledge of any programming, I do not know how to do
% this. I also do not know whether the  goal of this style could be achieved
% much more easily. Any hints are welcome.
% Inclusion of order of occurrence counting in showkeysff.
%%
%%%
%%%
%%%
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
 \ProvidesPackage{chemcono}
        [1999/09/10 1.3 (SS)]
\DeclareOption{normal}{\let\@openffbib@code\@empty}
\DeclareOption{tight}{\renewcommand{\@openffbib@code}{%
  \setlength{\parsep}{0pt}%
  \setlength{\itemsep}{0pt}%
  \setlength{\topsep}{0pt}%
}}
\ExecuteOptions{normal}
\ProcessOptions
\message{ffbibliography,}
\def\ffbibitem{\@ifnextchar[\@lffbibitem\@ffbibitem}
\def\@lffbibitem[#1]#2{\item[\@ffbiblabel{#1}\hfill]\if@filesw
      {\let\protect\noexpand
       \immediate
       \write\@auxout{\string\ffbibcite{#2}{#1}}}\fi\ignorespaces}
\def\@ffbibitem#1{\item\if@filesw \immediate\write\@auxout
       {\string\ffbibcite{#1}{\the\value{\@listctr}}}\fi\ignorespaces}
\def\ffbibcite{\@newl@bel b}
\let\ffcitation\@gobble
\DeclareRobustCommand\ffcite{%
  \@ifnextchar [{\@tempswatrue\@ffcitex}{\@tempswafalse\@ffcitex[]}}
\def\@ffcitex[#1]#2{%
  \let\@ffcitea\@empty
  \@ffcite{\@for\@ffciteb:=#2\do
    {\@ffcitea\def\@ffcitea{,\penalty\@m\ }%
     \edef\@ffciteb{\expandafter\@firstofone\@ffciteb}%
     \if@filesw\immediate\write\@auxout{\string\ffcitation{\@ffciteb}}\fi
     \@ifundefined{b@\@ffciteb}{\mbox{\reset@font\bfseries ?}%
       \G@refundefinedtrue
       \@latex@warning
         {ffcitation `\@ffciteb' on page \thepage \space undefined}}%
       {\hbox{\csname b@\@ffciteb\endcsname}}}}{#1}}
\let\ffbibdata=\@gobble
\let\ffbibstyle=\@gobble
\def\ffbibliography#1{%
  \if@filesw
    \immediate\write\@auxout{\string\ffbibdata{#1}}%
  \fi
  \@input@{\jobname.bbl}}
\def\ffbibliographystyle#1{%
  \ifx\@begindocumenthook\@undefined\else
    \expandafter\AtBeginDocument
  \fi
    {\if@filesw
       \immediate\write\@auxout{\string\ffbibstyle{#1}}%
     \fi}}
\def\noffcite#1{\@bsphack
  \@for\@ffciteb:=#1\do{%
    \edef\@ffciteb{\expandafter\@firstofone\@ffciteb}%
    \if@filesw\immediate\write\@auxout{\string\ffcitation{\@ffciteb}}\fi
    \@ifundefined{b@\@ffciteb}{\G@refundefinedtrue
        \@latex@warning{ffcitation `\@ffciteb' undefined}}{}}%
  \@esphack}
\expandafter\let\csname b@*\endcsname\@empty
\def\@ffcite#1#2{{#1\if@tempswa , #2\fi}}
\def\@ffbiblabel#1{\textbf{#1}} %ver�ndert von [#1]

\let\l@table\l@figure
\newdimen\ffbibindent
\setlength\ffbibindent{1.5em}
\newenvironment{theffbibliography}[1]
     {\section*{Compound numbers
        \@mkboth{\MakeUppercase Compound numbers}{\MakeUppercase Compound numbers}}%
      \list{\@ffbiblabel{\@arabic\c@enumiv}}%
           {\settowidth\labelwidth{\@ffbiblabel{#1}}%
            \leftmargin\labelwidth
            \advance\leftmargin\labelsep
            \@openffbib@code
            \usecounter{enumiv}%
            \let\p@enumiv\@empty
            \renewcommand\theenumiv{\@arabic\c@enumiv}}%
      \sloppy\clubpenalty4000\widowpenalty4000%
      \sfcode`\.\@m}
     {\def\@noitemerr
       {\@latex@warning{Empty `theffbibliography' environment}}%
      \endlist}
\newcommand{\fcite}[1]{\textbf{\ffcite{#1}}}