1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068
|
% \CheckSum{394}
%
% \iffalse
%% Package `multibib' to use with LaTeX2e.
%% Copyright (C) 2003 by Thorsten Hansen. All rights reserved.
%%
%
%<*dtx>
\ProvidesFile{multibib.dtx}
%</dtx>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{multibib}
%<driver>\ProvidesFile{multibib.drv}
% \fi
% \ProvidesFile{multibib.dtx}
[2004/01/28 v1.3 Multiple bibliographies for one document.]
%
% \iffalse
%<*driver>
\documentclass{ltxdoc}
\usepackage{ifthen}
%
% Sort `General before macros starting with `@'.
%
\makeatletter
\def\changes@#1#2#3{%
\protected@edef\@tempa{\noexpand\glossary{#1\levelchar
\ifx\saved@macroname\@empty
\space
\actualchar
\generalname
\else
\space % <-- \space added
\expandafter\@gobble
\saved@macroname
\actualchar
\string\verb\quotechar*%
\verbatimchar\saved@macroname
\verbatimchar
\fi
:\levelchar #3}}%
\@tempa\endgroup\@esphack}
\makeatother
%
%
%
\CodelineIndex
\RecordChanges
%\OnlyDescription
\begin{document}
\DocInput{multibib.dtx}
\end{document}
%</driver>
% \fi
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \newcommand{\class}[1]{\textsf{#1}}
% \newcommand{\option}[1]{\textsf{#1}}
% \newcommand{\komascript}{KOMA-\textsc{Script}}
% \newcommand{\package}[1]{\textsf{#1}}
% \newcommand{\macrott}[1]{\texttt{\symbol{'134}#1}}
% \renewcommand*\descriptionlabel[1]{\hspace\labelsep\option{#1}}
%
% ^^A
% ^^A A rule to separate figures from the text.
% ^^A (Modified code from bibtopic.dtx).
% ^^A
% \newcommand\toprule[1][]{^^A
% \ifthenelse{\equal{#1}{}}{^^A
% \noindent{\makebox[\textwidth][t]{\hrulefill}}^^A
% }{%
% \noindent{\makebox[\textwidth][t]{\hrulefill^^A
% \raisebox{-.5ex}{ \small\ttfamily#1 }\hrulefill}}^^A
% }%
% \par\noindent}
%
% \newcommand\bottomrule{\noindent\rule[\baselineskip]{\textwidth}{.6pt}}
%
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \hyphenation{bib-lio-gra-phy bib-lio-gra-phies}
%
% \GetFileInfo{multibib.dtx}
% \title{The \textsf{multibib} Package}
% \author{Thorsten Hansen\\
% \normalsize thorsten.hansen@psychol.uni-giessen.de}
% \date{\fileversion\quad \filedate}
% \maketitle
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% \GlossaryPrologue{\section*{{Change History}}%
% \markboth{{Change History}}{{Change History}}%
% Version numbers suffixed with characters have not
% been released.}
% \def\levelchar{-}
%
% \changes{v1.0}{1999/07/27}{Initial version}
% \changes{v1.1}{1999/01/14}{Documentation.}
% \changes{v1.1a}{2001/10/06}{Equivalents of macros \macrott{citep} and
% \macrott{citet} added.}
% \changes{v1.1b}{2001/10/10}{Evoke \package{multibib}'s \macrott{@citex}
% variant not for standard \macrott{cite}
% commands.}
% \changes{v1.1c}{2001/10/16}{Equivalents of macros \macrott{citealp} and
% \macrott{citealt} added.}
% \changes{v1.1d}{2001/11/04}{Spurious letters occurring for bibstyle
% \textsf{alpha} removed.}
% \changes{v1.1e}{2001/11/04}{Additional definition of \macrott{refname}
% in \macrott{newcites} loop.}
% \changes{v1.2}{2003/03/24}{Documentation.}
% \changes{v1.2a}{2003/07/15}{General compatibility mechanism for packages
% which redefine \macrott{@citex}, motivated
% by compatibility to \package{cite} v4.0.}
% \changes{v1.2b}{2003/09/22}{General compatibility mechanism for packages
% which define their own cite commands, motivated by
% compatibility to \package{jurabib}.}
% \changes{v1.2c}{2004/01/23}{Streamline code.}
% \changes{v1.3}{2004/01/24}{Documentation.}
%
%
%
%
% \begin{abstract}
% The \package{multibib} package allows to create references to
% multiple bibliographies within one document. It thus provides a
% complementary functionality to packages like \package{bibunits} or
% \package{chapterbib}, which allow to create one bibliography for
% multiple, but different parts of the document. The package
% introduces the generic macro |\newcites| which generates
% user-defined citation and bibliography commands for each new
% bibliography in the document. The new commands can be used
% intuitively, since both syntax and semantics are similar to their
% standard \LaTeX\ equivalents. Each bibliography can have its
% individual style and \BibTeX\ data file(s). Citations to each
% bibliography are collected in a new auxiliary file to be processed
% by \BibTeX. The \package{multibib} package is compatible with
% \package{cite}, \package{inlinebib}, \package{jurabib} (to be
% loaded before \package{multibib}), \package{natbib},
% \package{suthesis} and \komascript\ classes.
% \end{abstract}
%
%
%
%
% \section{Usage Notes}
%
% Suppose, you have to separate your citations into two bibliographies,
% one for primary literature and one for secondary literature. The
% \package{multibib} package defines the |\newcite| command which
% introduces a new new family of cite and bibliography commands.
% \begin{verbatim}
% \newcites{sec}{Secondary Literature}
% \end{verbatim}
% In this case the generic macro defines four new commands,
% suffixed by the first argument.
% \begin{verbatim}
% \citesec
% \nocitesec
% \bibliographystylesec
% \bibliographysec
% \end{verbatim}
% The second argument of |\newcites| provides the title of the corresponding
% bibliography. All these new commands accept the same parameters as
% their standard \LaTeX\ equivalents and behave analogous to.---In the
% example above, the bibliography for primary literature can be
% generated by \LaTeX's standard commands. When the document is
% processed, an auxiliary file |sec.aux| is generated, which needs to
% be compiled through \BibTeX.
%
% The tiny \verb|\newcites| command is not limited to one bibliography.
% In fact, you can generate as much bibliographies as you like (only
% limited by the maximum number of \TeX's output files, usually~16).
% In the following example, separate bibliographies are created for
% own articles, submitted articles, internal reports, and other work.
% \begin{verbatim}
% \newcites{own,submitted,internal}%
% {Own Work,%
% Submitted Work,%
% {Technical Reports, Master Theses and Ph.D. Theses}}
% \end{verbatim}
% Note that a title containing commas needs to be grouped. Again, the
% bibliography for other work is generated by \LaTeX's standard
% commands.
%
% \DescribeMacro{\newcites}
% After this introductory examples, let's look at the precise
% definition of |\newcites|. The command
% |\newcites|\marg{suffix\_list}\marg{heading\_list} defines a new
% family of commands for each suffix~\meta{s} in \meta{suffix\_list},
% namely |\cite|\meta{s}, |\nocite|\meta{s},
% |\bibliographystyle|\meta{s}, and |\bibliography|\meta{s} . The
% \meta{suffix\_list} is a comma separated list of letters, i.e, the
% same characters which are allowed as part of a \TeX\ command. The
% \meta{heading\_list} is a comma separated list of words, i.e, the
% same sort of input (including commands) that can be used as argument
% of, e.g., |\section|. The commands |\cite|\meta{s} and
% |\nocite|\meta{s} generate citations that appear in the
% corresponding bibliography which is generated by
% |\bibliography|\meta{s}. The title of this bibliography is defined
% by the entry \meta{h} in \meta{heading\_list} at the same position
% as \meta{s} in \meta{suffix\_list}. The individual style of the
% bibliography can be defined by |\bibliographystyle|\meta{s}.
%
% \DescribeMacro{\setbiblabelwidth}
% When using numerical reference schemes like, e.g., \textsf{plain},
% the labels in the bibliography have sometimes the wrong width. In
% this case you can set the desired label width using
% |\setbiblabelwidth|\marg{number}, in the same fashion as you would
% specify the label width with |\thebibliography|\marg{number}.
%
% It is also possible to let \LaTeX\ do the job by using
% \package{multibib}'s variant \textsf{mbplain} instead of
% \textsf{plain} as bibliography style. The modification does not
% affect the formatting style but only internal values, such that
% \LaTeX\ can determine the right width. More precisely,
% \textsf{mbplain} sets the longest label to the number of entries in
% the bibliography, while \textsf{plain} takes the smallest number
% which has the same width as the number of entries. For example, if
% your bibliography has 29~entries, \textsf{plain} sets the label to
% 10 while \textsf{mbplain} sets the label to~29. This is done by
% modifying the function \texttt{longest.label.pass}.
% \begin{verbatim}
% FUNCTION {longest.label.pass}
% { number.label int.to.str$ 'label :=
% number.label #1 + 'number.label :=
% label width$ longest.label.width >
% label width$ longest.label.width = %% added in mbplain
% or %% added in mbplain
% { label 'longest.label :=
% label width$ 'longest.label.width :=
% }
% 'skip$
% if$
% }
% \end{verbatim}
% If you use other numerical styles than \textsf{plain}, you can
% customize your favorite style accordingly.
%
%
%
% \subsection{Package Options}
% \begin{description}
% \item[resetlabels] When using numerical reference schemes,
% start each bibliography with~`[1]'. Default is continuous numbering,
% such that labels are created unambiguously.
% \end{description}
%
%
%
% \subsection{\textnormal{\BibTeX} Processing}
%
% For each bibliography a corresponding auxiliary file \meta{s}|.aux|
% is generated, that needs to be compiled through \BibTeX. This can be
% done by the following bash-script.
% \begin{verbatim}
% #!/bin/bash
% for file in *.aux ; do
% bibtex `basename $file .aux`
% done
% \end{verbatim}
%
%
%
% \subsection{Limitations}
%
% \begin{itemize}
% \item When using numerical reference schemes and references to the
% same item appear in different bibliographies, the labels
% cannot be resolved properly. Rather, the replacement text
% (i.e, the number) is used which is defined in the auxiliary
% file read last.
% \item When using author-year reference schemes, entries with the
% same author and year combinations which appear in different
% bibliographies get the same label.
% In this case you have to manually add some hints to which
% bibliography the entry refers, e.g.,\\
% |\cite[in primary literature]{Foo:1999a}| vs.\ \\
% |\citesec[in secondary literature]{Foo:1999b}|.\\
% You can also edit the |.bbl| files created by \BibTeX\ and
% add `a', `b',\dots\ to the labels, but your changes will
% be overwritten by subsequent \BibTeX\ runs. The
% differentiating letters `a', `b',\dots\ cannot be added
% automatically by \BibTeX\ since the entries appear in
% different auxiliary files.
% \item With \package{natbib}, you cannot use numerical and
% author-year reference schemes together. Typographically, this
% is regarded bad style anyway.
% \item For \package{jurabib} and \package{multibib}, the order of
% loading is important: \package{jurabib} must be loaded before
% \package{multibib}.
% \end{itemize}
%
%
%
%
% \section{Example}
%
% Let's now consider a complete example with two bibliographies, one
% for \TeX\ and \LaTeX\ references and one for Postscript references.
% For demonstration purposes, different styles are used for the two
% references, namely \textsf{alpha} for \TeX\ and \LaTeX\ references and
% \textsf{plain} for Postscript references. Typographically, different
% bibliography styles are regarded as bad and therefore should be
% avoided in real documents. The reference data are supposed to be
% stored in a common \BibTeX\ data file |lit.bib|. Note that the
% heading of the Postscript references is redefined with
% |\renewcommand{\refname}|.
% \begin{figure}[h]
% \hspace*{-25mm}\begin{minipage}[t]{0.6\textwidth}
% \toprule
% {\let\small\footnotesize
% \begin{verbatim}
% \documentclass{article}
% \usepackage{multibib}
% \newcites{ltex}{\TeX\ and \LaTeX\ References}
%
% \begin{document}
% References to the \TeX book \citeltex{Knuth:1991}
% and to Lamport's \LaTeX\ book, which appears
% only in the references\nociteltex{Lamport:1994}.
% Finally a cite to a Postscript tutorial
% \cite{Adobe:1985}.
%
% \bibliographystyleltex{alpha}
% \bibliographyltex{lit}
%
% \renewcommand{\refname}{Postscript References}
% \bibliographystyle{plain}
% \bibliography{lit}
%
% \end{document}
% \end{verbatim}}
% \bottomrule
% \end{minipage}
% \hspace{5mm}
% \begin{minipage}[t]{0.65\textwidth}
% \toprule
% \leftmargini1mm
% \begin{quote}
% \footnotesize
% References to the \TeX book \cite{Knuth:1991}
% and to Lamport's \LaTeX\ book, which appears
% only in the references\nocite{Lamport:1994}.
% Finally a cite to a Postscript tutorial
% \cite{Adobe:1985}.
% {\let\section\subsubsection
% \renewcommand{\refname}{\TeX\ and \LaTeX\ References}
% \begin{thebibliography}{Lam94}
% \bibitem[Knu91]{Knuth:1991}
% Donald~E. Knuth.
% \newblock {\em The {\TeX} book}.
% \newblock Addison-Wesley, Reading, Massachusetts, 1991.
% \bibitem[Lam94]{Lamport:1994}
% Leslie Lamport.
% \newblock {\em {\LaTeX:} A Document Preparation System}.
% \newblock Addison-Wesley, Reading, Massachusetts, 2 edition, 1994.
% \end{thebibliography}}
% {\let\section\subsubsection
% \renewcommand{\refname}{Postscript References}
% \begin{thebibliography}{1}
% \bibitem{Adobe:1985}
% {Adobe {S}ystem {I}ncorporated}.
% \newblock {\em Postscript Language Tutorial and Cookbook}.
% \newblock Addison-Wesley, Reading, Massachusetts, 1985.
% \end{thebibliography}}
% \end{quote}
% \vspace{3.25mm}
% \bottomrule
% \end{minipage}
% \caption{Example input and output.}
% \end{figure}
%
% To process your document, three runs of \LaTeX\ and two runs of \BibTeX\
% are required.
%
% \vbox{%
% \begin{verbatim}
% latex mydoc
% bibtex mydoc
% bibtex ltex
% latex mydoc
% latex mydoc
% \end{verbatim}}
%
%
%
%
% \section{Notes for Class and Package Writers}
%
% Packages such as \package{cite} or \package{natbib} which modify the
% internal macro |\@citex| called from |\cite| by, e.g., changing
% the number of arguments, and/or define new variants of |\cite|, such as
% \package{natbib}'s |\citep|, deserve a special handling to ensure
% combatibility to \package{multibib}. In the first case, the problem
% arise because \package{multibib}'s redefinition of |\@citex| to write to
% a new auxiliary file |\@newciteauxhandle| instead of writing to
% |\@auxout| is overwritten. In the second case, the problem arise
% because \package{multibib} is unaware of additional cite commands and
% thus cannot define the new variants. The problems can
% be solved by using the compatibility mechanisms
% supported by \package{multibib} as described in the following.
%
%
%
% \subsection{Packages which modify \macrott{@citex}}
%
% Packages which modify |\@citex| can be made compatible to
% \package{multibib} by making the following three changes to the code:
% \begin{enumerate}
% \item Add the following code:
% \begin{verbatim}
% \providecommand\@newciteauxhandle{\@auxout}
% \def\@restore@auxhandle{\gdef\@newciteauxhandle{\@auxout}}
% \AtBeginDocument{%
% \@ifundefined{newcites}{\global\let\@restore@auxhandle\relax}{}}
% \end{verbatim}
% The first line defines |\@newciteauxhandle| to the default value
% |\@auxout| if |\@newciteauxhandle| is not already defined. The
% second line defines macro |\@restoreauxhandle| which sets
% |\@newciteauxhandle| to its default value. The next two lines
% |\let| macro |\@restoreauxhandle| to |\relax| in case
% \package{multibib} is not loaded and |\newcites| is undefined.
% \item In the redefinitions of |\@citex| replace |\@auxout| by
% |\@newciteauxhandle|.
% \item At the end of the each |\@citex| redefinitions add the macro
% |\@restoreauxhandle|.
% \end{enumerate}
% At present, packages \package{cite} and \package{jurabib} use this
% combatibility mechanism.
%
%
%
% \subsection{Packages which define new cite commands}
%
% Packages which define new cite commands can add these commands using
% |\@mb@citenamelist|. The default definition, which
% already includes \package{natbib}'s cite variants, is given below.
% \begin{verbatim}
% \def\@mb@citenamelist{cite,citep,citet,citealp,citealt}
% \end{verbatim}
% A package which defines, e.g, a new cite command |\footcite| informs
% \package{multibib} about this command by defining
% \begin{verbatim}
% \def\@mb@citenamelist{cite,citep,citet,citealp,citealt,footcite}
% \end{verbatim}
% At present, package \package{jurabib} use this combatibility mechanism.
%
%
%
% \subsection{Advantages of the compatibility mechanism}
%
% Compared to a solution where all compatibility patching is done by
% \package{multibib}, such as is presently the case for
% \package{natbib}, the above solution has several advantages:
% \begin{enumerate}
% \item The mechanisms provides a general solution for several
% packages. Any new package can be made compatible with \package{multibib}
% without the need for a new release of \package{multibib}.
% \item Existing packages can change the number of arguments to
% |\@citex| or introduce new cite macros without the need to change
% \package{multibib}.
% \item If |\@citex| needs to read the next input character, this
% character is available and not masked by \package{multibib}'s |let|s
% which follow the |\@std@citex|. This is important for the
% \package{cite} package.
% \item More efficient code. A single |\let| in |\@restore@auxhandle|
% instead of four.
% \end{enumerate}
%
%
%
%
% \section{Brief Discussion of Related Packages}
%
% \paragraph{Similar packages.} The \package{bibtopic} package addresses the
% same issue as the present package, using a completely different
% approach. The user has to provide a separate \BibTeX\ data file
% |liti.bib| for each bibliography and can generate the corresponding
% bibliography within a |btSect| environment.
%
% \begin{verbatim}
% \begin{btSect}{liti}
% \btPrintCited
% \end{btSect}
% \end{verbatim}
%
% Using |\btPrintNotCited|, a complementary bibliography showing all
% entries not cited in the document can also be generated.
% Additionally, an environment |btunit| is defined to generate
% bibliographies for different units of the text, thus partly
% offering the functionality of packages like \package{bibunits} or
% \package{chapterbib}. Besides its powerful functionality, the
% \package{bibtopic} package has some drawbacks and restrictions:
% \begin{itemize}
% \item less intuitive user interface
% \item the user has to split his \BibTeX\ data files
% \item bibliography styles that put some material between the begin
% of\\ |thebibliography| and the first |\bibitem| deserve a
% special handling
% \item does not work with bibliography style |unsorted|
% \item and more, see Sec.~`Restrictions' of the \package{bibtopic}
% documentation
% \end{itemize}
%
% Finally, due to its large size (1059 lines) and implementation
% approach, processing is probably slower. In a nutshell,
% \package{bibtopic} does the following: for each bibliography, a
% |\citation{*}| command is written to a new, corresponding auxiliary
% file, such that \emph{all} entries of the \BibTeX\ data base are
% extracted. Then, by reimplementing the |\bibitem| command, all items
% which do not occur in a special list of labels, produced by the cite
% commands, are deleted. Obviously, doing part of \BibTeX's work
% requires some amount of memory and time (and programming skills,
% noteworthy |;-)|).
%
%
% \paragraph{Complementary packages.} The packages \package{bibunits}
% and \package{chapterbib} provide commands to generate multiple
% bibliographies, too. The main difference is, that with these
% packages a single bibliography is generated for multiple, but
% different parts of the text. Therefore, within a certain unit, i.e.,
% part of the text, citations can only be made to a single,
% corresponding bibliography. On the other hand, with
% \package{multibib}, within the same (but single) part, citations can
% be generated for multiple bibliographies.
%
% \paragraph{Analogous packages.} The \package{multind} package allows
% multiple indexes.
%
%
%
%
% \section{Acknowledgments}
%
% The author thanks Donald Arseneau for suggesting the compatibility mechanism
% for packages which modify |\@citex|. Further, the author
% acknowledges the contributions of numerous people, in particular
% Jens Berger and Frank Mittelbach, whose suggestions and bug reports have
% helped to improve \package{multibib}.
%
%
%
%
% \StopEventually{\PrintIndex\PrintChanges}
%
%
%
%
% \section{The Macros}
%
% One paradigm with guided the development of the code was to use
% standard \LaTeX\ commands as much as possible, and to customize their
% behavior using |\let|.
%
%
% \begin{macrocode}
%<*package>
% \end{macrocode}
%
%
% \subsection{Option Handling}
% \changes{v1.0i}{2000/01/12}{New option \option{resetlabels}.}
%
% \begin{macro}{\ifcontinuouslabels}
% Define a new if to switch between continuous labeling of
% bibliographies (default) and start of labels with~`[1]'. The latter
% can be activated with option \option{resetlabels}.
% \begin{macrocode}
\newif\ifcontinuouslabels
\continuouslabelstrue
\DeclareOption{resetlabels}{\continuouslabelsfalse}
\ProcessOptions
% \end{macrocode}
% \end{macro}
%
%
% \subsection{Preliminaries}
%
% \begin{macro}{\mylop}
% \begin{macro}{\mylopoff}
% Variation of |\lop|, using `|,|' as separator instead of `|\|'
% to extract the elements in the first argument of |\newcites|
% (cf.~The \TeX book, p. 378).
% \begin{macrocode}
\def\mylop#1\to#2{\expandafter\mylopoff#1\mylopoff#1#2}
\long\def\mylopoff#1,#2\mylopoff#3#4{\def#4{#1}\def#3{#2}}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@newciteauxhandle}
% \changes{v1.1b}{2001/10/10}{Handle removed.}
%
% Define a new handle of the auxiliary file for
% all |\cite| and |\nocite| commands, standard as well as newly
% defined. For the standard commands, this handle is let to
% |\auxout|. Since version 1.1b the definition
% |\let\@newciteauxhandle\@auxout| is no longer needed since
% below we reset |\@citex| to its standard value after each call of
% |\mb@@citex|.
% \end{macro}
%
%
% \begin{macro}{\std@@citex}
% \begin{macro}{\mb@@citex}
% \changes{v1.0f}{2000/01/10}{Update to \package{natbib} v7.0:
% save \macrott{@auxout} before
% redefinition instead of encapsulation
% in braces.}
% \changes{v1.1b}{2001/10/10}{\macrott{global} setting of
% \macrott{@save@auxout}; setting of \macrott{newciteauxhandle}
% removed; instead, reset \macrott{citex} to its standard
% version.}
% \changes{v1.2a}{2003/07/15}{New definition of \macrott{mb@@citex}
% only if \macrott{@newciteauxhandle} is not already
% defined by compatible packages.}
%
%
% Definitions of |\mb@@citex| to replace |\@citex| in the definition of
% the various |cite| commands. The idea is to write to a specific file
% referred to |\@newciteauxhandle| instead of |\@auxout|. Below in the
% definition of the specific |\cite<s>| and |\nocite<s>| commands,
% |\@newciteauxhandle| is set to the new auxiliary files |<s>.aux|. If
% |\@newciteauxhandle| is already defined by compatible packages, simply
% |\let| macro |\mb@@citex| to |\@citex|
%
% If \package{natbib} is loaded, a variant of |\@citex| with an
% additional optional argument is needed. Macro |\NAT@set@cites|
% invokes \package{natbib}'s |\cite| and |\@citex| definitions.
% \begin{macrocode}
\AtBeginDocument{%
\@ifpackageloaded{natbib}{%
\NAT@set@cites
\let\std@@citex\@citex
\def\mb@@citex[#1][#2]#3{%
\global\let\@save@auxout\@auxout
\let\@auxout\@newciteauxhandle
\std@@citex[#1][#2]{#3}%
\let\@auxout\@save@auxout
\let\@citex\std@@citex}%
}{% else
\@ifundefined{@newciteauxhandle}{% not defined by compatible packages
\let\std@@citex\@citex
\def\mb@@citex[#1]#2{{%
\let\@auxout\@newciteauxhandle
\std@@citex[#1]{#2}}%
\let\@citex\std@@citex}%
}{\let\mb@@citex\@citex}%
}%
}%
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@newusecounter}
% \begin{macro}{\newusecounter}
% Do not reset counter to zero at begin of bibliography. This
% generates continuous numbering of references through all new
% bibliographies to ensure that numerical references are created
% unambiguously. To reset the counter only for the \emph{first}
% bibliography, |\newusecounter| is initially let to |\usecounter|.
% Below, in the definition of the new bibliographies,
% |\newusecounter| is let to |\@newusecounter|.
% \begin{macrocode}
\def\@newusecounter#1{\@nmbrlisttrue\def\@listctr{#1}}
\let\newusecounter\usecounter
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\std@bibliography}
% \begin{macro}{\bibliography}
% \changes{v1.0a}{1999/07/27}{Continuous numbering also for
% \macrott{bibliography}.}
% \changes{v1.0i}{2000/01/12}{Change to respond to option
% \option{resetlabels}.}
%
% To ensure continuous numbering, the |\newusecounter| is
% redefined also for the standard |\bibliography|, same as for the
% new |\bibliography|\meta{s} macros.
% \begin{macrocode}
\let\std@bibliography\bibliography
\def\bibliography#1{%
\ifcontinuouslabels
\let\usecounter\newusecounter
\fi
\std@bibliography{#1}%
\ifcontinuouslabels
\global\let\newusecounter\@newusecounter
\fi}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\mb@biblabelwidth}
% \begin{macro}{\setbiblabelwidth}
% \changes{v1.0e}{1999/12/12}{New macro.}
%
% The macro |\setbiblabelwidth| explicitly sets the width of the
% labels in the bibliography. An internal counter
% |\mb@biblabelwidth| is introduced and a macro |\setbiblabelwidth|
% which simply assigns its argument to the new counter. The value
% of the counter is then used in \package{multibib}'s modification
% of |\thebibliography|.
% \begin{macrocode}
\newcount\mb@biblabelwidth
\newcommand\setbiblabelwidth[1]{\mb@biblabelwidth #1}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\std@thebibliography}
% \begin{macro}{\thebibliography}
% \changes{v1.0b}{1999/07/30}{Correct label width for numerical
% reference schemes.}
% \changes{v1.0e}{1999/12/12}{Works with \macrott{setbiblabelwidth}.}
% \changes{v1.0i}{2000/01/14}{No change of label width for option
% \option{resetlabels}.}
% \changes{v1.0k}{1999/01/14}{\package{suthesis} compatibility.}
%
% The argument of |\thebibliography| determines the width of the
% labels in the bibliography. First it is checked if the parameter
% is a number. If it is not a number, we do not have to care about
% setting label widths and can simply call |\std@thebibliography|.
% Otherwise we check if the label width is not set explicitly,
% i.e., |\mb@biblabelwidth=0|. In this case the label width is determined
% as the the last label in the previous bibliography |\c@enumiv|
% plus the number of labels in the current bibliography |#1|
% (provided the bibliography style computes the values right,
% like \textsf{mbplain}). If the value is set explicitly
% by~|\mb@biblabelwidth|, this value is used and then reset to zero
% such that only the labels in the current bibliography are affected.
%
% \begin{macrocode}
\AtBeginDocument{%
\@ifpackageloaded{suthesis}%
{\def\thebibliography#1{%
\newpage
\addcontentsline{toc}{chapter}{\bibname}%
\@ldthebibliography{#1}}}%
{}%
\let\std@thebibliography\thebibliography
\def\thebibliography#1{%
\@isnumber{#1}%
{\ifnum\mb@biblabelwidth=0
\@tempcnta\c@enumiv
\ifcontinuouslabels
\advance\@tempcnta#1%
\fi
\std@thebibliography{\@arabic\@tempcnta}%
\else
\std@thebibliography{\@arabic\mb@biblabelwidth}%
\global\mb@biblabelwidth 0
\fi}%
{\std@thebibliography{#1}}%
}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\@isnumber}
% \changes{v1.0g}{2000/01/10}{Empty string is not handled as number.}
% \changes{v1.1d}{2001/01/04}{Execute \macrott{@scannumber} in
% \macrott{hbox}.}
%
% Macro |\@isnumber| behaves as follows: If |#1| is a number (which
% may contain blanks at arbitrary positions), |#2| is executed,
% else |#3|.
%
% \begin{macrocode}
\newcommand{\@isnumber}[3]{%
\def\argi{#1}%
\ifx\argi\empty
#3
\else
\global\@tempswafalse
\setbox\@tempboxa=\hbox{\@scannumber#1\plugh}%
\if@tempswa#2\else#3\fi
\fi}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@scannumber}
% \changes{v1.1d}{2001/01/04}{Initialize \macrott{plugh} with
% \macrott{relax}; simply \macrott{relax}
% when the \macrott{testchar} is not a digit
% instead of \macrott{@gobbletillplugh}.}
%
% Macro |\@scannumber| evaluates the single characters
% of its argument. If all characters are digits or
% blanks,|\@scannumber| is recursively evoked until it finally
% reads |\plugh| which marks the end of the argument (in
% macro |\@isnumber|) and sets |\@tempswatrue| which is then used
% in |\@isnumber|. If the tested character is not a digit, the
% macro exits, leaving |\@tempswa| unchanged.
%
% \begin{macrocode}
\let\plugh\relax
\newcommand{\@scannumber}[1]{%
\let\testchar#1%
\ifx \testchar 0\let\next\@scannumber
\else\ifx \testchar 1\let\next\@scannumber
\else\ifx \testchar 2\let\next\@scannumber
\else\ifx \testchar 3\let\next\@scannumber
\else\ifx \testchar 4\let\next\@scannumber
\else\ifx \testchar 5\let\next\@scannumber
\else\ifx \testchar 6\let\next\@scannumber
\else\ifx \testchar 7\let\next\@scannumber
\else\ifx \testchar 8\let\next\@scannumber
\else\ifx \testchar 9\let\next\@scannumber
\else\ifx \testchar \plugh \let\next\relax \global\@tempswatrue
\else \let\next\relax
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
\next}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@gobbletillplugh}
% \changes{v1.1d}{2001/01/04}{Macro removed.}
%
% Macro |\@gobbletillplug| gobbles all input up to (and including)
% |\plugh| by defining |\def\@gobbletillplugh#1\plugh{}|. Since
% version 1.1d, |\@scannumber| is evaluated in a |\hbox| and the
% gobbling is no longer needed.
% \end{macro}
%
%
% \begin{macro}{\mb@addtocontents}
% \changes{v1.0d}{1999/08/19}{Add bibliography name to table of contents.}
%
% Some styles like \package{suthesis} or \komascript\ classes like
% \class{scrartcl} with option \option{bibtotoc} redefine
% |\bibliography| such that the heading of the bibliography appears
% in the table of contents. Entries for the table of contents are
% generated by writing the appropriate information to |\@auxout|.
% Because |\@auxout| is locally redefined when the bibliography is
% read, entries go to the wrong file. Therefore, a macro
% |\mb@addtocontents| is introduced which writes to |\temp@auxout|.
% Below, in the definition of the new |\bibliography|\meta{s},
% |\mb@addtocontents| replaces the standard |\addtocontents|, and
% |\temp@auxout| is set to the default |\@auxout|.
% \begin{macrocode}
\long\def\mb@addtocontents#1#2{%
\protected@write\temp@auxout
{\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}%
{\string\@writefile{#1}{#2}}}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\bibname}
% \changes{v1.0h}{2000/01/10}{Changed to evoke \macrott{refname} instead.}
% \changes{v1.0j}{2000/01/13}{New implementation: Check if
% \macrott{bibname} is undefined
% instead of checking if class
% \class{book} or \class{report} is loaded.}
% \changes{v1.1e}{2001/01/04}{Macro removed.}
%
% Package~\package{multibib} redefines the headings of the new
% bibliographies using |\refname|. Some classes like \class{book} and
% \class{report} use |\bibname| instead of |\refname|. Instead of
% changing the definition of |\bibname|, we simply define
% |\refname| in the same was as |\bibname| in the |newcites| loop below.
% \end{macro}
%
%
% \begin{macro}{\@mb@citenamelist}
% \changes{v1.2b}{2003/09/22}{Macro added.}
%
% Define list of cite commands to be processed within the
% |\newcites| loop below. If already defined by other packages,
% |\relax|.
% \begin{macrocode}
\@ifundefined{@mb@citenamelist}%
{\def\@mb@citenamelist{cite,citep,citet,citealp,citealt}}%
{\relax}
% \end{macrocode}
% \end{macro}
%
%
%
% \subsection{The \texttt{newcites} loop}
%
% \begin{macro}{\newcites}
% Loop over all headings in \meta{heading\_list}. The current
% heading is stored in |\@newrefname|, the corresponding suffix is
% stored in |\@suffix|.
% \begin{macrocode}
\def\newcites#1#2{%
\def\@suffixlist{#1,}%
\@for\@newrefname:=#2\do{%
\mylop\@suffixlist\to\@suffix
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@refname<s>}
% Define the reference title |\protected|, such that the title can
% contain control sequences as, e.g., in the title `\LaTeX\
% References'.
% \begin{macrocode}
\expandafter\protected@edef\csname refname\@suffix\endcsname
{\@newrefname}%
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@auxout<s>}
% \begin{macro}{\@auxout<s>name}
% \changes{v1.0c}{1999/08/19}{\macrott{makeatletter} when input new
% auxiliary files.}
%
% Define new write. Input the auxiliary file if it exists before
% opening it, to read the replacement text for the |\cite| commands
% which is generated by |\bibcite|. Because some styles (like
% \package{inlinebib.sty}) write command names containing an |@| to
% the auxiliary files, |\makeatletter| is locally set.
% \begin{macrocode}
\if@filesw
\expandafter\newwrite\csname @auxout\@suffix\endcsname
\expandafter\edef\csname @auxout\@suffix name\endcsname{\@suffix}%
\begingroup
\makeatletter
\@input@{\csname @auxout\@suffix name\endcsname .aux}%
\endgroup
\immediate\openout\csname @auxout\@suffix\endcsname
\csname @auxout\@suffix name\endcsname .aux
\fi
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% Define new |\cite| and |\nocite|. For |\nocite|, we simple let
% |\@auxout| to the new auxiliary file. For |\cite|, this
% approach does not work because |\cite| can have an optional
% argument, so we cannot enclose the redefinition of |\@auxout| in
% braces. We slightly modify |\@citex| (see above) to use a special
% handle, |\@newciteauxhandle|, which is let to the new auxiliary file.
%
% \begin{macro}{\cite<s>}
% \changes{v1.2b}{2003/09/22}{Loop over \macrott{@mb@citenamelist} added.}
%
% For each \meta{citename} in |\@mb@citenamelist|, define
% \package{multibib}'s new \meta{citename}\meta{s} commands. For
% example, if \meta{citename} := |cite| and if \meta{s} := |own|, a command
% |\citeown| is defined as:
% \begin{verbatim}
% \def\citeown{%
% \let\@citex\mb@@citex
% \let\@newciteauxhandle\@auxoutown
% \cite}
% \end{verbatim}
% \begin{macrocode}
\@for\@citename:=\@mb@citenamelist\do{%
\expandafter\edef\csname \@citename\@suffix\endcsname{%
\let\noexpand\@citex\noexpand\mb@@citex
\let\noexpand\@newciteauxhandle\csname @auxout\@suffix\endcsname
\noexpand\csname\@citename\endcsname}%
}%
%
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\nocite<s>}
% \changes{v1.2c}{2004/01/23}{\macrott{let} \macrott{@citex}
% \macrott{mb@@citex} removed.}
%
% Define new |\nocite|\meta{s}, e.g., if \meta{s} := |own|, a
% command |\nociteown| is defined as:
% \begin{verbatim}
% \def\nociteown##1{{%
% \let\@auxout\@auxoutown
% \nocite{##1}}}
% \end{verbatim}
% \begin{macrocode}
\expandafter\edef\csname nocite\@suffix\endcsname##1{{%
\let\noexpand\@auxout\csname @auxout\@suffix\endcsname
\noexpand\nocite{##1}}}%
% \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\bibliography<s>}
% \changes{v1.0i}{2000/01/12}{Remove setting of \macrott{usecounter} and
% \macrott{newusecounter} which is done
% in redefined \macrott{bibliography}.}
% \changes{v1.1e}{2001/01/04}{Definition of \macrott{bibname} analogously
% to \macrott{refname}.}
%
% Define new |\bibliography|\meta{s} equivalents.
% The standard |\bibliography| macro does
% two things: The bibdata file is written to the auxiliary file
% |\@auxout| and the |.bbl| file |\jobname.bbl| is inputed. For
% |\bibliography|\meta{s}, we thus let both |\@auxout|
% and |\jobname| refer to the new auxiliary file \meta{s}|.aux|.
% Since some styles and classes write the heading
% of the bibliography to the table of contents, the old meaning of
% |\@auxout| is saved in |\temp@auxout| and |\addtocontents| is locally
% replaced by \package{multibib}s variant |\mb@addtocontents|
% (defined above) which writes to |\temp@auxout| instead of
% |\auxout|. Further, the heading of the bibliography generated by
% |\refname| or |\bibname| depending on the class is set to the
% particular heading of |\bibliography|\meta{s}. After this
% redefinitions, the standard |\bibliography| can be evoked.
% Extra braces are needed to encapsulate the various |\let|s.
% \begin{macrocode}
\expandafter\edef\csname bibliography\@suffix\endcsname##1{{%
\let\noexpand\temp@auxout\noexpand\@auxout
\let\noexpand\addtocontents\noexpand\mb@addtocontents
\let\noexpand\@auxout\csname @auxout\@suffix\endcsname
\let\noexpand\jobname
\expandafter\noexpand\csname @auxout\@suffix name\endcsname
\let\noexpand\refname
\expandafter\noexpand\csname refname\@suffix\endcsname
\let\noexpand\bibname
\expandafter\noexpand\csname refname\@suffix\endcsname
\noexpand\bibliography{##1}%
}}
% \end{macrocode}
% \end{macro}
%
% \newpage
%
% \begin{macro}{\bibliographystyle<s>}
% Define new |\bibliographystyle|\meta{s} equivalents.
% \begin{macrocode}
\expandafter\edef\csname bibliographystyle\@suffix\endcsname##1{{%
\let\noexpand\@auxout\csname @auxout\@suffix\endcsname
\noexpand\bibliographystyle{##1}}}%
% \end{macrocode}
% \end{macro}
%
%
% Close loop and end macro.
% \begin{macrocode}
}%
}
% \end{macrocode}
%
%
% Finally, restrict the use of |\newcites| to the preamble such that
% the auxiliary files can be |\@input@|ed.
% \begin{macrocode}
\@onlypreamble\newcites
% \end{macrocode}
%
%
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \PrintIndex
% \PrintChanges
% \Finale
%
|