• Home   /
• Archive by category "1"

## The Bibliography Latex Optionsxpress

This is a gentle introduction to using some of the bibliography functionality available to LaTeX users beyond the BibTeX basics. This introduction won't be discussing how to create new styles or packages but rather how to use some existing ones. It is worth noting that Harvard, for example, is a citation style. It is associated with an alphabetical reference list secondarily ordered on date, but the only strictly defined element of Harvard style is the citation in author-date format.

## The example data

The database used for my examples contains just the following

@article{Erdos65, title = {Some very hard sums}, journal = {Difficult Maths Today}, author = {Paul Erd\H{o}s and Arend Heyting and Luitzen Egbertus Brouwer}, year = {1930}, pages = {30}}

## The limits of BibTeX styles

Using cite.sty and BibTeX makes it very easy to produce some bibliography styles. But author-date styles - for example the often mentioned, never defined "Harvard" - are not so easy. It's true that you can download some .bst files from CTAN that will handle some variants but using them is not always straightforward. This guide deals with Natbib a supplementary package that can access .bib files and has sophisticated functionality for producing custom or default author-year format citations and bibliographies as well as the numerical styles handled by BibTeX.

## Natbib

Natbib is a package created by Patrick Daly as a replacement for the cite.sty package when author-date citation styles are required. Natbib provides three associated bibliography styles:

• plainnat
• abbrvnat
• unsrtnat

which correspond to the three styles available by default in BibTeX where you have a plain numbered style, an abbreviated numbered style and an unsorted numbered style.

Alongside these new styles is an extended set of citation commands to provide flexible citation formats. These are

and

each of which has a number of variants.

### The Preamble

All Natbib styles require that you load the package in your document preamble. So, a skeleton LaTeX file with Natbib might look like this:

\documentclass[]{article}\usepackage[round]{natbib}\begin{document} Document body text with citations. \bibliographystyle{plainnat}\bibliography{myrefs}\end{document}

#### Options

Options available with Natbib can be specified in the brackets on the \usepackage command. Among them are:

OptionEffect
round()
square[]
curly{}
angle<>
semicolonseparate citations with ;
colonas semicolon
commaseparate with commas
authoryearauthor-year citations
numbersnumeric citations
supersuperscript citations
sortmultiple citations are ordered as in bibliography
sort&compressas sort but number ranges are compressed and hyphenated
compressnumber ranges are compressed and hyphenated but only where the 'natural' sort produces a continuous range
longnamesfirstfirst citation is full author list and subsequent citations are abbreviated
sectionbiballows multiple bibliographies in the same document
nonamebreakforces all author names onto one line
mergemerges a citation with a previous citation
elideelides any repeated elements in merged references
mciteignore merge

Clearly some of these options require explanation but that will be achieved via examples below. For now, we just note that they can be passed through \usepackage[]{} in the preamble of your LaTeX file.

## Citation

### Basic Citation Commands

To cite with Natbib, use the commands \citet or \citep in your document. The "plain" versions of these commands produced abbreviated lists in the case of multiple authors but both have * variants which result in full author listings. We assume the use of the round option in these examples.

#### \citet and \citet*

The \citet command is used for textual citations, that is to say that author names appear in the text outside of the parenthetical reference to the date of publication. This command can take options for chapter, page numbers etc. Here are examples

 \citet{Erdos65} produces Erdős et al. (1965) \citet[chapter 2]{Erdos65} produces Erdős et al. (1965, chapter 2) \citet[pp. 10-12]{Erdos65} produces Erdős et al. (1965, pp. 10-12) \citet[see][chap. 2]{Erdos65} produces Erdős et al. (see 1965, chap. 2)

Here are the \citet* versions

 \citet*{Erdos65} produces Erdős, Heyting and Brouwer (1965) \citet*[chapter 2]{Erdos65} produces Erdős, Heyting and Brouwer (1965, chapter 2) \citet*[pp. 10-12]{Erdos65} produces Erdős, Heyting and Brouwer (1965, pp. 10-12) \citet*[see][chap. 2]{Erdos65} produces Erdős, Heyting and Brouwer (see 1965, chap. 2)

#### \citep and \citep*

The \citep command is used where the author name is to appear inside the parentheses alongside the date.

 \citep{Erdos65} produces (Erdős et al. 1965) \citep[chapter 2]{Erdos65} produces (Erdős et al. 1965, chapter 2) \citep[pp. 10-12]{Erdos65} produces (Erdős et al. 1965, pp. 10-12) \citep[see][chap. 2]{Erdos65} produces (see Erdős et al. 1965, chap. 2) \citep[e.g.][]{Erdos65} produces (e.g. Erdős et al. 1965)

Here are the \citep* versions

 \citep*{Erdos65} produces (Erdős, Heyting and Brouwer 1965) \citep*[chapter 2]{Erdos65} produces (Erdős, Heyting and Brouwer 1965, chapter 2) \citep*[pp. 10-12]{Erdos65} produces (Erdős , Heyting and Brouwer 1965, pp. 10-12) \citep*[see][chap. 2]{Erdos65} produces (see Erdős , Heyting and Brouwer, 1965, chap. 2) \citep*[e.g.][]{Erdos65} produces (e.g. Erdős , Heyting and Brouwer, 1965)

### The Reference List

Having dealt with basic varieties of citation, we turn to the creation of the bibliography or reference list.

