Texmaker Bibliography Jabref Tutorial

Bibliography in LaTeX with Bibtex/Biblatex

Learn how to create a bibliography with Bibtex and Biblatex in a few simple steps. Create references / citations and autogenerate footnotes.

Tweet

[View example on Overleaf]

  1. Creating a .bib file
  2. Using BibTeX
  3. Autogenerate footnotes with BibLaTeX
  4. BibTeX Format
  5. BibTeX Styles

We have looked at many features of LaTeX so far and learned that many things are automated by LaTeX. There are functions to add a table of contents, lists of tables and figures and also several packages that allow us to generate a bibliography. I will describe how to use bibtex and biblatex (both external programs) to create the bibliography. At first we have to create a .bib file, which contains our bibliographic information.

Creating a .bib file

A .bib file will contain the bibliographic information of our document. I will only give a simple example, since there are many tools to generate the entries automatically. I will not explain the structure of the file itself at this point, since i suggest using a bibtex generator (choose one from google). Our example will contain a single book and look like this:

@BOOK{DUMMY:1, AUTHOR="John Doe", TITLE="The Book without Title", PUBLISHER="Dummy Publisher", YEAR="2100", }

If you don't want to use a BibTeX generator or a reference management tool like Citavi (which generates BibTeX files automatically for you), you can find more examples of BibTeX formats here.

Using BibTeX

After creating the bibtex file, we have to tell LaTeX where to find our bibliographic database. For BibTeX this is not much different from printing the table of contents. We just need the commands \bibliography which tells LaTeX the location of our .bib file and \bibliographystyle which selects one of various bibliographic styles.

\documentclass{article} \begin{document} Random citation \cite{DUMMY:1} embeddeed in text. \newpage \bibliography{lesson7a1} \bibliographystyle{ieeetr} \end{document}

By using this code, we will obtain something like this:

I named my .bib file lesson7a1.bib, note that I did not enter the .bib extension. For the style, I've choosen the ieeetr style, which is very common for my subject, but there are many more styles available. Which will change the way our references look like. The ieeetr style will mark citations with successive numbers such as [1] in this example. If I choose the style to apalike instead, i will get the following result:

Most editors will let you select, to run bibtex automatically on compilation. In TeXworks (MiKTeX) for example, this should be selected by default.

If you use a different editor, it can be necessary to execute the bibtex command manually. In a command prompt/shell simply run:

pdflatex lesson7a1.tex bibtex lesson7a1 pdflatex lesson7a1.tex pdflatex lesson7a1.tex

It is necessary to execute the pdflatex command, before the bibtex command, to tell bibtex what literature we cited in our paper. Afterwards the .bib file will be translated into the proper output for out references section. The next two steps merge the reference section with our LaTeX document and then assign successive numbers in the last step.

Autogenerate footnotes in $\LaTeX$ using BibLaTeX

The abilities of BibTeX are limited to basic styles as depicted in the examples shown above. Sometimes it is necessary to cite all literature in footnotes and maintaining all of them by hand can be a frustrating task. At this point BibLaTeX kicks in and does the work for us. The syntax varies a bit from the first document. We now have to include the biblatex package and use the \autocite and \printbibliography command. It is crucial to move the \bibliography{lesson7a1} statement to the preamble of our document:

\documentclass{article} \usepackage[backend=bibtex,style=verbose-trad2]{biblatex} \bibliography{lesson7a1} \begin{document} Random citation \autocite[1]{DUMMY:1} embeddeed in text. \newpage \printbibliography \end{document}

The \autocite command generates the footnotes and we can enter a page number in the brackets \autocite[1]{DUMMY:1} will generate a footnote like this:

For BibLaTeX we have to choose the citation style on package inclusion with:

\usepackage[backend=bibtex,style=verbose-trad2]{biblatex}

The backend=bibtex part makes sure to use BibTeX instead of Biber as our backend, since Biber fails to work in some editors like TeXworks. It took me a while to figure out how to generate footnotes automatically, because the sources I found on the internet, didn't mention this at all.

BibTeX Formats

This is not meant to be a comprehensive list of BibTeX formats, but rather give you an idea of how to cite various sources properly. If you're interested in an extensive overview of all BibTeX formats, I suggest you to check out the resources on Wikibooks.

Article

@ARTICLE{ARTICLE:1, AUTHOR="John Doe", TITLE="Title", JOURNAL="Journal", YEAR="2017", }

Book

@BOOK{BOOK:1, AUTHOR="John Doe", TITLE="The Book without Title", PUBLISHER="Dummy Publisher", YEAR="2100", }

Inbook (specific pages)

@INBOOK{BOOK:2, AUTHOR="John Doe", TITLE="The Book without Title", PUBLISHER="Dummy Publisher", YEAR="2100", PAGES="100-200", }

Website

@MISC{WEBSITE:1, HOWPUBLISHED = "\url{http://example.com}", AUTHOR = "Intel", TITLE = "Example Website", MONTH = "Dec", YEAR = "1988", NOTE = "Accessed on 2012-11-11" }

This is a list of the formats that I have most commonly used. If you think some important format is missing here, please let me know.

BibTeX Styles

Here's a quick overview of some popular styles to use with BibTeX.

Abbrv

Alpha

Apalike

IEEEtr

Plain

I'm trying to keep this list updated with other commonly used styles. If you're missing something here, please let me know.

Summary

  • Generate a bibliography with BibTeX and BibLaTeX
  • First define a .bib file using: \bibliography{BIB_FILE_NAME} (do not add .bib)
  • For BibTeX put the \bibliography statement in your document, for BibLaTeX in the preamble
  • BibTeX uses the \bibliographystyle command to set the citation style
  • BibLaTeX chooses the style as an option like: \usepackage[backend=bibtex, style=verbose-trad2]{biblatex}
  • BibTeX uses the \cite command, while BibLaTeX uses the \autocite command
  • The \autocite command takes the page number as an option: \autocite[NUM]{}

Next Lesson: Lesson 8

HomeCoding »Writing »Photography »

Tweet

Getting to Grips with LaTeX

Bibliographies with BibTeX

by Andrew Roberts

For any academic/research writing, incorporating your references into your document is an important task. Fortunately, as LaTeX was aimed for this sort of work, it has a variety of features that make dealing with your references much simpler. LaTeX has built in support for citing references. However, a much more powerful and flexible solution is achieved thanks to an auxiliary tool called BibTeX (which comes bundled as standard with Latex.)

BibTeX allows you to store all your references in an external, flat-file database. You can then easily link this database to any Latex document, and cite any reference that is contained within the file. This is often more convenient that embedding them at the end of every document you write. You can have a centralised store of your bibliography, that can be linked to as many documents as you wish (write once, read many!) Of course, you can split your bibliographies over as many files as you wish, so you could have a file of references concerning the theory of relativity, and another about quantum physics. And if you were writing about the Grand Unifying Theory (GUT), which tries to bridge the gap between the inconsistencies of these two theories, then you can easily link both to your current document, as well another file of references about GUT, for example. It's up to you how you store your references, of course.

BibTeX

The previous tutorial introduced the idea of embedding references at the end of the document, and then using the command to cite them within the text. In this tutorial, I want to do a little better than this method, as it's not as flexible as it could be. Which is why I wish to concentrate on using BibTeX.

A BibTeX database is stored as a .bib file. It is a plain text file, and so can be viewed and edited easily. The structure of the file is also quite simple. An example of a BibTeX entry:

@article{greenwade93, author = "George D. Greenwade", title = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})", year = "1993", journal = "TUGBoat", volume = "14", number = "3", pages = "342--351" }

Each entry begins with the declaration of the reference type, in the form of . BibTeX knows of practically all types you can think of, common ones such as book, article, and for papers presented at conferences, there is inproceedings, etc. In this example, I have referred to an article within a journal.

After the type, you must have a left curly brace '' to signify the beginning of the reference attributes. The first one follows immediately after the brace, which is the citation key. This key must be unique for all entries in your bibliography. It is with this identifier that you will use within your document to cross-reference it to this entry. It is up to you as to how you wish to label each reference, but there is a loose standard in which you use the author's surname, followed by the year of publication. This is the scheme that I use in this tutorial.

