1 Doshicage

Bibliography Style Plain Invalidate

Your LaTeX file needs to include
  • a reference to a label in your BibTeX file whenever you want to cite an item in the file
  • a reference to the bibliography style file you want to use, which determines how the references you cite are formatted in the bibliography of your document (and possibly a LaTeX style file associated with the bibliography style)
  • a LaTeX command to generate the bibliography at the point in your document where you want it to appear.

Example using

Here is an example using the bibliography style , which produces citations in "author (year)" format. This file is available on this page (which has instructions on where to put the file once you get it). The lines related to BibTeX are highlighed. It requires the LaTeX style file to produce citations in the right style in the text (matching the format of the references produced by ). You probably have this file already (assuming you have some implementation of TeX on your computer). If you don't, you can get it on this CTAN page. Hover over orangetext to see explanations.

When you run the LaTeX file through LaTeX and BibTeX (instructions below), you'll get output for the body of the document that looks roughly like this:

This document illustrates the use of BibTeX. You may want to refer to Arrow et al. (1961) or Aliprantis and Border (1994) or Maskin (1985). Or you may want to cite a specific page in a reference, like this: see Maskin (1985, p. 199). Or perhaps you want to cite more than one paper by Maskin: Maskin (1985, 1999). Or you want to make a parenthetical reference to one or more articles, in which case the \citealt command omits the parentheses around the year (Arrow et al. 1961).
A few more options for the command are available. Here they are:
Jones et al. (1990)
Jones, Baker, and Smith (1990)
(Jones et al. 1990)
(Jones, Baker, and Smith 1990)
(Jones et al., 1990, p. 99)
(e.g. Jones et al., 1990)
(e.g. Jones et al., 1990, p. 99)
Jones et al.
Jones, Baker, and Smith
1990
*Jones et al.'s (1990)

*Assumes \citeapos is defined in your style or document like this:

(Thanks to Christopher M. Duncombe Rae for pointing out this simple way of generating a possessive citation.)

The list of references will look like this:

Aliprantis, Charalambos D. and Kim C. Border (1994), Infinite Dimensional Analysis. Springer, Berlin.

Arrow, Kenneth J., Leonid Hurwicz, and Hirofumi Uzawa (1961), "Constraint qualifications in maximization problems." Naval Research Logistics Quarterly, 8, 175–191.

Maskin, Eric S. (1985), "The theory of implementation in Nash equilibrium: a survey." In Social Goals and Social Organization (Leonid Hurwicz, David Schmeidler, and Hugo Sonnenschein, eds.), 173–204, Cambridge University Press.

Maskin, Eric S. (1999), "Nash equilibrium and welfare optimality." Review of Economic Studies, 66, 23–38.

Example using

Here is an example using the bibliography style , which in included in many LaTeX systems.

When you run the LaTeX file through LaTeX and BibTeX (instructions below), you'll get output for the body of the document that differs from the output when you use only in that the names of all three authors of Arrow, Hurwicz, and Uzawa (1961) are listed in the first citation to that work, although not in the second, parenthetical, citation.

The list of references differs more significantly from the list produced by : only authors' initials, not their full first names, are included, and "&" rather than "and" is used as a separator; numbers in page ranges are separated by hyphens, rather than the conventional en-dashes. Precisely, the list of references produced by looks like this:

Aliprantis, C. D. & K. C. Border (1994), Infinite Dimensional Analysis. Berlin: Springer.

Arrow, K. J., Hurwicz, L., & Uzawa, H. (1961), Constraint qualifications in maximization problems. Naval Research Logistics Quarterly, 8, 175-191.

Maskin, E. S. (1985), The theory of implementation in Nash equilibrium: a survey. In L. Hurwicz, D. Schmeidler, & H. Sonnenschein (Eds.), Social Goals and Social Organization (p. 173-204). Cambridge: Cambridge University Press.

Maskin, Eric S. (1999), Nash equilibrium and welfare optimality. Review of Economic Studies, 66, 23-38.