Inserting a correct and correctly formatted bibliography when using Natbib is no different than when using plain BibTeX. There are two essential commands -

\bibliography{mybibliographydatabase}

which LaTeX interprets as an instruction to read a bibliographic database file (eg myrefs.bib) and insert the relevant data here, and

\bibliographystyle{plainnat}

which specifies how the data are to be presented.

Above the three basic Natbib styles were mentioned as analogues of the partially homonymous styles in BibTeX. Let us imagine documents bearing citations as in the section about citation above. Here is, approximately, how these citations would appear in plainnat.

### What more is there?

This covers the basic functionality provided by the package Natbib. It may not, of course, provide what you are looking for. If you don't find what you want here then you should probably next investigate harvard.sty which provides a slighly different set of author-date citation functions. Providing a gentle guide to harvard.sty is my next rainy day project.

### What is LaTeX?

LaTeX is a typesetting program that takes a plain text file with various commands in it and converts it to a formatted document based on the commands that it has been given. The source file for the document has a file extension of .tex. It is widely used for theses and other technical papers due to its prowess with mathematical and foreign characters.

### What is BibTeX?

BibTex is a bibliographic tool that is used with LaTeX to help organize the user's references and create a bibliography. A BibTex user creates a bibliography file that is separate from the LaTeX source file, wth a file extension of .bib. Each reference in the bibliography file is formatted with a certain structure and is given a "key" by which the author can refer to it in the source file. For more information on BibTeX, see the section of the Athena On-Line Help System's LaTeX documentation called Using a Bibliography.

### How do I export from RefWorks to BibTeX?

Log into RefWorks on your web browser. Move all of the references that you'd like to cite into a separate folder. Go to the References menu and select Export. In the drop-down menu, choose the folder that contains the references you'd like to cite in your document. From the list of export types, click the radio button next to BibTeX - RefWorks ID. Now click Export to Text File.

A text file containing information for each of your references should appear (if it doesn't, click Download It). From the File menu, select Save Page As. Navigate to the directory where you are storing your manuscript. Change the name of the file that you are saving to filename.bib. Then click Save. This will save your references in the correct format for BibTeX to read and create a bibliography from.

\bibliographystyle{style} should go just inside your \begin{document} command. style.bst is the name of the style file dictating the format of your bibliography (see How do I change the format of the bibliography? below).

\bibliography{filename} should go wherever you want LaTeX to generate the bibliography. filename.bib is the name of the file that you just downloaded from RefWorks containing your exported references.

### How do I cite references in my document?

Insert the command \cite{RefWorks:#} where "#" is the RefWorks ID number of the reference you are citing.

### How can I correct errors I encounter when running BibTeX on my bibliography file?

BibTeX has a 5000 character limit for each field. Most fields will not surpass this limit, but for a reference where the "note" field contains a large amount of information such as the entire table of contents, this limit may be breached. When this problem occurs, you will see an error message saying "Sorry--you've exceeded BibTeX's buffer size 5000." When you encounter this problem, use a text editor to open your bibliography file and shorten the field that contains too many characters.

### How can I correct errors I encounter when running LaTeX on my document after compiling the bibliography file?

If the references in your bibliography file contain certain special characters which are used as part of the syntax of LaTeX, you could see a whole host of errors when you run LaTeX on your document after running BibTeX. For example, LaTeX will view any ampersand in a journal title as an alignment character, and you will see an error message saying "Misplaced alignment tab character &." Use a text editor to find the line that is causing the error (LaTeX should tell you as part of its error message) and replace the trouble-making character with the following commands:

 Character LaTeX Command # \# $\$ % \% & \& _ \_ { \{ } \} ~ \~{ } ^ \^{ } \ $\backslash$

If you receive a warning from LaTeX that references may have changed, simply run LaTeX again. In fact, the correct order for running LaTeX and BibTeX, where document is your document name, is:

latex document
bibtex document
latex document
latex document

This process should correctly create your bibliography and in-text citations for your document.

### How can I make an organization name display correctly?

BibTeX reads text in the author field as an author's name or names unless told otherwise. For example, say a reference exported from RefWorks contains the line:

author={Institute of Electrical Engineers},

BibTeX will read this field as a person's name, where the first name is "Institute" and the last name is "of Electrical Engineers," and would format accordingly. Use a text editor and to add quotes around the field so that the line reads:

author="{Institute of Electrical Engineers}",

Now BibTeX will read this all as one piece rather than as a person's name, and will format correctly.

### How can I override BibTeX capitalization conventions?

BibTeX attempts to correct the capitalization in the title field such that only the first letter of the first word is capitalized. While this is generally grammatically correct, it can cause problems if the title contains a proper name or an acronym, so that a line in the bibliography file that looks like this:

title={IEE Proceedings},

will appear in the bibliography as "Iee proceedings." Use a text editor and to add quotes around the field so that the line reads:

title="{IEE Proceedings}",

The quotes will prevent BibTeX from applying its capitalization rules to the title of the document and thus will preserve the capitalization for proper nouns.

### How do I change the format of the bibliography?

The bibliography format is determined by the style file that you have entered in the \bibliographystyle{} command. Several default styles exist, they are explained in the section of IST's Latex Answers page entitled How to make BIBLIOGRAPHIES in Latex. Style files may also be edited to produce a required bibliography style.