% \iffalse
\NeedsTeXFormat{LaTeX2e}[1996/10/24]
%<package>\ProvidesPackage{bibtopicprefix}
%<package>         [2006/10/22 v1.10 BibTopicPrefix Package (MS)]
%
%<*driver>
\ProvidesFile{bibtopicprefix.drv}
      [2006/10/18 v1.00 Driver for BibTopicPrefix Package (MS)]
\documentclass{ltxdoc}
\usepackage{url}
\usepackage{bibtopicprefix}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\GetFileInfo{bibtopicprefix.sty}
\EnableCrossrefs
\RecordChanges    % Gather update information
%%\DisableCrossrefs% Say \DisableCrossrefs if index is ready
\CodelineIndex    % Index code by line number
\OnlyDescription  % comment out for implementation details
%%\OldMakeIndex   % use if your MakeIndex is pre-v2.9
\setcounter{IndexColumns}{2}
\setlength{\IndexMin}{40ex}
\setlength{\columnseprule}{.4pt}
\addtolength{\oddsidemargin}{1cm}
\addtolength{\textwidth}{-1cm}
\begin{document}
   \DocInput{bibtopicprefix.dtx}
\end{document}
%</driver>
%
% Copyright 2006 by Martin Schr"oder
% 
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, either version 1.3 of this license
% or (at your option) any later version.  The latest version of this
% license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Martin Schr"oeder.
%
% This work consists of the files bibtopicprefix.dtx and
% bibtopicprefix.ins and the derived file bibtopicprefix.sty
%
% For error reports in case of UNCHANGED versions see bibtopicprefix.ins
%
% \fi
%
% \CheckSum{119}
% ^^A$Id: bibtopicprefix.dtx,v 1.3 2006/10/21 22:52:26 ms Exp $
%
%% \CharacterTable
%% {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%  Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%  Digits        \0\1\2\3\4\5\6\7\8\9
%%  Exclamation   \!     Double quote  \"     Hash (number) \#
%%  Dollar        \$     Percent       \%     Ampersand     \&
%%  Acute accent  \'     Left paren    \(     Right paren   \)
%%  Asterisk      \*     Plus          \+     Comma         \,
%%  Minus         \-     Point         \.     Solidus       \/
%%  Colon         \:     Semicolon     \;     Less than     \<
%%  Equals        \=     Greater than  \>     Question mark \?
%%  Commercial at \@     Left bracket  \[     Backslash     \\
%%  Right bracket \]     Circumflex    \^     Underscore    \_
%%  Grave accent  \`     Left brace    \{     Vertical bar  \|
%%  Right brace   \}     Tilde         \~}
%%
%
%  \pagestyle{headings}
%
%  \newcommand{\bs}           {\texttt{\symbol{'134}}}
%  \newcommand*{\env}[1]      {\textsf{#1}}
%  \newcommand*{\option}[1]   {\textsf{#1}}
%  \newcommand*{\package}[1]  {\textsf{#1}}
%  \newcommand*{\bst}[1]      {\textsf{#1}}
%  \newcommand*{\NEWfeature}[1]{%
%     \hskip 1sp \marginpar{\small\sffamily\raggedright
%     New feature\\#1}}
%  \newcommand*{\NEWdescription}[1]{%
%     \hskip 1sp \marginpar{\small\sffamily\raggedright
%     New description\\#1}}
%
%  \renewcommand{\thefootnote}{\ensuremath{\fnsymbol{footnote}}}
%
% ^^A -----------------------------
%
%  \title{\unskip
%     The \textsf{BibTopicPrefix}-package^^A
%     \thanks{^^A
%        The version number of this file is \fileversion,
%        last revised \filedate.}^^A
%     }
%  \author{Martin Schr\"oder\\[0.5ex]
%          \normalsize  Cr\"usemannallee 3\\
%          \normalsize  28213 Bremen\\
%          \normalsize  Germany\\
%          \normalsize  martin@oneiros.de}
%  \date{\filedate}
%  \maketitle
%
% ^^A -----------------------------
%
%  \begin{abstract}
%     This package provides a way to prefix references from
%     bibliographies produced by the \package{bibtopic}
%     package\cite{bibtopic}.
%  \end{abstract}
%
%
% ^^A -----------------------------
%
%  \tableofcontents
%
% ^^A -----------------------------
%
%  \section{Introduction}
%  ^^A
% Suppose you want to split your literature in your document into
% parts (this can be done with the \package{bibtopic} package) and you
% want to make this split visible in the references in the document.
%
% This package loads \package{bibtopic} with the right option and then
% defines a command \cs{bibprefix} which should be used inside the
% \env{btSect} environment, whose argument is inserted before every
% reference (e.\,g. [1] becomes [\meta{prefix}1]).
%
%
% ^^A -----------------------------
%
%  \section{Usage}
%  ^^A
%  \DescribeMacro{\bibtopic}
% Add an \mbox{\cs{usepackage\{}\package{bibtopicprefix}\texttt{\}}}
% to your document and insert the command \cs{bibprefix}\marg{prefix}
% at the start of every \env{btSect} environment.
%  \begin{quote}
%\begin{verbatim}
%\begin{btSect}{adlit}
%  \renewcommand{\bibprefix}{AD}
%  \section{Applicable Documents}
%  \btPrintCited
%\end{btSect}
%\begin{btSect}{rdlit}
%  \renewcommand{\bibprefix}{RD}
%  \section{Reference Documents}
%  \btPrintCited
%\end{btSect}
%\end{verbatim}
%  \end{quote}
% The package works of course best with bibliography styles that
% produce numerical references (like \bst{plain}).
%
%
% ^^A -----------------------------
%
% \section{Required packages}
% ^^A
% This package requires the following package:
% \begin{description}
%   \item[\normalfont\package{bibtopic}\cite{bibtopic}]
%     It is loaded with the right option so that all bibliographies
%     are numbered indepedently.
%   \item[\normalfont\package{scrlfile}\cite{scrlfile}]
%     \changes{v1.10}{2006/10/22}{Use \package{scrlfile}}
%     This is used internally to handle the
%     \package{hyperref}\cite{hyperref} package.
% \end{description}
%
%
% ^^A -----------------------------
%
% \StopEventually{^^A
%
%
% ^^A -----------------------------
%
% \section{Acknowledgements}
% ^^A
% Developement of this package was financed by the von Hoerner \&
% Sulger GmbH.
%
% ^^A -----------------------------
%
% \begin{thebibliography}{1}
%   \bibitem{babel}
%     Johannes Braams
%     \newblock Babel, a multilingual package for use with \LaTeX's
%       standard document classes
%     \newblock \url{CTAN: tex-archive/macros/latex/required/babel/}.
%   \bibitem{bibtopic}
%     Pierre Basso and Stefan Ulrich
%     \newblock \textsf{bibtopic.sty}
%     \newblock \url{CTAN: tex-archive/macros/latex/contrib/bibtopic/}.
%   \bibitem{hyperref}
%     Sebastian Rahtz and Heiko Oberdiek
%     \newblock Hypertext marks in \LaTeX{}
%     \newblock \url{CTAN: tex-archive/macros/latex/contrib/hyperref/}.
%   \bibitem{scrlfile}
%     Markus Kohm
%     \newblock \textsf{scrlfile.sty}
%     \newblock Part of KOMA-Script.
%     \newblock \url{CTAN: tex-archive/macros/latex/contrib/koma-script/}.
% \end{thebibliography}
% }
%
% ^^A -----------------------------
%
%  \section{The implementation}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%
% ^^A -----------------------------
%
%  \subsection{Loading packages}
%  ^^A
%  We need the \package{scrlfile} package\cite{scrlfile}.
%   \changes{v1.10}{2006/10/22}{Load \package{scrlfile}}
%    \begin{macrocode}
\RequirePackage{scrlfile}
%    \end{macrocode}
%  We need the \package{bibtopic} package\cite{bibtopic} and we have
%  to use the \option{sectcntreset} option to number every
%  bibliography seperately.
%    \begin{macrocode}
\RequirePackage[sectcntreset]{bibtopic}
%    \end{macrocode}
%
% ^^A -----------------------------
%
%  \subsection{The macros}
%  ^^A
% \begin{macro}{\bibprefix}
% \cs{bibprefix} defines the prefix for all references henceforce.
%    \begin{macrocode}
\newcommand{\bibprefix}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@bibitem}
% We want to redefine \cs{\@bibitem} to add our prefix.
% To do this we need to distinguish three cases: the use of the
% \package{hyperref} package, the use of the \package{babel} package
% and the default.
%
% We handle the \package{hyperref} package by activating our code
% after \package{hyperref} with the help of \cs{AfterPackage*} from
% \package{scrlfile}.
%   \changes{v1.10}{2006/10/22}{Handle \package{hyperref}}
%    \begin{macrocode}
\AfterPackage*{hyperref}{%
  \CheckCommand*{\@bibitem}[1]{%
    \@skiphyperreftrue\H@item\@skiphyperreffalse
    \Hy@raisedlink{%
      \hyper@anchorstart{cite.#1}\relax\hyper@anchorend}%
    \if@filesw
      \begingroup
        \let\protect\noexpand
        \immediate\write\@auxout{%
          \string\bibcite{#1}{%
            \the\value{\@listctr}}%
        }%
      \endgroup
    \fi
    \ignorespaces
    }%
  \renewcommand*{\@bibitem}[1]{%
    \@skiphyperreftrue\H@item\@skiphyperreffalse
    \Hy@raisedlink{%
      \hyper@anchorstart{cite.#1}\relax\hyper@anchorend}%
    \if@filesw
      \begingroup
        \let\protect\noexpand
        \immediate\write\@auxout{%
          \string\bibcite{#1}{%
            \bibprefix\the\value{\@listctr}}%
        }%
      \endgroup
    \fi
    \ignorespaces
    }%
  }%
%    \end{macrocode}
%
% If \package{hyperref} is not used, we must distinguish between
% \package{babel} and the default. \package{babel} saves \cs{@bibitem}
% as \cs{org@@bibitem}, so we have to redefine that. 
%   \changes{v1.10}{2006/10/22}{Handle \package{babel}}
%    \begin{macrocode}
\@ifpackageloaded{hyperref}{}{%
  \@ifpackageloaded{babel}
    {%
      \CheckCommand*{\org@@bibitem}[1]{%
        \item\if@filesw \immediate\write\@auxout
          {\string\bibcite{#1}{%
            \the\value{\@listctr}}}%
        \fi\ignorespaces
        }%
      \renewcommand*{\org@@bibitem}[1]{%
        \item\if@filesw \immediate\write\@auxout
          {\string\bibcite{#1}{%
            \bibprefix\the\value{\@listctr}}}%
        \fi\ignorespaces
        }%
    }{%
      \CheckCommand*{\@bibitem}[1]{%
        \item\if@filesw \immediate\write\@auxout
          {\string\bibcite{#1}{%
            \the\value{\@listctr}}}%
        \fi\ignorespaces
        }%
      \renewcommand*{\@bibitem}[1]{%
        \item\if@filesw \immediate\write\@auxout
          {\string\bibcite{#1}{%
            \bibprefix\the\value{\@listctr}}}%
        \fi\ignorespaces
        }%
    }%
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@biblabel}
% We redefine \cs{\@biblabel} to add our prefix.
%    \begin{macrocode}
\renewcommand*{\@biblabel}[1]{[\bibprefix#1]}
%    \end{macrocode}
% \end{macro}
%
%
% ^^A -----------------------------
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%  \Finale
% ^^A vim:tw=70:ts=2:et