%% \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         \~}
%\iffalse
%
% (c) copyright  2001-2004 Apostolos Syropoulos
% This software is derived from original software by the LaTeX3 Project.
% This program can be 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.
%
% Please report errors or suggestions for improvement to
%    
%    Apostolos Syropoulos
%    366, 28th October Str.
%    GR-671 00 Xanthi, GREECE
%    apostolo@ocean1.ee.duth.gr or apostolo@obelix.ee.duth.gr
%\changes{v1.1}{2004/07/27}{Added percent symbols to avoid unnecessary
%                           wait space.}
%\fi
% \CheckSum{125}
% \iffalse This is a Metacomment
%
%    \begin{macrocode}
%<*driver>
\documentclass{ltxdoc}
\GetFileInfo{multibbl.drv}
\begin{document}
   \DocInput{multibbl.dtx}
\end{document}
%</driver>
%    \end{macrocode}
% \fi
%
%\title{The ``multibbl'' package}
%\author{Apostolos Syropoulos\\366, 28th October Str.\\
%GR-671 00 Xanthi, HELLAS\\ 
%Email:\texttt{apostolo@obelix.ee.duth.gr}\\ or \\
%\hphantom{Email:}\texttt{apostolo@ocean1.ee.duth.gr}}
% \date{2004/07/27}
%\maketitle
% \begin{abstract}
% The package ``multibbl'' redefines the standard commands bibliographic
% commands so that one can generate multiply reference sections. Each
% section has it own auxiliary file (for use with BibTeX) and title.
% \end{abstract}
%\MakeShortVerb{\|}
%\StopEventually{}
%\section{Introduction}
% This package has been designed for people who write a document that
% has references in languages that use different scripts. For example,
% if one prepares a book in Greek, then his/her document may have 
% references in Greek and in English. In this particular case, it makes
% no sense to sort the references and have only one bibliography section.
% It is better to have two bibliography sections: one for the Greek 
% references and on for the English references. Moreover, it is possible
% to have references in more than two scripts. Then we obviously, need
% three or even more bibliography sections. By the redefining the standard
% \LaTeX\ user interface commands, this package makes it possible to have
% two or more bibliography sections in one document. Naturally, one can
% use this package for documents that use only one script, just in case
% there is a need to have multiply bibliography sections. 
%
% \section{The code}
% 
% As usual, we first have to identify the package:
%    \begin{macrocode}
%<package>
\NeedsTeXFormat{LaTeX2e}[1996/01/01]
\ProvidesPackage{multibbl}[2007/07/27\space v1.1]
\typeout{Package: `multibbl' v1.1\space <2004/07/27> (A. Syropoulos)}
%    \end{macrocode}
%
%\begin{macro}{\newbibliography}
% Now we have to define a new command which has one argument: the name of 
% a new auxiliary file. If that file does not exist, it simply creates 
% this file.
%    \begin{macrocode}
\def\newbibliography#1{\begingroup
  \if@filesw \expandafter\newwrite\csname #1@auxfile\endcsname
  \expandafter\immediate\openout \csname #1@auxfile\endcsname #1.aux\relax
  \typeout{Writing auxiliary file #1.aux }\fi \endgroup}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@citex}
% The command |\@citex| is used internally to process the arguments of
% the |\cite| command. Since, the later command has now two required 
% arguments, the name of an auxiliary file and the usual citation labels,
% we have to redefine the |\@citex| command so that these labels are 
% written into the auxiliary file, just in case we want to generate the
% bibliography with BibTeX. What we actually do is to replace the code
% \begin{verbatim}
% \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
% \end{verbatim}
% with the code
% \begin{verbatim}
%  \@ifundefined{#2@auxfile}{}{\expandafter\immediate%
%        \write\csname #2@auxfile\endcsname{\string\citation{\@citeb}}}%
% \end{verbatim} 
% This code checks whether we have defined the control sequence
% |#2@auxfile|, where |#2| is the first required argument, i.e., the
% name of the auxiliary file, and if it is it writes the citation
% labels to this file.
%    \begin{macrocode}
\def\@citex[#1]#2#3{%
  \let\@citea\@empty
  \@cite{\@for\@citeb:=#3\do
    {\@citea\def\@citea{,\penalty\@m\ }%
     \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
     \@ifundefined{#2@auxfile}{}{\expandafter\immediate%
        \write\csname #2@auxfile\endcsname{\string\citation{\@citeb}}}%
     \@ifundefined{b@\@citeb}{\mbox{\reset@font\bfseries ?}%
       \G@refundefinedtrue
       \@latex@warning
         {Citation `\@citeb' on page \thepage \space undefined}}%
       {\hbox{\csname b@\@citeb\endcsname}}}}{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\bibliography}
% The |\bibliography| command has been redefined to take three required
% arguments: the first is the name of the auxiliary file, the second is
% the argument that the standard command has and the third is the 
% the title of the bibliographic section, i.e., what will appear
% in the running heads, etc. In order to do this, we have to redefine the
% commands |\bibname| and |\refname|, which are used to typeset the running
% heads, etc.
%    \begin{macrocode}
\def\bibliography#1#2#3{%
   \@ifundefined{#1@auxfile}{}{\expandafter\immediate%
     \write\csname #1@auxfile\endcsname{\string\bibdata{#2}}}%
  \def\bibname{#3}%
  \def\refname{#3}%
  \@input@{#1.bbl}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\bibliographystyle}
% The |\bibliographystyle| command has two arguments: the name of an
% auxiliary file and the name of a bibliographic style. With this
% command one can specify the bibliographic style each bibliography section
% will have. Although, at first sight it makes no sense to use different
% bibliographic styles. However, we believe that this feature may be proved
% useful in cases where it is not possible to distinguish to which 
% bibliography section each citation belongs to. 
%    \begin{macrocode}
\def\bibliographystyle#1#2{%
  \ifx\@begindocumenthook\@undefined\else
    \expandafter\AtBeginDocument
  \fi
  \@ifundefined{#1@auxfile}{}{\expandafter\immediate%
     \write\csname #1@auxfile\endcsname{\string\bibstyle{#2}}}}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\nocite}
% The |\nocite| command has been redefined so that it has two required
% arguments: the name of an auxiliary file and the standard argument.
%    \begin{macrocode}
\def\nocite#1#2{\@bsphack
  \@for\@citeb:=#2\do{%
    \edef\@citeb{\expandafter\@firstofone\@citeb}%
    \@ifundefined{#1@auxfile}{}{\expandafter\immediate%
        \write\csname #1@auxfile\endcsname{\string\citation{\@citeb}}}%
    \@ifundefined{b@\@citeb}{\G@refundefinedtrue
        \@latex@warning{Citation `\@citeb' undefined}}{}}%
  \@esphack}
%    \end{macrocode}
%\end{macro}
% Although it is not necessary to explicitly terminate a
% package, we believe it is good practice to do it.
%    \begin{macrocode}
\endinput
%</package>
%    \end{macrocode}
% \section*{Acknowledgment}
% I thank Antonis Tsolomitis for checking this usability of this package. 
% \section*{Dedication}
% To the fond memory of my late brother Mikhail Syropoulos.
% \Finale