• Home   /  
  • Archive by category "1"

Latex Does Not Include Bibliography

Creating and Managing Bibliographies with BibTeX on Overleaf

By Lian Tze Lim


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:


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

    How do I create bibliographies in LaTeX?

    On this page:


    There are two methods for creating a bibliography. The first can be used for short documents with only a few sources, and is fairly simple. The second method is used for large documents and theses, and involves using a program called "bibtex".

    Simple method

    If all of this seems complicated, there is a simpler way to produce a quick bibliography for your document. This can be used for smaller papers, ones that don't need a very extensive bibliography. Something like this will work fine:

    You can put this at the end of your LaTeX file. If you want to refer to something from your bibliography you can put something like this in yourfile:

    which would produce something like


    Pretend that the file that we are using is called 'foo.tex'. To make a bibliography, we should put all our sources into a file called 'foo.bib'. The structure of foo.bib is as follows:

    For our sample document, we will use the following:

    Quotation Marks
    BIBTeX uses REAL quotation marks (") and NOT the opening and closing quotation marks (`` and '') that LaTeX normally uses.

    Now, everytime you refer to the book Foo Bar Baz in foo.tex, you refer to it in the following manner:

    This will match the citation number with the number of the book in the list of references.

    If you have a few references that you did not explicitly cite in the text of your document, but you would like to include it in the list of references, you use the following (in foo.tex):

    where baz, fuzz, and bong are abbreviations for the other texts.

    To actually create the bibliography, you need to use the following commands in foo.tex (these are usually at the end of the document - where you want the References section to appear):

    There are several options for \bibliographystyle:

    plainnormal style - listed in ABC order and labeled numerically
    unsrtsame as plain except entries appear in order of citation
    alphasame as plain except entry labels are used
    abbrvsame as plain except uses abbreviations for first names, month names, and journal names

    Now that you have the basis for a bibliography, you have to run both latex and bibtex on the document. First, you should run latex (to create a foo.aux file, which bibtex reads). Then run bibtex once to get some of the citations and create a .bbl file. Then run latex again so that the cross references between the text file and the bibliography are correct. You may want to repeat running bibtex and latex on the file to make sure that all cross references are correct. Be warned that adding/deleting citations and sources will require running bibtex again.

    For more information on this topic, please refer the following pages in the LaTeX manual by Leslie Lamport:

    \begin{thebibliography}{1} \bibitem{notes} John W. Dower {\em Readings compiled for History 21.479.} 1991. \bibitem{impj} The Japan Reader {\em Imperial Japan 1800-1945} 1973: Random House, N.Y. \bibitem{norman} E. H. Norman {\em Japan's emergence as a modern state} 1940: International Secretariat, Institute of Pacific Relations. \bibitem{fo} Bob Tadashi Wakabayashi {\em Anti-Foreignism and Western Learning in Early-Modern Japan} 1986: Harvard University Press. \end{thebibliography}
    This is obvious \cite{norman}.
    @BOOK{<some abbreviation that you make up>, AUTHOR = "author", TITLE = "book title", PUBLISHER = {publishing company}, ADDRESS = {where published}, YEAR = year published}
    @BOOK{bar, AUTHOR = "Star, R. M.", TITLE = "Foo Bar Baz", PUBLISHER = {MIT Press}, ADDRESS = {Cambridge, MA}, YEAR = 1989}
    \bibliography{foo} \bibliographystyle{plain}
    72-74 Bibliography and Citation 74-74 BibTeX 140-147 Format of the .bib File (also gives info on other entry types) 187-188 Bibliography and Citation

    One thought on “Latex Does Not Include Bibliography

    Leave a comment

    L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *