• Tidak ada hasil yang ditemukan

7.4 Cross-references

7.4.2 Bibliographic references

The mechanism used for references to reading lists and bibliogra-phies is almost identical to that used for normal cross-references.

Although it is possible to type the details of each citation manu-ally, there is a companion program to LATEX called BIBTEX, which manages bibliographic references automatically. This reduces the time needed to maintain and format them, and dramatically im-proves accuracy. Using BIBTEX means you only ever have to type the bibliographic details of a work once. You can then cite it in

3Thus I can refer here to \ref{normalxref} and get the value § 7.4.1.

Formatting information 

129

any document you write, and it will get formatted automatically to the style you specify.

7.4.2.1 Citing references

BIBTEX works exactly the same way as other bibliographic databases: you keep details of every document you want to refer to in a separate file, using BIBTEX’s own format (see exam-ple below). Many writers make a habit of adding the details of every book and article they read, so that when they write a document, these entries are always available for reference. You give each entry a short label, just like you do with normal cross-references (see § 7.4.1), and it is this label you use to refer to in your own documents when you cite the work using the \cite command:



...as has clearly been shown by Fothergill˜\cite{fg}.

By default, this creates a cross-reference number in square brackets [1] which is a common style in the Natural Sciences (see

§ 7.4.2.5 for details of how to change this). There are dozens of alternative citation formats in extra packages, including the popular author/year format:



...as has clearly been shown

by˜\citeauthoryear{fg}.

. . . as has clearly been shown by Fothergill (1929).

Note that in this case you don’t type the author’s name because it is automatically extracted by BIBTEX. There are lots of variants on this technique in many packages, allowing you to phrase your sentences with references in as natural a way as possible, and rely

7.4. CROSS-REFERENCES

on BIBTEX to insert the right data. (If you examine the source of this document you’ll find I use some homebrew commands like

\authorof and \titleof which I use for a similar purpose.)

To print the bibliographic listing (usually called ‘References’ in articles and ‘Bibliography’ in books and reports), add these two lines towards the end of your document, or wherever you want it printed, substituting the name of your own BIBTEX file and the name of your chosen bibliography style:



\bibliographystyle{ieeetr}

\bibliography{mybib}

o The \bibliography command is followed by the filename of your BIBTEX file without the .bib extension.

o The \bibliographystyle command is followed by the name of any of LATEX’s supported bibliography styles, of which there are many dozens available from CTAN.4

The styles plain and alpha are two common generic styles used for drafts. The example above uses Transactions of the Institute of Electrical and Electronics Engineers (IEEETR).

7.4.2.2 Running bibtex

When you run the bibtex program, the details of every document you have cited will be extracted from your database, formatted according to the style you specify, and stored in a temporary bibliographic (.bbl) file with a label corresponding to the one you used in your citation, ready for LATEX to use. This is entirely automatic: all you do is cite your references in your LATEX document using the labels you gave the entries in your BIBTEX file, and run the bibtex program.

After processing your file with LATEX, run BIBTEX on it by clicking on the BIBTEX toolbar icon (if your editor has one),

4The style shown in the example here provides formatting according to the specifications for Transactions of the IEEE (revised).

Formatting information 

131

or use the TeXBibTeX File p menu entry, or type the command bibtexfollowed by the name of your document (without the .tex extension). When you run LATEX again it will use the .bbl file which BIBTEX created, and subsequent runs of LATEX will format the correct citation numbers (or author/year, or whatever format you are using).



$ latex mybook

$ bibtex mybook

$ latex mybook

$ latex mybook

Because of this three-stage process, you always get a warning message about an ‘unresolved reference’ the first time you add a new reference to a previously uncited work. This will disappear after subsequent runs of bibtex and LATEX.

In practice, authors tend to run LATEX from time to time during writing anyway, so they can preview the document. Just run BIBTEX after adding a new \cite command, and subsequent runs of LATEX will incrementally incorporate all references without you having to worry about it. You only need to follow the full formal sequence (LATEX, BIBTEX, LATEX, LATEX) when you have finished writing and want to ensure that all references have been resolved.

7.4.2.3 BIBTEX format

