ltbibl.dtx

Johannes Braams  David Carlisle  Alan Jeffrey
Leslie Lamport  Frank Mittelbach  Chris Rowley

Rainer Schöpf

1995/12/07

1 Bibliography Generation

A bibliography is created by the thebibliography environment, which generates a title such as “References”, and a list of entries. The BIBTEX program will create a file containing such an environment, which will be read in by the \bibliography command. With BIBTEX, the following commands will be used.

\bibliography \bibliography{⟨file1,file2, …,filen⟩} : specifies the bibdata files. Writes a

\bibdata entry on the .aux file and tries to read in mainfile.bbl.

\bibliographystyle      \bibliographystyle{⟨style⟩} : Writes a \bibstyle entry on the .aux file.

thebibliography The thebibliography environment is a list environment. To save the use of an extra counter, it should use enumiv as the item counter. Instead of using \item, items in the bibliography are produced by the following commands: \bibitem{⟨name⟩} : Produces a numbered entry cited as ⟨name⟩. \bibitem[⟨label⟩]{⟨name⟩} : Produces an entry labeled by ⟨Label⟩ and cited by ⟨name⟩.

The former is used for bibliographies with citations like [1], [2], etc.; the latter is used for citations like [Knuth82].

The document class must define the thebibliography environment. This environment has a single argument, which is the widest bibliography label– e.g., if the [Knuth67] is the widest entry, then this argument will be Knuth67. The \thebibliography command must begin a list environment, which the

\endthebibliography command ends.

\cite Entries are cited by the command \cite{⟨name⟩}. \nocite \nocite{⟨citations⟩} puts information on the .aux file that causes BibTEX to

include the {⟨citations⟩} list in the bibliography, but puts nothing in the text.

\nocite{*} is special: it tells BibTEX to put the whole of a collection of references into the bibiography.

1 ⟨∗2ekernel⟩

 2 \message{bibliography,}

PARAMETERS \@cite : A macro such that \@cite{LABEL1,LABEL2}{NOTE}

produces the output for a \cite[NOTE]{FOO1,FOO2}

command, where entry FOOi is defined by \bibitem[LABELi]{FOOi}. The switch @tempswa is true if the optional NOTE

argument is present. The default definition is :

\@cite{LABELS}{NOTE} ==

BEGIN [LABELS IF @tempswa = T THEN , NOTE FI ]

END

\@biblabel : A macro to produce the label in the bibliography entry. For \bibitem[LABEL]{NAME}, the label is generated by \@biblabel{LABEL}. It has the default definition \@biblabel{LABEL} -> [LABEL].

CONVENTION

\b@FOO : The name or number of the reference created by \cite{FOO} E.g., if \cite{FOO} -> [17] , then \b@FOO -> 17.

\bibitem
3 \def\bibitem{\@ifnextchar[\@lbibitem\@bibitem}
\@lbibitem
4 \def\@lbibitem[#1]#2{\item[\@biblabel{#1}\hfill]\if@filesw
5  {\let\protect\noexpand
6  \immediate
7  \write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces}
\@bibitem
8 \def\@bibitem#1{\item\if@filesw \immediate\write\@auxout
9  {\string\bibcite{#1}{\the\value{\@listctr}}}\fi\ignorespaces}
\bibcite
10 \def\bibcite{\@newl@bel b}
\citation
11 \let\citation\@gobble
\cite
12 \DeclareRobustCommand\cite{%
13 \@ifnextchar [{\@tempswatrue\@citex}{\@tempswafalse\@citex[]}}

\@citex \penalty\@m added to definition of \@citex to allow a line break after the ‘,’ in

citations like [Jones80,Smith77] (Added 23 Oct 86)

space added after the ‘,’ (21 Nov 87)

14 \def\@citex[#1]#2{%
15 \let\@citea\@empty
16 \@cite{\@for\@citeb:=#2\do
17  {\@citea\def\@citea{,\penalty\@m\ }%
18  \edef\@citeb{\expandafter\@firstofone\@citeb}%
19  \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
20  \@ifundefined{b@\@citeb}{\mbox{\reset@font\bfseries ?}%
21  \G@refundefinedtrue
22  \@latex@warning
23  {Citation `\@citeb' on page \thepage \space undefined}}%
24  {\hbox{\csname b@\@citeb\endcsname}}}}{#1}}
\bibdata \bibstyle
25 \let\bibdata=\@gobble
26 \let\bibstyle=\@gobble
\bibliography
27 \def\bibliography#1{%
28 \if@filesw
29  \immediate\write\@auxout{\string\bibdata{#1}}%
30 \fi
31 \@input@{\jobname.bbl}}
\bibliographystyle
32 \def\bibliographystyle#1{%
33 \ifx\@begindocumenthook\@undefined\else
34  \expandafter\AtBeginDocument
35 \fi
36  {\if@filesw
37  \immediate\write\@auxout{\string\bibstyle{#1}}%
38  \fi}}

\nocite (Added 14 Jun 85)

This puts information on the .aux file that causes BibTEX to include the citation list in the bibliography, but puts nothing in the text.

RmS 93/08/06: Made loop for \nocite like that for \@citex, to get rid of leading spaces.

39 \def\nocite#1{\@bsphack
40 \@for\@citeb:=#1\do{%
41  \edef\@citeb{\expandafter\@firstofone\@citeb}%
42  \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi
43  \@ifundefined{b@\@citeb}{\G@refundefinedtrue
44  \@latex@warning{Citation `\@citeb' undefined}}{}}%
45 \@esphack}

Since \nocite{*} should not produce a warning about undefined citation keys (seee PR 557), we need to set the control sequence ‘\b@*’ to something other than \relax. As a result \cite{*} will not warn either (but that never worked with BibTEX in the first place).

46 \expandafter\let\csname b@*\endcsname\@empty

1.1 Default definitions

\@cite
47 \def\@cite#1#2{[{#1\if@tempswa , #2\fi}]}
\@biblabel
48 \def\@biblabel#1{[#1]}

49 ⟨/2ekernel⟩