Next, it should be clear that what follows are the relevant fields and data for that particular reference. The field names on the left are BibTeX keywords. They are followed by an equals sign (=) where the value for that field is then placed. BibTeX expects you to explicitly label the beginning and end of each value. I personally use quotation marks ("), however, you also have the option of using curly braces ('{', '}'). But as you will soon see, curly braces have other roles, within attributes, so prefer not to use them for this job as they can get more confusing.

Remember that each attribute must be followed by a comma to delimit one from another. You do not need to add a comma to the last attribute, since the closing brace will tell BibTeX that there are no more attributes for this entry, although you won't get an error if you do.

It can take a while to learn what the reference types are, and what fields each type has available (and which ones are required or optional, etc). So I've prepared a BibTeX cheat sheet for all entry types and fields with descriptions. It may be worth bookmarking or printing these pages so that they are easily at hand when you need them.

Authors

BibTeX can be quite clever with names of authors. It can accept names in forename surname or surname, forename. I personally use the former, but remember that the order you input them (or any data within an entry for that matter) is customisable and so you can get BibTeX to manipulate the input and then output it however you like. If you use the forename surname method, then you must be careful with a few special names, where there are compound surnames, for example "John von Neumann". In this form, BibTeX assumes that the last word in the surname, and everything before is the forename, plus any middle names. You must therefore manually tell BibTeX to keep the 'von' and 'Newman' together. This is achieved easily using curly braces. So the final result would be "John {von Neumann}". If course, this is easily avoided with the surname, forename, since you have a comma to separate the surname from the forename. Of course, you use your own preference.

Secondly, there is the issue of how to tell BibTeX when a reference has more than one author. This is very simply done by putting the keyword 'and in between every author. As we can see from another example:

@book{goossens93, author = "Michel Goossens and Frank Mittlebach and Alexander Samarin", title = "The Latex Companion", year = "1993", publisher = "Addison-Wesley", address = "Reading, Massachusetts" }

This book has three authors, and each is separated as described. Of course, when BibTeX processes and outputs this, there will only be an 'and' between the penultimate and last authors, but within the .bib file, it needs the and's so that it can keep track of the individual authors.

Preserving capital letters

In the event that BibTeX has been set to not preserve all capitalisation within titles, problems can occur, especially if you are referring to proper nouns, or acronyms. To tell BibTeX to keep them, use curly braces around the letter in question, (or letters, if it's an acronym) and all will be well! As you can see in the following first entry example above:

Getting current LaTeX document to use your .bib file

This is not actually very difficult. At the end of your Latex file (that is, after the content, but before , you need to place the following commands:

\bibliographystyle{plain} \bibliography{sample}

Bibliography styles are files recognised by BibTeX that tell it how to format the information stored in the .bib file when processed for output. And so the first command listed above is declaring which style file to use. The style file in this instance is plain.bst (which comes as standard with BibTeX). You do not need to add the .bst extension when using this command, as it is assumed. Despite its name, the plain style does a pretty good job (look at the output of this tutorial to see what I mean).

The second command is the one that actually specifies the .bib file you wish to use. The one I created for this tutorial was called sample.bib, but once again, you don't include the file extension. At the moment, the .bib file is in the same directory as the LaTeX document too. However, if your .bib file was elsewhere (which makes sense if you intend to maintain a centralised database of references for all your research), you need to specify the path as well, e.g .

Now that LaTeX and BibTeX know where to look for the appropriate files, actually citing the references is fairly trivial. The is the command you need, making sure that the ref_key corresponds exactly to one of the entries in the .bib file. If you wish to cite more that one reference at the same time, do the following: .

Why won't LaTeX generate any output?

The addition of BibTeX adds extra complexity for the processing of the source to the desired output. This is largely hidden to the user, but because of all the complexity of the referencing of citations from your source LaTeX file to the database entries in another file, you actually need multiple passes to accomplish the task. This means you have to run LaTeX a number of times, where each pass, it will perform a particular task until it has managed to resolve all the citation references. Here's what you need to type:

  1. (doesn't require .tex extension)
  2. (doesn't require .bib extension)

After the first LaTeX run, you will see errors such as:

LaTeX Warning: Citation `lamport94' on page 1 undefined on input line 21. ... LaTeX Warning: There were undefined references.

The next step is to run 'bibtex' on that same LaTeX source (and not on the actual .bib file) to then define all the references within that document. You should see output like the following:

This is BibTeX, Version 0.99c (Web2C 7.3.1) The top-level auxiliary file: bib.aux The style file: plain.bst Database file #1: sample.bib

The third step, which is invoking LaTeX for the second time will see more errors like "". Don't be alarmed, it's almost complete. As you can guess, all you have to do is follow its instructions, and run LaTeX for the third time, and the document will be output as expected, without further problems (as a DVI file. See Absolote beginners tutorial if you need reminding how to convert them into PS or PDF.)

What about citation styles other than numerical, e.g., Harvard?

Hopefully, you have already looked at the PDF output of this tutorial. You will have noticed that the document ends with an automatically generated 'References' section. Each reference is numbered and each citation corresponds to the numbers. The numeric style of citation is quite common in scientific writing. In other disciplines, the author-year style, e.g., (Roberts, 2003), such as Harvard is preferred, and is in fact becoming increasingly common within scientific publications. A discussion about which is best will not occur here. I shall merely provide details for those who wish to have the choice.

Natbib

Natbib is a package written for LaTeX to do just this job. In fact, it can supersede LaTeX's own citation commands, as Natbib allows the user to easily switch between Harvard or numeric. In order to demonstrate Natbib, I've modified the original LaTeX file to take advantage of the additional functionality. Therefore, for the rest of this section, I shall be referring to bib-har.tex which can be accessed, along with the PDF of its output, at the bottom of this page.

The first job is to add the following to your preamble in order to get LaTeX to use the Natbib package:

\usepackage{natbib}

Also, you need to change the bibliography style file to be used, so edit the appropriate line at the bottom of the file so that it reads: . Once done, it is basically a matter of altering the existing commands to display the type of citation you want.

Citation commandNatbib output
Goossens et al. (1993)
(Goossens et al., 1993)
Goossens, Mittlebach, and Samarin (1993)
(Goossens, Mittlebach, and Samarin, 1993)

The main commands simply add a t for 'textual' or p for 'parenthesised', to the basic command. You will also notice how Natbib by default will compress references with three or more authors to the more concise 1st surname et al version. By adding an asterisk (*), you can override this default and list all authors associated with that citation. There some other less common commands that Natbib supports, such as , , etc., which are fairly obvious.

The final area that I wish to cover about Natbib is customising its citation style. There is a command called that can be used to override the defaults and change certain settings. For example, I have put the following in the preamble:

\bibpunct{(}{)}{;}{a}{,}{,}

The command requires six mandatory parameters.

  1. The symbol for the opening bracket.
  2. The symbol for the closing bracket.
  3. The symbol that appears between multiple citations.
  4. This argument takes a letter:
    • n - numerical style.
    • s - numerical superscript style.
    • any other letter - author-year style.
  5. The punctuation to appear between the author and the year (in parenthetical case only).
  6. The punctuation used between years, in multiple citations when there is a common author. e.g., (Chomsky 1956, 1957). If you want an extra space, then you need .
So as you can see. This package is quite flexible, especially as you can easily switch between different citation styles by changing a single parameter. Do have a look at the Natbib manual, it's a short document and you can learn even more about how to use it.

Customising bibliography appearance

In my mind, one the main advantages of BibTeX, especially for people who write many research papers, is the ability to customise your bibliography to suit the requirements of a given publication. You will notice how different publications tend to have their own style of formatting references, which authors must adhere to if they want their manuscript publishing. In fact, established journals and conference organisers often will have created their own bibliography style (.bst file) for those users of BibTeX, to do all the hard work for you.

It can achieve this because of the nature of the .bib database, where all the information about your references is stored in a structured format, but nothing about style. This is a common theme in Latex in general, where it tries as much as possible to keep content and presentation separate - as it should be!

A bibliography style file (.bst) will tell LaTeX how to format each attribute, what order to put them in, what punctuation to use in between particular attributes etc. Unfortunately, creating such a style by hand is not a trivial task. Which is why Makebst (also known as custom-bib) is the tool we need.

Makebst can be used to automatically generate a .bst file based on your needs. It is very simple, and actually asks you a series of questions about your preferences. Once complete, it will then output the appropriate style file for you to use.

It should be installed with the LaTeX distribution (otherwise, you can download it) and it's very simple to initiate. At the command line, type:

latex makebst

LaTeX will find the relevant file and the questioning process will begin. You will have to answer quite a few (although, note that the default answers are pretty sensible), which means it would be impractical to go through an example in this tutorial. However, it is fairly straight-forward. And if you require further guidance, then there is a comprehensive manual available. I'd recommend experimenting with it and seeing what the results are when applied to a LaTeX document.

If you are using a custom built .bst file, it is important that LaTeX can find it! So, make sure it's in the same directory as the Latex source file, unless you are using one of the standard style files (such as plain or plainnat, that come bundled with Latex - these will be automatically found in the directories that they are installed. Also, make sure the name of the .bst file you want to use is reflected in the command (but don't include the .bst extension!).

Summary

Although it can take a little time to get to grips with BibTeX, in the long term, it's an efficient way to handle you references. It's not uncommon to find .bib files on websites that people compile as a list of their own publications, or a survey of relevant works within a given topic, etc. Or in those huge, online bibliography databases, you often find BibTeX versions of publications, so it's a quick cut-and-paste into your own .bib file, and then no more hassle!

Having all you references in one place is a big advantage in my opinion. And having then in a structured form, that allows customisable output is another one. There are a variety of free utilities that can load you .bib files, and allow you to view them in a more efficient manner, as well as sorting them and checking for errors.

Files: bib.tex | bib.pdf | bib-har.tex | bib-har.pdf | sample.bib
Useful resources: Natbib manual | Makebst manual | BibTeX entries cheat sheet - A reference sheet summarising all BibTeX types and fields.

Last updated: February 22, 2012

« Back to LaTeX tutorials.

Tweet

Andrew Roberts © 2018

0 Replies to “Texmaker Bibliography Jabref Tutorial”

Lascia un Commento

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