The format for the BIBTEX file is specified in the BIBTEX docu-mentation (see § 5.1.2 for how to find and print it). You create a file with a name ending in .bib, and add your entries, for example:

7.4. CROSS-REFERENCES



@book{fg,

title = {{An Innkeeper’s Diary}}, author = {John Fothergill},

edition = {3rd}, publisher = {Penguin},

year = 1929,

address = {London}

}

There is a prescribed set of fields for each of a dozen or so types of document: book, article (in a journal), article (in a collection), chapter (in a book), thesis, report, paper (in a Proceedings), etc. Each entry identifies the document type after the ‘@’ sign, followed by the entry label that you make up, and then each field (in any order), using the format:



keyword = {value},

Most TEX-sensitive editors have a BIBTEX mode which under-stands these entries. Emacs automatically uses its bibtex-mode whenever you open a filename ending in .bib. When editing BIBTEX databases, the rules are simple:

q Omit the comma after the last field in the entry (only — eg after {London} in the example).

q Titles may have their case changed in some styles: to prevent this, enclose the title in double curly braces as in the example.

q Values which are purely numeric (e.g. years) may omit the curly braces.

q Fields can occur in any order but the format must otherwise be strictly observed.

Formatting information 

133

Figure 7.1: tkBIBTEX, one of several graphical interfaces to BIBTEX databases

r Fields which are not used do not have to be included (so if your editor automatically inserts them as blank or prefixed by OPT [optional], you can safely delete them as unused lines).

To help with this, there are several interfaces to creating and maintaining BIBTEX files, such as tkbibtex (see Figure 7.1), or pybliographic.

7.4. CROSS-REFERENCES

7.4.2.4 Changing the layout

To change the title printed over the reference listing, just change the value of \refname (articles) or \bibname (books and reports) by adding a line like this in your preamble:



\renewcommand{\bibname}{Reading List}

The formatting specifications (BIBTEX styles) are based on stan-dard settings for journals and books from dozens of publishers:

you just pick the one you want by name. The texmf/bib/bst subdirectory of your installation contains the ones installed by default, and you can search on CTAN for others (look for .bst files). Many of them are named after university press styles (e.g.

harvard, oxford) or the publisher or journal which specified them (e.g. elsevier, kluwer, etc.).

Some of them have an accompanying package (.sty) file which you need to include with the normal \usepackage command in your preamble. In this case the format may be distributed as .dtx and .ins files and will need installing in the same way as any other package (see § 5.2). Always read the documentation, because most of the formats are very specific to the journal they were designed for, and may have fairly absolute requirements.

If you are writing for a specific publisher, you should remember that the rules or formats are laid down by the typographic designer of that journal or publisher: you cannot arbitrarily change the format just because you don’t happen to like it: it’s not your choice!

It is also possible to write your own BIBTEX (.bst) style files, although it uses a language of its own which really needs a computer science background to understand. However, this is rendered unnecessary in most cases: there is an extensive program (actually written in LATEX) called makebst, which makes .bst files by asking you a (long) series of questions about exactly how

Formatting information 

135

you want your citations formatted. Just type latex makebst in a command window, but give it a dummy run first, because some of the questions are very detailed, so you need to have thought through how you want your citations to appear before you start.

7.4.2.5 Other modes of citation

The method of citing a work by numeric reference is common in the Natural Sciences but is not used in Law or the Humanities.

In these fields, citations are usually done with short references (author/short-title/year) in a numbered footnote. Sometimes they are actually called ‘footnotes’ to the exclusion of ordinary footnotes, although they are really citations which happen by convention to be displayed as footnotes: an important distinction rarely appreciated by authors until they come to need a normal footnote.

For these fields, the bibliography at the back of the document is printed unnumbered in alphabetic order of author, or perhaps chronologically if the time-frame is very large. This unnumbered format is why it is conventionally called ‘References’ rather than

‘Bibliography’: a sufficient working citation has already been provided in the footnote, and the list at the back is for reference purposes only; whereas in the Natural Sciences, the citation is just a number, or possibly an author and year only, so the full listing is called a Bibliography.

The jurabib package (originally intended for German law arti-cles but now extended to other fields in the Humanities, and to other languages) has extensive features for doing this style of citation and is strongly recommended.