Skip to content

Video 1 | Video 2 | Video 3 | Video 4 | Video 5 | Video 6 | Video 7

This seven-part series of LaTeX tutorial videos was first published in 2013; consequently, today's editor interface has changed considerably due to the development of ShareLaTeX and the subsequent merger of ShareLaTeX and Overleaf. However, the video content is still relevant and teaches you the basics of LaTeX—skills and expertise that will apply across all platforms. You don’t need any previous background knowledge, and by the end of these LaTeX guides you will be able to create and write basic LaTeX documents and have the knowledge to start learning how to create more complicated documents. Each video is accompanied by a transcript (listed below the video)—these in-situ transcripts replace the URLs shown at the start of each tutorial.

Bibliographies and natbib

Note: You can open the project used in the video by following this link.

Links and examples

Here are some of the useful links we mentioned in the video:

Here is the .bib file we used in the video:

@article{einstein,
  author =       "Albert Einstein",
  title =        "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
                 [{On} the electrodynamics of moving bodies]",
  journal =      "Annalen der Physik",
  volume =       "322",
  number =       "10",
  pages =        "891--921",
  year =         "1905",
}

@book{latexcompanion,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The \LaTeX\ Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}
 
@misc{knuthwebsite,
    author    = "Donald Knuth",
    title     = "Knuth: Computers and Typesetting",
    url       = "http://www-cs-faculty.stanford.edu/\~{}uno/abcde.html"
}

Video transcript

In the previous video we looked at inserting graphics into our documents. In this video we are going to look at writing bibliographies with BibTeX. Often when composing documents in LaTeX we need to cite different authors that we’ve quoted or referred to and compile a list of these sources in a bibliography. One way of writing a bibliography is to use an environment called ‘the bibliography’. However this is not advised as it isn’t very flexible. A better way of doing it is to use a feature of LaTeX called BibTeX. This involves creating a list or database of sources in a separate file. To do this select the new button in the project panel and select new file. For this method to work we need to save the file as a .bib file rather than a .tex file. Now every time we need to reference a source we can cite it in the .tex file and then fill in the source details in the .bib file. First we’ll look at filling in our .bib file and then we’ll move on to discussing citations.

To make a new entry in our .bib file we need to first tell BibTeX what type of source we are referencing. We then need to tell it all the details it wants for that particular type of source. There are many standard sources that BibTeX can work with. For example an article, a book, a manual, a PhD thesis and several more. I will show you three of the ones that you are most likely to use. Each recognised source type has a list of required details which you must provide, all of this information can be found online.

This is what unfilled in entries look like for an article, a book and a website. The standard structure for a BibTeX entry starts with an @ symbol followed immediately by the type of source you are citing. Then comes an opening curly bracket and a citation key of your choice which you will later use as the label to cite with in the .tex file. After a comma the following lines form a list of BibTeX keywords each followed by an equals sign and the corresponding information in quotations marks. Each item in this list is separated by a comma. After the last keyword and corresponding information you don’t need a comma but instead you close the curly brackets on the next line. For an article entry you need to fill in the author, title, journal and year information, the rest are optional. For a book entry it’s the author, title, publisher and year you must fill in. When it comes to adding a web address we use the misc type. For this source type all the keywords are optional but for a web entry you are at least going to want the URL. Here’s an example of what they might look like filled in.

A few things to note. When adding multiple authors we separate each author by the word ‘and’. In these examples the authors have been put in with their forename first and then their surname. Another way you can do it is to put their surname in first, follow it immediately with a comma and then their forename after a space. This second method is probably the best method if an author has multiple forenames as it will ensure BibTeX knows exactly which name is a forename and which is the surname. Another thing to point out is the curly brackets used in the title of the first example. These curly brackets are there to ensure BibTeX keeps the capital letters as capitals, as some BibTeX styles don’t preserve all the capitals within the title. So that’s an example of a ‘.bib’ file.

Now let’s return to the main .tex file and add some citations. To add a citation we use the \cite command followed by the citation key you chose in you .bib file for the relevant source. Now to get the bibliography to appear on the page we need to add two commands into the document. First the \bibliographystyle command and then the \bibliography command. We will add them at the bottom of the page just before the \end{document} command. Both of these commands need us to give them more information in the curly brackets. The \bibliographystyle command needs us to enter a style name. There are several styles you can use, but we’ll just use the plain style. You can find out more about other styles online. The \bibliography command wants us to enter the file name of the .bib file containing the details of the sources we are citing. If you’ve split your source details over multiple .bib files you can enter multiple filenames into this command by separating them with a comma. Now if we compile the document you will notice the citations appear in the text as bracketed numbers and a ‘References’ section has appeared below the text. At this point I should inform you that if you’re not using ShareLaTeX as your LaTeX editor you would need to run LaTeX, then run BibTeX and then run LaTeX again to get to the desired output. ShareLaTeX streamlines this process into one click of the green recompile button.

Finally I want to introduce you to the natbib package. This is a package which gives you more options as to how your citations to appear in the text. To load up this package add a new \usepackage command into the preamble. In the curly brackets we need to write natbib. In the square brackets we can enter one or more of the natbib option keywords. These keywords are used to change things like the type of brackets you want used in the citations among other things. Lists of these keywords can be found online. By default natbib uses the author–year system but it can be changed to the numeric style by using the numbers keyword. In our example we’ll keep the author–year system but specify round parentheses by adding the keyword round. Now that our package is loaded and configured we need to change the citation commands to natbib citation commands. These commands give you more control over how the citations appear in the text, for sake of time I won’t introduce all of them to you, I’ll just demonstrate the \citep command. By changing my existing \cite commands to \citep commands, the citations will appear in the text entirely encapsulated in brackets. The final thing we need to do when using natbib is change the bibliography style to one that is compatible with natbib, we will use the plainnat style but again details of these can be found online.

This concludes our discussion on bibliographies. In the next video we’ll look at inserting tables and matrices.

Video 1 | Video 2 | Video 3 | Video 4 | Video 5 | Video 6 | Video 7

Overleaf guides

LaTeX Basics

Mathematics

Figures and tables

References and Citations

Languages

Document structure

Formatting

Fonts

Presentations

Commands

Field specific

Class files

Advanced TeX/LaTeX