Other bibliography styles for author-year citations

A family of styles that produce author-year citations is available on this page.

Creating your own bibliography style

A BibTeX style file is plain text, which in principle you can edit. However, the language used is arcane, and changes that are more than trivial are tricky. A better way to proceed is to create a new style file from scratch, using the custom-bib package (that's how I created ). You run TeX on a file, which asks you a long list of questions about the features of the style you would like. You'll probably not be completely clear about your preferred answers to all the questions on your first attempt, but two or three runs should produce a format to your liking.

Creating and Managing Bibliographies with BibTeX on Overleaf

By Lian Tze Lim

Introduction

Many tutorials have been written about what \(\mathrm{Bib\TeX}\) is and how to use it. However, based on my experience of providing support to Overleaf’s users, it’s still one of the topics that many newcomers to \(\mathrm{\LaTeX}\) find complicated—especially when things don’t go quite right; for example: citations aren’t appearing; problems with authors’ names; not sorted to a required order; URLs not displayed in the references list, and so forth.

In this first article, one of a planned series to address references, we’ll pull together all the threads relating to citations, references and bibliographies, as well as how Overleaf and related tools can help users manage these.

We’ll start with a quick recap of how \(\mathrm{Bib\TeX}\) and bibliography database () files work and look at some ways to prepare files. This is, of course, running the risk of repeating some of the material contained in many online tutorials, but future blog posts will expand our coverage to include bibliography styles and —the alternative package and bibliography processor.

Bibliography: just a list of

Let’s first take a quick look “under the hood” to see what a \(\mathrm{\LaTeX}\) reference list is comprised of—please don’t start coding your reference list like this because later in this article we’ll look at other, more convenient, ways to do this.

A reference list really just a list of :

By default, this environment is a numbered list with labels , and so forth. If the document class used is , automatically inserts a numberless section heading with (default value: References). If the document class is or report, then a numberless chapter heading with (default value: Bibliography) is inserted instead. Each takes a cite key as its parameter, which you can use with commands, followed by information about the reference entry itself. So if you now write

together with the block from before, this is what gets rendered into your PDF when you run a \(\mathrm{\LaTeX}\) processor (i.e. any of , , or ) on your source file:

Figure 1: Citing entries from a list.

Notice how each is automatically numbered, and how then inserts the corresponding numerical label.

takes a numerical argument: the widest label expected in the list. In this example we only have two entries, so is enough. If you have more than ten entries, though, you may notice that the numerical labels in the list start to get misaligned:

Figure 2: with a label that’s too short.

We’ll have to make it instead, so that the longest label is wide enough to accommodate the longer labels, like this:

Figure 3: with a longer label width.

If you compile this example code snippet on a local computer you may notice that after the first time you run (or another \(\mathrm{\LaTeX}\) processor), the reference list appears in the PDF as expected, but the commands just show up as question marks [?].

This is because after the first \(\mathrm{\LaTeX}\) run the cite keys from each (, ) are written to the file and are not yet available for reading by the commands. Only on the second run of are the commands able to look up each cite key from the file and insert the corresponding labels (, ) into the output.

On Overleaf, though, you don’t have to worry about re-running yourself. This is because Overleaf uses the build tool, which automatically re-runs (and some other processors) for the requisite number of times needed to resolve outputs. This also accounts for other cross-referencing commands, such as and .

A note on compilation times

Processing \(\mathrm{\LaTeX}\) reference lists or other forms of cross-referencing, such as indexes, requires multiple runs of software—including the \(\mathrm{\TeX}\) engine (e.g., ) and associated programs such as \(\mathrm{Bib\TeX}\), , etc. As mentioned above, Overleaf handles all of these mulitple runs automatically, so you don’t have to worry about them. As a consequence, when the preview on Overleaf is refreshing for documents with bibliographies (or other cross-referencing), or for documents with large image files (as discussed separately here), these essential compilation steps may sometimes make the preview refresh appear to take longer than on your own machine. We do, of course, aim to keep it as short as possible! If you feel your document is taking longer to compile than you’d expect, here are some further tips that may help.

Enter \(\mathrm{Bib\TeX}\)

There are, of course, some inconveniences with manually preparing the list:

  • It’s up to you to accurately format each based on the reference style you’re asked to use—which bits should be in bold or italic? Should the year come immediately after the authors, or at the end of the entry? Given names first, or last names first?
  • If you’re writing for a reference style which requires the reference list to be sorted by the last names of first authors, you’ll need to sort the s yourself.
  • For different manuscripts or documents that use different reference styles you’ll need to rewrite the for each reference.

This is where \(\mathrm{Bib\TeX}\) and bibliography database files ( files) are extremely useful, and this is the recommended approach to manage citations and references in most journals and theses. The approach, which is slightly different and gaining popularity, also requires a file but we’ll talk about in a future post.

Instead of formatting cited reference entries in a list, we maintain a bibliography database file (let’s name it for our example) which contains format-independent information about our references. So our file may look like this:

You can find more information about other \(\mathrm{Bib\TeX}\) reference entry types and fields here—there’s a huge table showing which fields are supported for which entry types. We’ll talk more about how to prepare files in a later section.

Now we can use with the cite keys as before, but now we replace with a to choose the reference style, as well as to point \(\mathrm{Bib\TeX}\) at the file where the cited references should be looked-up.

This is processed with the following sequence of commands, assuming our \(\mathrm{\LaTeX}\) document is in a file named (and that we are using ):

    and we get the following output:

    Figure 4: \(\mathrm{Bib\TeX}\) output using the bibliography style.

    Whoah! What’s going on here and why are all those (repeated) processes required? Well, here’s what happens.

    1. During the first run, all sees is a and a from . It doesn’t know what all the commands are about! Consequently, within the output PDF, all the commands are simply rendered as [?], and no reference list appears, for now. But writes information about the bibliography style and file, as well as all occurrences of , to the file .

    2. It’s actually that \(\mathrm{Bib\TeX}\) is interested in! It notes the file indicated by , then looks up all the entries with keys that match the commands used in the file. \(\mathrm{Bib\TeX}\) then uses the style specified with to format the cited entries, and writes a formatted list into the file . The production of the file is all that’s achieved in this step; no changes are made to the output PDF.

    3. When is run again, it now sees that a file is available! So it inserts the contents of i.e. the into the \(\mathrm{\LaTeX}\) source, where is. After this step, the reference list appears in the output PDF formatted according to the chosen , but the in-text citations are still [?].

    4. is run again, and this time the commands are replaced with the corresponding numerical labels in the output PDF!

    As before, the build tool takes care of triggering and re-running and as necessary, so you don’t have to worry about this bit. You can inspect the generated file on Overleaf, if you click on the downward-pointing triangle next to the “Download as ZIP” button, and choose the “For submission (with .bbl)” option. This is also useful for some journal submission sites where their internal \(\mathrm{\LaTeX}\) compilation systems do not run separately.

    On some other journals, if you are asked to “copy the contents of the file into your manuscript”, you can also use this download option to access the file. You can then copy-and-paste the contents to replace the original lines in your manuscript.

    A few further things to note about using \(\mathrm{Bib\TeX}\) and :

    • You may have noticed that although contained five \(\mathrm{Bib\TeX}\) reference entries, only two are included in the reference list in the output PDF. This is an important point about \(\mathrm{Bib\TeX}\): the file’s role is to store bibliographic records, and only entries that have been cited (via ) in the files will appear in the reference list. This is similar to how only cited items from an EndNote database will be displayed in the reference list in a Microsoft Word document. If you do want to include all entries—to be displayed but without actually citing all of them—you can write . This also means you can reuse the same file for all your \(\mathrm{\LaTeX}\) projects: entries that are not cited in a particular manuscript or report will be excluded from the reference list in that document.
    • \(\mathrm{Bib\TeX}\) requires one and one to function correctly—in future posts we’ll see how to create multiple bibliographies in the same document. If you keep getting “undefined citation” warnings, check that you have indeed included those two commands, and that the names are spelled correctly. File extensions are not usually required, but bear in mind that file names are case sensitive on some operating systems—including on Overleaf! Therefore, if you typed (note the typo: “e”) instead of , or wrote when the actual file name is , you’ll get the dreaded [?] as citations.
    • In the same vein, treat your cite keys as case-sensitive, always. Use the exact same case or spelling in your as in your file.
    • The order of references in the file does not have any effect on how the reference list is ordered in the output PDF: the sorting order of the reference list is determined by the. For example, some readers might have noticed that, within my earlier example, the first citation in the text is numbered [2], while the second citation in the text () is numbered [1]! Have \(\mathrm{\LaTeX}\) and \(\mathrm{Bib\TeX}\) lost the plot? Not at all: this is actually because the style sorts the reference list by alphabetical order of the first author’s last name. If you prefer a scheme where the numerical citation labels are numbered sequentially throughout the text, you’ll have to choose a bibliography style which implements this. For example, if instead we had used for that example, we’d get the following output. Notice also how the formatting of each cited item in the reference list has automatically updated to suit the IEEE’s style:

    Figure 5: bibliography style output.

    We’ll talk more about different bibliography styles, including author–year citation schemes, in a future blog post. For now, let’s turn our attention to file contents, and how we can make the task of preparing files a bit easier.

    Taking another look at files

    As you may have noticed earlier, a file contains \(\mathrm{Bib\TeX}\) bibliography entries that start with an entry type prefixed with an . Each entry has a some key–value \(\mathrm{Bib\TeX}\) fields, placed within a pair of braces (). The cite key is the first piece of information given within these braces, and every field in the entry must be separated by a comma:

    As a general rule, every bibliography entry should have an , and field, no matter what the type is. There are about a dozen entry types although some bibliography styles may recognise/define more; however, it is likely that you will most frequently use the following entry types:

    • for journal articles (see example above).
    • for conference proceeding articles:
    • for books (see examples above).
    • , for dissertations and theses:
    • is for a book chapter where the entire book was written by the same author(s): the chapter of interest is identified by a chapter number:
    • is for a contributed chapter in a book, so would have its own and . The actual title of the entire book is given in the field; it is likely that an field will also be present:
    • is for whatever doesn’t quite fit any other entry type. It can be especially useful for web pages—by writing or :
      • you will often find it useful to add or in your files’ preamble (for more robust handling of URLs);
      • not all bibliography styles support the field: doesn’t, but does. All styles support . More on this in a future post;
      • you should be mindful that even web pages and entries should have an , a and a field:

    Multiple authors in \(\mathrm{Bib\TeX}\)

    In a file, commas are only used to separate the last name from the first name of an author—if the last name is written first. Individual author names are separated by . So these are correct:

    or

    But none of the following will work correctly—you’ll get weird output, or even error messages from \(\mathrm{Bib\TeX}\)! So take extra care if you are copying author names from a paper or from a web page.

    Multiple-word last names

    If an author’s last name is made up of multiple words separated by spaces, or if it’s actually an organisation, place an extra pair of braces around the last name so that \(\mathrm{Bib\TeX}\) will recognise the grouped words as the last name:

    Alternatively, you can use the format; some users find that clearer and more readable:

    Remember: Whether the first or last name appears first in the output (“John Doe” vs “Doe, John”), or whether the first name is automatically abbreviated “J. Doe” or “Doe, J.” vs “John Doe” “J. Doe”), all such details are controlled by the .

    is actually not a comment character in files! So, inserting a in files not only fails to comment out the line, it also causes some \(\mathrm{Bib\TeX}\) errors. To get \(\mathrm{Bib\TeX}\) to ignore a particular field we just need to rename the field to something that \(\mathrm{Bib\TeX}\) doesn’t recognise. For example, if you want to keep a field around but prefer that it’s ignored (perhaps because you want \(\mathrm{Bib\TeX}\) to use the field instead) write or the more human-readable .

    To get \(\mathrm{Bib\TeX}\) to ignore an entire entry you can remove the before the entry type. A valid reference entry always starts with a followed by the entry type; without the character \(\mathrm{Bib\TeX}\) skips the lines until it encounters another .

    How/where do I actually get those files?

    Edit the file as plain text

    Because files are plain text you can certainly write them by hand—once you’re familiar with \(\mathrm{Bib\TeX}\)’s required syntax. Just make sure that you save it with a extension, and that your editor doesn’t surreptitiously add a or some other suffix. On Overleaf you can click on the “Files…” link at the top of the file list panel, and then on “Add blank file” to create a fresh file to work on.

    Pro tip: Did you know that Google Scholar search results can be exported to a \(\mathrm{Bib\TeX}\) entry? Click on the “Cite” link below each search result, and then on the “\(\mathrm{Bib\TeX}\)” option search. You can then copy the \(\mathrm{Bib\TeX}\) entry generated. Here’s a video that demonstrates the process. Note that you should always double-check the fields presented in the entry, as the automatically populated information isn’t always comprehensive or accurate!

    Help from GUI-based editors

    Many users prefer to use a dedicated \(\mathrm{Bib\TeX}\) bibliography database editor/manager, such as JabRef or BibDesk to maintain, edit and add entries to their files. Using a GUI can indeed help reduce syntax and spelling errors whilst creating bibliography entries in a \(\mathrm{Bib\TeX}\) file. If you prefer, you can prepare your file on your own machine using JabRef, BibDesk or another utility, and then upload it to your Overleaf project using “Files > Bibliography > Upload .bib file”.

    Pro tip: If you’d like to use the same for multiple Overleaf projects, have a look at this help article to set up a “master project”, or this one for sharing files from Google Drive (the instructions apply to other cloud-based storage solutions, such as Dropbox).

    Export from reference library services

    If you click on the “Files > Bibliography” menu item in your Overleaf editor you may notice some options: Import your Mendeley, Zotero and CiteULike libraries! If you’re already using one of those reference library management services, Overleaf can now hook into the Web exporter APIs provided by those services to import the file (generated from your library) into your Overleaf project.

    For other reference library services that don’t have a public API, or are not yet directly integrated with Overleaf, such as EndNote or Paperpile, look for an “export to ” option in the application or service. Once you have a file, you can then add it to your Overleaf project using the steps explained earlier and in the linked help articles.

    I’ve already got a reference list in a Microsoft Word/HTML/PDF file; can I somehow reuse the data without re-typing everything?

    It used to be that you would have to hand-code each line into a or an entry (or another entry type) in a file. As you can imagine, it’s not exactly a task that many people look forward to. Fortunately, these days some tools are available to help. They typically take a plain text file, e.g.

    and attempt to parse the lines, converting it into a structured bibliography as a \(\mathrm{Bib\TeX}\) file. For example, have a look at text2bib or Edifix. Be sure to go through the options of these tools carefully, so that they work well with your existing unstructured bibliography in plain text.

    Summary and future articles

    We’ve now had a quick look at how \(\mathrm{Bib\TeX}\) processes a bibliography database file to resolve commands and produce a formatted reference list, as well as how to prepare files. In an forthcoming post we’ll look further into some popular options, as well as some citation niceties provided by the package.

    Until then, happy \(\mathrm{Bib\TeX}\)ing!

    More news from Overleaf

    Lian Tze Lim

    Community TeXpert

    Computer scientist, once-lecturer, trainer. Enjoys tinkering with LaTeX in the name of productive procrastination (ahem). Personal motto: "all research students are insane at one time or another".

    Leave a Comment

    (0 Comments)

    Your email address will not be published. Required fields are marked *