# Full Bibliography Latex

By In 1

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".

When it comes to bibliography management packages, there are three main options in LaTeX: bibtex, natbib and biblatex. Biblatex is a modern program to process bibliography information, provides an easier and more flexible interface and a better language localization that the other two options. This article explains how to use biblatex to manage and format the bibliography in a LaTeX document.

## Introduction

A minimal working example of the biblatex package is shown below:

\documentclass{article}\usepackage[utf8]{inputenc}\usepackage[english]{babel}   \usepackage{biblatex}\addbibresource{sample.bib}   \begin{document} Let's cite! The Einstein's journal paper \cite{einstein} and the Dirac's book \cite{dirac} are physics related items.   \printbibliography   \end{document}

There are four bibliography-related commands in this example:

Imports the package biblatex.
Imports the bibtex data file sample.bib, this file is the one that includes information about each referenced book, article, etc. See the bibliography file section for more information.
This command inserts a reference within the document, [1] in this case, that corresponds to an element in the bibliography, "einstein" is a keyword corresponding to an entry in sample.bib.
Prints the list of cited references, the default title is "References" for the article document class and "Bibliography" for books and reports.

ShareLaTeX provides several templates with pre-defined styles to manage bibliography. See this link

Open an example of the biblatex package in ShareLaTeX

## Basic usage

Several parameters can be passed to the package import command, as in the following example:

\documentclass{article}\usepackage[utf8]{inputenc}\usepackage[english]{babel}   \usepackage{comment}   \usepackage[ backend=biber, style=alphabetic, sorting=ynt ]{biblatex}\addbibresource{sample.bib}   \title{Bibliography management: \texttt{biblatex} package}\author{Share\LaTeX}\date{}   \begin{document}   \maketitle   Using \texttt{biblatex} you can display bibliography divided into sections, depending of citation type. Let's cite! Einstein's journal paper \cite{einstein} and the Dirac's book \cite{dirac} are physics related items. Next, \textit{The \LaTeX\ Companion} book \cite{latexcompanion}, the Donald Knuth's website \cite{knuthwebsite}, \textit{The Comprehensive Tex Archive Network} (CTAN) \cite{ctan} are \LaTeX\ related items; but the others Donald Knuth's items \cite{knuth-fa,knuth-acp} are dedicated to programming.   \medskip   \printbibliography   \end{document}

Some extra options, inside brackets and comma-separated, are added when importing biblatex:

Sets the backend to sort the bibliography, is the default one and recommended since it provides full localization for several commands and the styles for biber are easier to modify because they use standard LaTeX macros. The other supported backend is , which is a more traditional program; if set as the backend, bibtex will only be used to sort the bibliography, so no bibtex styles can be used here.
Defines the bibliography style and the citation style, in this case . Depending on the style, more citation commands might be available. See biblatex bibliography styles and citation styles for more information.
Determines the criteria to sort the bibliographic sources. In this case they are sorted by year, name and title. See the reference guide for a list of sorting options.

The rest of the commands were explained in the introduction.

Open an example of the biblatex package in ShareLaTeX

## The bibliography file

The bibliography files must have the standard bibtex syntax

This file contains records in a special format, for instance, the first bibliographic reference is defined by:

This is the first line of a record entry, tells BibTeX that the information stored here is about an article. The information about this entry is enclosed within braces. Besides the entry types shown in the example (, , and ) there are a lot more, see the reference guide.
The label is assigned to this entry, is a unique identifier that can be used to refer this article within the document.
This is the first field in the bibliography entry, indicates that the author of this article is Albert Einstein. Several comma-separated fields can be added using the same syntax , for instance: title, pages, year, URL, etc. See the reference guide for a list of possible fields.

The information in this file can later be printed and referenced within a LaTeX document, as shown in the previous sections, with the command . Not all the information in the .bib file will be displayed, it depends on the bibliography style set in the document.

Open an example of the biblatex package in ShareLaTeX

## Customizing the bibliography

Biblatex allows high customization of the bibliography section with little effort. It was mentioned that several citation styles and bibliography styles are available, and you can also create new ones. Another customization option is to change the default title of the bibliography section.

\documentclass{article}\usepackage[utf8]{inputenc}\usepackage[english]{babel}   \usepackage{comment}   \usepackage[ backend=biber, style=alphabetic, sorting=ynt ]{biblatex}\addbibresource{sample.bib}   \title{Bibliography management: \texttt{biblatex} package}\author{Share\LaTeX}\date{}   \begin{document}   \maketitle   Using \texttt{biblatex} you can display bibliography divided into sections, depending of citation type. Let's cite! The Einstein's journal paper \cite{einstein} and the Dirac's book \cite{dirac} are physics related items. Next, \textit{The \LaTeX\ Companion} book \cite{latexcompanion}, the Donald Knuth's website \cite{knuthwebsite}, \textit{The Comprehensive Tex Archive Network} (CTAN) \cite{ctan} are \LaTeX\ related items; but the others Donald Knuth's items \cite{knuth-fa,knuth-acp} are dedicated to programming.   \medskip   \printbibliography[title={Whole bibliography}]

The additional parameter passed inside brackets to the command is the one that changes the title.

The bibliography can also be subdivided into sections based on different filters, for instance: print only references from the same author, the same journal or similar title. Below an example.

\printbibliography[type=article,title={Articles only}]\printbibliography[type=book,title={Books only}]   \printbibliography[keyword={physics},title={Physics-related only}]\printbibliography[keyword={latex},title={\LaTeX-related only}]

Here, the bibliography is divided in 4 sections. The syntax of the commands used here is explained below:

Only prints entries whose type is "article", and sets the title "Articles only" for this section. The same syntax works for any other entry type.
Filters bibliography entries that include the word "physics" in any of the fields. Sets the title "Physics-related only" for said section.

Open an example of the biblatex package in ShareLaTeX

For the bibliography the be printed in the table of contents an extra option must be passed to

• The second case is that adds the title as a second level entry in the table of contents, in this example as a subsection nested in "Whole bibliography".

Open an example of the biblatex package in ShareLaTeX

## Reference guide

Supported entry types

 article book mvbook inbook bookinbook suppbook booklet collection mvcollection incollection suppcollection manual misc online patent periodical suppperiodical proceedings mvproceedings inproceedings reference mvreference inreference report set thesis unpublished custom conference electronic masterthesis phdthesis techreport

Supported entry fields (The printed information depends on the bibliography style)

 abstract addendum afterword annotate author authortype bookauthor bookpagination booksubtitle booktitle chapter commentator date doi edition editor editortype eid entrysubtype eprint eprinttype eprintclass eventdate eventtitle file foreword holder howpublished indextitle institution introduction isan isbn ismn isrn issue issuesubtitle issuetitle iswc journalsubtitle journaltitle label language library location mainsubtitle maintitle month note number organization origdate origlanguage origlocation origpublisher origtitle pages pagetotal pagination part publisher pubstate reprinttitle series shortauthor shortedition shorthand shorthandintro shortjournal shortseries shorttitle subtitle title translator type url venue version volume year

Bibliography sorting options

option description
sort by name, title, year
sort by name, year, title
sort by name, year, volume, title
sort by alphabetic label, name, year, title
sort by alphabetic label, name, year, volume, title
sort by year (descending), name, title
entries are processed in citation order

For detailed information on these entries and options, see the package documentation.