summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/cite/chapterbib.sty
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/cite/chapterbib.sty
Initial commit
Diffstat (limited to 'macros/latex/contrib/cite/chapterbib.sty')
-rw-r--r--macros/latex/contrib/cite/chapterbib.sty557
1 files changed, 557 insertions, 0 deletions
diff --git a/macros/latex/contrib/cite/chapterbib.sty b/macros/latex/contrib/cite/chapterbib.sty
new file mode 100644
index 0000000000..4004095ab3
--- /dev/null
+++ b/macros/latex/contrib/cite/chapterbib.sty
@@ -0,0 +1,557 @@
+% chapterbib.sty Version 1.17 (18-Sep-2010) Donald Arseneau
+%
+% Allow multiple bibliographies in a LaTeX document, including items
+% \cite'd in more than one bibliography.
+%
+% Copyright (C) 1989-2010 by Donald Arseneau and Niel Kempson
+% These macros may be freely transmitted, reproduced, or modified
+% provided that this notice is left intact.
+%
+% Instructions are below, after \endinput.
+%
+%====================== BEGIN MACROS ===========================
+
+\newenvironment{cbunit}%
+{\global\advance\c@inputfile\@ne \xdef\the@ipfilectr{@-\the\c@inputfile}%
+ \@namedef{b@*\@extra@b@citeb}{}%
+ \@CB@writeContext}%
+{\gdef\the@ipfilectr{}\@CB@writeContext}
+
+\def\@CB@writeContext{\if@filesw\begingroup
+ \edef\@tempa{\string\gdef\string\@extra@binfo{\@extra@b@citeb}}%
+ \immediate\write\@auxout{\@tempa\@CB@wtoc{toc}\@CB@wtoc{lof}\@CB@wtoc{lot}}%
+ \endgroup\fi}
+\def\@CB@wtoc#1{\string\@writefile{#1}{\gdef
+ \string\the@ipfilectr{\@extra@b@citeb}}}%
+
+\let\cb@include\include
+\def\include#1{\clearpage \cbunit \xdef\@currentipfile{#1}%
+ \cb@include{#1}\global\let\@currentipfile\@savedjobname\endcbunit}
+
+\newcommand\cb@input[1]{\cbunit \xdef\@currentipfile{#1}%
+ \input{#1}\global\let\@currentipfile\@savedjobname\endcbunit}
+\let\cbinput\cb@input
+
+\@ifundefined{@extra@binfo}{% if not defined by compatible package
+% \@ifundefined{@safe@activestrue}{}{% babel is loaded
+ \@ifundefined{org@bibcite}{%
+ \let\bibcite@iii\bibcite
+ \def\bibcite#1{\bibcite@iii{#1\@extra@binfo}}%
+ }{% and will clobber us
+ \let\bibcite@iii\org@bibcite
+ \def\org@bibcite#1{\bibcite@iii{#1\@extra@binfo}}%
+ }%}
+ }{}%
+
+\@ifundefined{@extra@b@citeb}{% if not defined by compatible package
+ \def\@citex[#1]#2{% Add \@extra@b@citeb to \cite
+ \leavevmode \let\@citea\@empty
+ \@cite{\@for\@citeb:=#2\do
+ {\@citea\let\@citea\citepunct
+ \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
+ \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
+ \@ifundefined{b@\@citeb \@extra@b@citeb}{\hbox{\reset@font\bfseries ?}%
+ \G@refundefinedtrue
+ \@latex@warning{Citation `\@citeb' in file `\@currentipfile'
+ on page \thepage \space undefined}}%
+ {\@cite@ofmt{\citeform{\csname b@\@citeb
+ \@extra@b@citeb\endcsname}}}}}{#1}}
+}{}%
+
+% Test if \@extra@b@citeb hook needs to be added to \nocite
+\setbox\@tempboxa\hbox{\let\@onlypreamble\document%
+ \def\@extra@b@citeb{\global\let\@gtempa\relax}\@extra@b@citeb
+ \def\@ifundefined#1#2#3{\global\let\@gtempa\@empty #1}%
+ \@fileswfalse \nocite{x}}
+
+\ifx\@gtempa\@empty % define \nocite with hook
+\def\nocite#1{\@bsphack % Add \@extra@b@citeb to \nocite
+ \ifx\@onlypreamble\document
+ \@for\@citeb:=#1\do{%
+ \edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
+ \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
+ \@ifundefined{b@\@citeb\@extra@b@citeb}{\G@refundefinedtrue\@latex@warning
+ {Citation `\@citeb' in file `\@currentipfile' undefined}}%
+ {}}%
+ \else
+ \@latex@error{Cannot be used in preamble}\@eha
+ \fi
+ \@esphack}
+\fi
+
+\@ifundefined{@cite@ofmt}{\let\@cite@ofmt\hbox}{}
+\@ifundefined{citeform}{\let\citeform\@empty}{}
+\@ifundefined{citepunct}{\def\citepunct{,\penalty\@m\ }}{}
+
+\xdef\@savedjobname{\jobname}% save root file name as a macro
+\let\@currentipfile\@savedjobname
+\gdef\the@ipfilectr{}
+\def\@extra@b@citeb{\the@ipfilectr}
+\newcount\c@inputfile \global\c@inputfile=0
+
+\gdef\@extra@binfo{} % in case .aux files are left from old run.
+
+\let\cb@bibliographystyle\bibliographystyle
+\def\bibliographystyle#1{\if\cb@roottest\cb@bibliographystyle{#1}\fi}
+\def\cb@roottest{11}% for [rootbib]: {2\ifx\the@ipfilectr\@empty 1\else2\fi}
+
+\def\bibliography#1{\if\cb@roottest
+ \if@filesw\immediate\write\@auxout{\string\bibdata{#1}}\fi
+ \fi
+ \begingroup % localize hooks into \@bibitem
+ \ifx\@CitationPrefix\@empty\else \ifx\the@ipfilectr\@empty\else
+ \@cb@insertprefix
+ \fi\fi
+ \cb@dobiblio{\@currentipfile.bbl}%
+ \endgroup}
+
+\let\cb@dobiblio\@input@
+
+\def\FinalBibPrefix{\bibname\space for\space}%
+\def\@auto@bibname{Bibliography}
+
+\def\sectionbib#1#2{% Macro to convert \thebibliography command
+ \@ifundefined{bibsection}{% Regular -- patch \thebibliography
+ \long\def\@tempa##1##{% to parse beginning of old def -> \@tempc
+ \long\def\@tempa####1\endthebibliography{}\def\@tempc{##1}\@tempa}%
+ \expandafter\@tempa\thebibliography{}{}\endthebibliography
+ \def\@tempa{\chapter*}%
+ \begingroup
+ \toks@{#1}%\showthe\toks@\show\@tempa\show\@tempc
+ \ifx\@tempa\@tempc\expandafter\PackageInfo\else \expandafter\PackageWarning\fi
+ {chapterbib}{The sectionbib option changes \string"\expandafter
+ \strip@prefix\meaning\@tempc\string" to \string"\the\toks@\string" %
+ in \string\thebibliography}%
+ \endgroup
+ \let\cb@thebibliography\thebibliography
+ \def\thebibliography{\let\@currentlabel\@empty
+ \ifx\the@ipfilectr\@empty \else
+ \expandafter\expandafter\expandafter\cb@sectionbib\fi
+ \cb@thebibliography}%
+ \expandafter\def\expandafter\cb@sectionbib\@tempc##1{#1{\bibname}%
+ \ifx\@currentlabel\@empty \begingroup \c@secnumdepth\m@ne
+ \addcontentsline{toc}{#2}{\bibname}% local: * -> no num
+ \csname#2mark\endcsname{\bibname}\endgroup\fi
+ \@ifnextchar\@mkboth{\@gobblethree}{}}%
+ }{% Some package or class has \bibsection -- patch that.
+ \long\def\@tempa##1##{% to parse beginning of old def
+ \long\def\@tempa####1\endthebibliography{}\def\@tempc{##1}\@tempa}%
+ \expandafter\@tempa\bibsection{}{}\endthebibliography
+ \def\@tempa{\chapter*}%
+ \begingroup
+ \toks@{#1}%
+ \ifx\@tempa\@tempc\expandafter\PackageInfo\else \expandafter\PackageWarning\fi
+ {chapterbib}{The sectionbib option changes \string"\expandafter
+ \strip@prefix\meaning\@tempc\string" to \string"\the\toks@\string" %
+ in \string\thebibliography}%
+ \endgroup
+ \let\cb@bibsection\bibsection
+ \def\bibsection{\let\@currentlabel\@empty
+ \ifx\the@ipfilectr\@empty \else
+ \expandafter\expandafter\expandafter\cb@sectionbib\fi
+ \cb@bibsection}%
+ \expandafter\def\expandafter\cb@sectionbib\@tempc{#1}%
+}}
+
+\long\def\@gobblethree#1#2#3{}%
+\@ifundefined{bibname}{\def\bibname{Bibliography}}{}
+
+% The following very messy hacking is to apply a prefix to each
+% cite value, shown in the cites and the bibitems, and active
+% with hyperref. The user should declare something like:
+% \CitationPrefix{\thechapter.}
+% Because this hooking-in is so tricky and specific, it is best
+% to regard this feature as perpetually "experimental".
+%
+\let\@cb@use@prefix\@empty
+\let\@CitationPrefix\@empty
+%
+\newcommand\CitationPrefix[1]{%
+ \def\@CitationPrefix{#1}%
+ \@ifundefined{cb@emptytoks}{\newtoks\cb@emptytoks}{}\cb@emptytoks={}%
+ \def\@cb@use@prefix{% Performed at the first \bibitem of each (sub-)bibliography
+ \let\value\@cb@valuehack
+ \def\@itemlabel{\@biblabel {\the\value\@listctr}}%
+ \let\@cb@use@prefix\@empty}%
+ \def\@cb@valuehack##1{% hook into "\the\value\@listctr"
+ \ifx\@listctr##1% only affect "\value\@listctr"
+ \cb@emptytoks % use up the preceding \the
+ \@CitationPrefix % insert the prefix text
+ \the % restore \the
+ \fi
+ \csname c@\@listctr\endcsname}% regular \value
+}
+
+% redefine \@lbibitem to use prefixed number; set hook (through \value)
+% to use prefix in \@bibitem also. This \@cb@insertprefix is executed
+% by \bibliography.
+\def\@cb@insertprefix{%
+ \let\@cborg@lbibitem\@lbibitem \let\@cborg@bibitem\@bibitem
+ \def\@bibitem{\@cb@use@prefix\@cborg@bibitem}%
+ \def\@lbibitem[##1]{\@cb@use@prefix\@cborg@lbibitem[\@CitationPrefix##1]}%
+ \let\@cb@insertprefix\@empty % ensure no recursive use
+}
+
+\ProvidesPackage{chapterbib}[2010/09/18 \space v 1.17]
+\DeclareOption{sectionbib}{\AtBeginDocument{\sectionbib{\section*}{section}}%
+ \let\FinalBibPrefix\@empty
+ \providecommand\StartFinalBibs{\chapter*{\bibname}%
+ \begingroup \c@secnumdepth\m@ne
+ \addcontentsline{toc}{chapter}{\bibname}%
+ \chaptermark{\bibname}\endgroup
+ \def\bibname{\@auto@bibname}}}%
+\DeclareOption{draft}{\let\cbinput=\include}
+\DeclareOption{rootbib}{\def\cb@roottest{2\ifx\the@ipfilectr\@empty2\else1\fi}}
+\DeclareOption{duplicate}{\gdef\cb@biblist{}\let\cb@sub@input\@input@}
+\DeclareOption{gather}{\gdef\cb@biblist{}\let\cb@sub@input\@gobble}
+\ProcessOptions
+
+\@ifundefined{chapter}%
+{\@ifundefined{section}%
+ {\providecommand\CBMainSectioning{page}}% silly default to prevent errors
+ {\providecommand\CBMainSectioning{section}}%
+}{\providecommand\CBMainSectioning{chapter}}%
+
+
+\ifx\cb@sub@input\@input@ % For [duplicate]
+ \def\cb@dofinalbibs{\if@filesw
+ \toks@{\let\cb@bc\bibcite\let\bibcite\@gobbletwo}%
+ \immediate\write\@auxout{\the\toks@}\fi
+ \let\cb@elt\cb@dogatherbib \cb@biblist
+ \if@filesw\immediate\write\@auxout{\let\string\bibcite\string\cb@bc}\fi}%
+\fi
+
+\ifx\cb@sub@input\@gobble % For [gather]
+ \def\cb@dofinalbibs{\let\cb@elt\cb@dogatherbib \cb@biblist}%
+\fi
+
+\ifx\cb@biblist\@empty % duplicate or gather declared
+ \providecommand\StartFinalBibs{\def\bibname{\@auto@bibname}}%
+ \def\cb@dobiblio#1{% defined to save local context for later "dofinalbibs"
+ \begingroup\makeatletter
+ \ifx\the@ipfilectr\@empty % in root
+ \StartFinalBibs \cb@dofinalbibs
+ \else % in chapter, or section; append to \cb@biblist
+ \let\cb@elt\relax % list \cb@elt{title}{input#}{file}{citeprefix}
+ \let\@ifchapapp\@secondoftwo % provide a *possible* title
+ \expandafter\ifx\csname the\CBMainSectioning\endcsname\thechapter
+ \@ifundefined{@chapapp}{}{\let\@ifchapapp\@firstoftwo}\fi
+ \@ifundefined{FinalBibTitles}{\def\FinalBibTitles % locally
+ {\FinalBibPrefix
+ \@ifchapapp{\@chapapp}{\csname the\CBMainSectioning\endcsname}\space
+ \csname the\CBMainSectioning\endcsname}}{}%
+ \protected@xdef\cb@biblist{\cb@biblist\cb@elt
+ {\FinalBibTitles}{\the\c@inputfile}{\@currentipfile}{\@CitationPrefix}}%
+ \cb@sub@input{#1}%
+ \fi\endgroup}% end \cb@dobiblio
+ \def\cb@dogatherbib#1#2#3#4{% Title, count, fname, prefix
+ \begingroup
+ \protected@edef\@auto@bibname{#1}%
+ \def\@CitationPrefix{#4}%
+ \ifx\@CitationPrefix\@empty\else \@cb@insertprefix \fi
+ \global\c@inputfile#2\global\advance\c@inputfile\m@ne
+ \IfFileExists{#3.bbl}{\cb@input{#3.bbl}}{}%
+ \endgroup}
+\fi
+
+\AtBeginDocument{\let\sectionbib\undefined}
+
+\endinput
+
+%====================== BEGIN INSTRUCTIONS ===========================
+
+
+ chapterbib.sty Version
+ ~~~~~~~~~~~~~~ 1.17 (18-SEP-2010) DA Fix errors introduced in prev
+ 1.16 (05-SEP-2010) DA \CitationPrefix with [gather], drop 2.09
+ 1.15 (30-JUL-2009) DA (typo \CitationPrefix)
+ 1.14 (31-MAR-2009) DA (\nocite*, \CitationPrefix, etc)
+ 1.13 (11-DEC-2007) DA (new final-bib titling)
+ 1.12 (21-MAR-2004) DA
+ 1.11 (29-FEB-2004) DA (allow \nocite check)
+ 1.10 (23-JUN-2003) DA (\bibsection \CBMainSectioning)
+ 1.9 (19-SEP-2001) DA (sectionbib change; babel)
+ 1.8 (29-APR-1999) DA (gather, duplicate, toc)
+ 1.7 (21-JUL-1997) DA (sectionbib, \nocite)
+ 1.6 (08-FEB-1997) Donald Arseneau (more sectionbib)
+ 1.5 (09-OCT-1995) Donald Arseneau (rootbib)
+ 1.4 (11-MAR-1995) Donald Arseneau (sectionbib)
+ 1.3 (04-JUL-1994) Donald Arseneau (2e, cbunit)
+ 1.2 (21-MAY-1993) Donald Arseneau (bug fix)
+ 1.1 (24-MAR-1993) Donald Arseneau
+ 1.0 (23-NOV-1988) Niel Kempson
+
+ Allow multiple bibliographies in a LaTeX document, including items
+ \cite'd in more than one bibliography. Despite the name "chapterbib",
+ the BIBLIOGRAPHIES ARE FOR EACH INCLUDED FILE, not necessarily for each
+ chapter. The main point is to allow you to use BibTeX: Each included
+ file should have its own \bibliographystyle and \bibliography commands,
+ and you should run BibTeX on each included file separately rather than
+ on the root file.
+
+ There are also the commands \begin{cbunit}, \end{cbunit}, and \cbinput
+ to allow multiple bibliographies without using \include (see item 4).
+ There are two added hooks, \citeform and \citepunct, which you can
+ redefine to customise the formatting of each entry in a citation list,
+ and the declaration \CitationPrefix to use in preference to \citeform
+ for numbering-by-chapter.
+
+ Usage, Restrictions, and Options
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ 1. Normal use: Put \bibliographystyle and \bibliography commands in
+ each \include'd file. Run LaTeX; run BibTeX on each included file;
+ run LaTeX; run LaTeX.
+
+ 2. The \bibliography and \bibliographystyle commands are not normally used
+ in the root file, only in files that have been \include'd. To have a
+ whole-document bibliography, see items 6-9, depending on which style of
+ whole-document bib.
+
+ 3. If you can't use \include because a new section must start below the
+ preceding bibliography on the same page (odd format!), then you can
+ use \begin{cbunit}...\end{cbunit} or \cbinput, with a {thebibliography}
+ environment in each unit or input file. To use BibTeX: input separate
+ files using \cbinput; at first use the package or global option [draft],
+ run LaTeX on the document, then BibTeX on each file that was \cbinput;
+ finally, remove the [draft] option and run LaTeX again (maybe twice to
+ get page references right). The [draft] option only affects the treatment
+ of \cbinput, not \include or \begin{cbunit}.
+ With old LaTeX, do the preliminary run using \include commands, and
+ change these to \cbinput for the final run(s).
+
+ 4. Your preferred citation style (xxx.sty) may not work with chapterbib at
+ first, but it is easy to make it compatible: In `xxx.sty' change every
+ "@\@citeb" to "@\@citeb\@extra@b@citeb", and insert the line
+ \@ifundefined{@extra@b@citeb}{\def\@extra@b@citeb{}}{}
+ somewhere (but not as a comment or as part of another definition!).
+
+ If the package also redefines \bibcite then you should change that
+ definition, replacing "@#1" with "@#1\@extra@binfo", and insert
+ \gdef\@extra@binfo{}
+ somewhere in the file. If the package defines a command that acts
+ similarly to \bibcite (being written to the aux file), then it should
+ have "\@extra@binfo" inserted the same way.
+ Some citation packages deviate quite far from LaTeX's own method
+ of organizing cite tags using "b@\@citeb". The instructions above
+ catch such extensions as "Y@\@citeb", but not more radical differences.
+ In such cases, try contacting the author of the citation package.
+ If a citation style does not define "\nocite", then that command
+ would not be converted when you make the patches to "@\@citeb".
+ Chapterbib will try to detect the hook in "\nocite", but if this fails
+ you may need to redefine "\nocite" (with any "@\@citeb" changed to
+ "@\@citeb\@extra@b@citeb") in that sty file.
+
+ 5. The report and book document classes usually treat the bibliography as
+ an unnumbered chapter (\chapter*), which is not so good for bibliographies
+ IN a chapter. You can specify
+ \usepackage[sectionbib]{chapterbib}
+ to convert your bibliographies from \chapter* to \section*, with an
+ entry in the table of contents and the page-header. A bibliography in
+ the root file remains as a \chapter*. The [sectionbib] option modifies
+ the existing thebibliography environment (or the \bibsection command, if
+ present already), so the other formatting in the bibliography should
+ remain unchanged. On the other hand, if you already have a non-standard
+ bibliography defined, or if you want them numbered, it may be easier to
+ redefine \thebibliography directly, without any trickery.
+ Alternatively, you can use the \sectionbib command directly in the
+ document preamble. It takes two parameters: the sectioning command, and
+ the name of the sectioning level. For instance, the [sectionbib] option
+ does \sectionbib{\section*}{section}. Again, for the most control, it is
+ better to redefine \thebibliography entirely.
+
+ 6. If you want a completely unrelated bibliography in the root file, perhaps
+ for a general reading list, you can provide your own bibliography there
+ using the thebibliography environment. I don't suppose this will appeal
+ to BibTeX users!
+
+ 7. To have a cohesive bibliography for the whole document, plus individual
+ bibs in the chapters, put \bibliography commands in the included chapters
+ plus in the root file. Make sure the \bibliographystyle for the overall
+ bibliography appears FIRST, before any chapters are included. Run LaTeX;
+ run BibTeX on the root file; run BibTeX on each included file; run LaTeX;
+ run LaTeX. This produces an independent `overall' bibliography which only
+ makes sense for various `named' bibliography styles; a numbered style, or
+ one with any type of automatic enumeration (like Me2007a, Me2007b) will
+ give unrelated numbers in each bibliography and lead to confusion.
+ Bibtex will complain about multiple \bibdata commands when it makes
+ the whole bibliography, but it should obey the first. If you don't
+ want to see any error messages from bibtex, or if you don't want to put
+ the main \bibliographystyle command first in the document, then use
+ \usepackage[rootbib]{chapterbib} when you run LaTeX first; run BibTeX
+ on the root file; change to \usepackage{chapterbib}; run LaTeX; run
+ BibTeX on each included file; run LaTeX; run LaTeX.
+
+ 8. To have a bibliography-by-chapter at the end instead of separate bibs
+ in the chapters, use \usepackage[gather]{chapterbib}, put \bibliography
+ commands in each file, and at the end of the main file. Run LaTeX as
+ in item 1. You can control the titling of the final bibliographies by
+ defining \FinalBibTitles, such as
+
+ \newcommand\FinalBibTitles{References for Chapter \thechapter}
+
+ A similar effect may be achived by RE-defining \FinalBibPrefix as
+
+ \renewcommand\FinalBibPrefix{References for }
+
+ Even more control is achieved by redefining \StartFinalBibs.
+ The default definition is (like)
+
+ \newcommand{\StartFinalBibs}{%
+ \renewcommand{\bibname}{Bibliography for chapter n}}
+
+ normally, but when using the [sectionbib] option it becomes
+
+ \newcommand{\StartFinalBibs}{\chapter*{\bibname}%
+ \addcontentsline{toc}{chapter}{\bibname}\@mkboth{\bibname}{\bibname}%
+ \renewcommand{\bibname}{Chapter n}}
+
+ where the \bibname text is now provided by \@auto@bibname, which
+ relies on bookkeeping and \FinalBibPrefix.
+
+ If your document class has neither section nor chapter, then you must
+ define \StartFinalBibs and also indicate the sectioning: for example,
+ if the main sectioning command in your document class is \motif:
+ \newcommand\CBMainSectioning{motif}
+
+ 9. To have bibliographies in each chapter PLUS a bibliography-by-chapter at
+ the end, follow item 8, but declare \usepackage[duplicate]{chapterbib}
+ (or \usepackage[duplicate,sectionbib]{chapterbib}).
+
+10. If you use Babel, load chapterbib before babel.
+
+ \citeform, \citepunct and \CitationPrefix:
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Normally, the citations are formatted as given, but you can define \citeform
+ (with one parameter) to reformat every citation. Some possibilities:
+ \renewcommand\citeform[1]{\romannumeral 0#1}% roman numerals: [iv,x]
+ \renewcommand\citeform[1]{(#1)} % parentheses: [(3),(4),(7)]
+ If you change \citeform, you should probably define \@biblabel to match.
+
+ Another not-so-good example to provide a chapter-number prefix is
+ \renewcommand\citeform[1]{\thechapter.#1} % number by chapter.
+ This partially works, but has only limited applicability: it does not
+ work with cites in the front-matter (TOC, LOF) or with hyperref.
+ Instead, there is a \CitationPrefix command to apply a prefix to the
+ citation numbers (or names) in the bibliographies and \cite commands
+ for the included files. Use it by declaring something like
+ \CitationPrefix{\thechapter.}
+ in the preamble. The prefix will be applied to all the chapter-bibs
+ but will not be used in an overall (root) bibliography, if you have one.
+ (The \CitationPrefix mechanism is likely to break often if it conflicts
+ with other packages.)
+
+ \citepunct gives the punctuation (comma-penalty-space) between items
+ in the \cite list.
+
+%====================== END INSTRUCTIONS ===========================
+%
+% -----------------Implementation notes---------------
+%
+% LaTeX normally uses command names in the form \b@TAG to associate a mnemonic
+% TAG with the citation name or number. Chapterbib changes this to a command
+% like \b@TAG@-nn where nn is a number identifying which included file is in
+% effect.
+%
+% Tags indicating the citations and/or the input files:
+% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+% \c@inputfile = counter counting included files
+% \the@ipfilectr = (empty) when typesetting from the root file,
+% = @-\the\c@inputfile when typesetting from an included file
+% \@extra@b@citeb = \the@ipfilectr (just an alias)
+% \@extra@binfo = the value of \@extra@b@citeb as saved in .aux files
+%
+% \b@FOO:
+% ~~~~~~~
+% In the root file, the citation number (or name) is given by \b@FOO
+% just like regular LaTeX, but in an \include'd file it is given by
+% \b@FOO@-number. Any definition of \cite (\@citex) should refer
+% to this using \csname b@\@citeb\@extra@b@citeb \endcsname.
+%
+% \include \cbinput and \cbunit:
+% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+% Redefine the \include macro so that when a file is \include'd...
+% Increment the file number, (globally) update \the@ipfilectr to be
+% @-number, and write \gdef\@extra@binfo{@-number} in the (main) .aux
+% file, and do regular \include. When the \include'd file is finished,
+% write \gdef\@extra@binfo{} in the (main) .aux file. Globally reset
+% \the@ipfilectr to {}. Provide similar \cbunit and \cbinput.
+%
+% \cite:
+% ~~~~~~
+% Redefine \cite (\@citex actually) and \bibcite to use the file number
+% tag along with the specified tag. \@citex also uses \citeform as a hook
+% to reformat each individual citation.
+% Only do the redefinitions if no citation style that supports chapterbib
+% has been loaded--as indicated by existence of filename tags.
+%
+% \nocite:
+% ~~~~~~~~
+% A while ago LaTeX changed its \nocite so it checks the validity of the
+% (no)citation tags. This necessitated adding the "\@extra@b@citeb" hook
+% to \nocite. At first, I only redefined \nocite when redefining \cite,
+% but there existed citation packages that supported chapterbib by putting
+% \@extra@b@citeb into \cite but which did not define \nocite at all!
+% These then gave warning messages for every \nocite. With version 1.7,
+% I now try exercising the \nocite command with some functions disabled:
+% (1) .aux file output is locally switched off; (2) The \@ifundefined
+% command is hacked to merely typeset the text of the tag; (3) this is
+% done in a disappearing \hbox so it generates no output. This detects
+% (by setting a global flag \@gtempa) a \nocite command that executes
+% \@ifundefined but not \@extra@b@citeb. In such cases, \nocite must
+% be redefined.
+%
+% \citepunct and \citeform:
+% ~~~~~~~~~~~~~~~~~~~~~~~~~
+% These customization hooks are present in cite.sty; others (\citemid,
+% \citeleft, \citeright) are not defined here because \@cite is not redefined.
+% LaTeX has now adopted \@cite@ofmt, which is normally \hbox, so use both.
+%
+% We redefine \@testdef so that it properly checks whether the
+% \cite labels have changed.
+%
+% Table of contents etc:
+% ~~~~~~~~~~~~~~~~~~~~~~
+% As of version 1.8, definitions of \@extra@b@citeb are written to the
+% toc, lot, and lof files to avoid undefined citation tags in those tables.
+% This is actually a problem in regular LaTeX with bibTeX -- cites that
+% appear in those tables get numbered starting with 1, but they should
+% be sequenced by where they originated -- but the problem was worse with
+% chapterbib.
+%
+% \CitationPrefix:
+% ~~~~~~~~~~~~~~~~
+% This is a really ugly hack, but \citeform worked poorly for putting
+% a chapter-identifier on each cite. It locally redefines both
+% \@bibitem and \@lbibitem at each \bibliography. The insertion
+% of the prefix is straightforward for \@lbibitem, but for \@bibitem
+% the prefix is inserted by a redefined \value macro (eeek!). It has
+% a deficiency in not being sorted as a simple number by cite.sty.
+%
+%---------------------------------------------------------------
+%
+% Authors Niel Kempson (original)
+% ~~~~~~~ Donald Arseneau <asnd@triumf.ca> March 1993 - Sept 2010
+%
+% Changes with ver 1.17: Fix errors made dropping ancient support;
+% Make [sectionbib] give warn or info always.
+% Changes with ver 1.16: Propagate prefix info to final bibs;
+% drop support for ancient LaTeX versions
+% Changes with ver 1.15: Fix typo \bibitemPrefix -> \CitationPrefix
+% Changes with ver 1.14: No warning from \nocite* in chapters, \CitationPrefix
+% Changes with ver 1.13: Rewrite final-bibs titling
+% Changes with ver 1.12: Update \@citex \bfseries
+% Changes with ver 1.11: Follow LaTeX's barring \nocite from preamble
+% Changes with ver 1.10: \CBMainSectioning; \bibsection hook
+% Changes with ver 1.9: sectionbib remove \@mkboth
+% Changes with ver 1.8: options gather and duplicate; babel workarounds; toc
+% Changes with ver 1.7: Change the \sectionbib command re. headings.
+% Update \nocite and alter \citeform
+% Changes with ver 1.6: Change the \sectionbib command to take arguments.
+% Changes with ver 1.5: rootbib option; item 8 in instructions.
+% Changes with ver 1.4: sectionbib and draft options
+% Changes with ver 1.3: rewrite:
+% The filename tag is defined in each .aux file by \include, not as an
+% extra parameter to \bibcite. \@bibitem & \@lbibitem are left alone. Add
+% \citeform and \citepunct. Add \cbunit and \cbinput for use without \include.
+%