Wikibook Latex Bibliography Two

Learn how to create a bibliography using modern biblatex and biber - A short tutorial.

This will only be a short overview of the main and most often used features of biblatex and biber to create a bibliography. More detailed information can be found in the package documentation.

The database[edit]

Creating a bibliography using biblatex and biber means storing all of your available bibliographic information in a simple text-based database. The name should be as unique as possible, for example . This is helpful when transferring files with your advisor, students or colleagues. biber is used to deal with the database.

Every entry in the database starts with an -sign followed by the entry type. More types are available, the package documentation lists all of them. The bibliographic information for each entry are stored in a pair of braces, beginning with a unique keyword for that entry (bibkey). Least complicated way of presenting the data is every field type in a new line, the content in curly braces, followed by a comma. The order in which you give the information is not important.

Please have a close look at the authors, every individual author is separated by the keyword . All dates are written in YYYY-MM-DD, or just the year if the other information is not available. The file which should have been installed with the package contains some sample entries.

Setting up biber[edit]

Biber is the name of the helper program that sorts the entries and provides all the relevant information to package biblatex. If you are not comfortable using the command line (aka the terminal), you should set up your editor to call biber for you. Setting up my editor to use biber shows how to do it for the different editors.

A simple example[edit]

\documentclass{article}\usepackage[backend=biber]{biblatex}\addbibresource{lauraPhd2016.bib}\begin{document} I doubt that there is any useful information here~\cite{wikibook}. All we know is limited, apart from knowing the answer we all know. Or do we? Wombat and Koala have discovered some interesting things~\cite{wombat2016}. Some people are too nosy. What can happen to them is described by Laura Lion~\cite[9]{lion2010}. \printbibliography\end{document}

Now how does it actually work? Package biblatex is loaded with the option followed by adding your database file to the list of bibliographic files using . Please note that the file extension is mandatory and that this is happening in the preamble of the document.

Within the document you can cite one of your database entries using . Your database can contain hundreds of entries, but only cited references will occur in the final list. You can use to add uncited entries to the list. If you want to add all entries from the database use .

Finally, the list of your references is printed with .

Running LaTeX (no matter if , etc.) on the main document will result in the following output.

We get several warnings about undefined references, no bibliography and instead of proper citations, we see just the cite key in bold.

In order to really get a bibliography and the citations, and not just the infamous warning, you have to run biber after latex to extract the relevant data from the database. After setting up biber as described in Setting up my editor to use biber you should be able to do it by pressing one button while working on your document. To incorporate the bibliography information into your document, LaTeX then has to process the data biber has generated before. To sum it up, if you have a file you (or your editor) will have to do:

latex lauraPhdd2016Main

biber lauraPhdd2016Main

latex lauraPhdd2016Main

Everytime your database is updated, remember to process the database by calling biber.

The full result can be seen in the picture below. Please note that package biblatex adds some small little details. Can you see things that are printed but have not been defined?

Reference Styles[edit]

Different reference styles are in use within the different disciplines of science. Very broadly speaking, you can divide into a numerical referencing sytem (Vancouver) or an author date referencing system (Harvard).

Package biblatex[1] provides different citation commands that generate different output (in-text citation, footnotes and more). A few examples are given below, the package documentation contains and explains the use of the whole set.

Numerical Referencing[edit]

Numerical referencing is the default style. Numbers within brackets are used in text and in the bibliography. Using makes it easy to change the style into footnotes. gives a bibliography that is sorted chronologically, i.e. the numbers increase to the end of the document.

\documentclass{article}\usepackage[backend=biber,style=numeric,autocite=plain,sorting=none]{biblatex}\addbibresource{lauraPhd2016.bib}\begin{document} I doubt that there is any useful information here.~\cite{wikibook} All we know is limited, apart from knowing the answer we all know. Or do we? \citeauthor{wombat2016} have discovered some interesting things.~\autocite[compare][80]{wombat2016} What can happen to nosy people is described by \textcite[9]{lion2010}. \printbibliography\end{document}

Using gives a diffferent output. Can you spot all the differences?

Author Date Referencing[edit]

If you want an author-date referencing style, you can use when loading biblatex. The option with the option puts parenthesis around the cite genererated with (which is similar to using . In some cases, may come in handy when the citation is the subject and part of the sentence flow.

\documentclass{article}\usepackage[backend=biber,style=authoryear,autocite=inline]{biblatex}\addbibresource{lauraPhd2016.bib}\begin{document} I doubt that there is any useful information here~\cite{wikibook}. All we know is limited, apart from knowing the answer we all know. Or do we?~\cite{wombat2016} Some people are too nosy. What can happen to them is described by Laura Lion~\autocite[9]{lion2010}. Some people are too nosy. What can happen to them is described by \textcite[9]{lion2010}. \printbibliography\end{document}

APA Citing[edit]

The American Psychological Association (APA) defines a very strict author year style. You can access it using and additionally defining the language mapping.

Splitting into different topics[edit]

You can split your bibliography into different topics, in trusted and untrusted sources, or in primary and secondary sources. The way to tell biblatex what is what, is by adding a tag to the entries of the database.

Note, that the entryfield in the dataase is called (plural) because you can have more than one keyword (separated by commas). When calling the command, you have to use the singular. biblatex has a powerful system of filtering data, more can be found in the manual.

Bibliographies per Section or Chapter[edit]

Some people have the need for a reference list at the end of each chapter or section. This can be done using .

\documentclass{article}\usepackage[backend=biber,defernumbers=true,refsection=section]{biblatex}\addbibresource{biblatex-examples.bib}\begin{document}\section{Aster}\cite{ctan,sigfridsson} and some text \printbibliography[heading=subbibliography]\section{Begonia}\cite{aristotle:physics,markey}\printbibliography[heading=subbibliography]\section{Cichorium}\cite{westfahl:space,baez/online}\printbibliography[heading=subbibliography]\end{document}

A bibliography in a presentation[edit]

You can use package with (see the Presentations section) to have citations and a reference list in your presentation. Using full cites right away is recommended, so listeners don't have to wait till the very end to see where information is drawn from.

This is an incomplete list of useful packages that can be used for a wide range of different kind of documents. Each package has a short description next to it and, when available, there is a link to a section describing such package in detail. All of them (unless stated) should be included in your LaTeX distribution as package_name.sty. For more information, refer to the documentation of the single packages, as described in Installing Extra Packages.

The list is in alphabetical order.

amsmath

It contains the advanced math extensions for LaTeX. The complete documentation should be in your LaTeX distribution; the file is called amsdoc, and can be dvi or pdf. For more information, see the chapter about Mathematics. Successed by package described below.

amssymb

It adds new symbols in to be used in math mode.

amsthm

It introduces the proof environment and the command. For more information see the Theorems section.

array

It extends the possibility of LaTeX to handle tables, fixing some bugs and adding new features. Using it, you can create very complicated and customized tables. For more information, see the Tables section.

babel

It provides the internationalization of LaTeX. It has to be loaded in any document, and you have to give as an option the main language you are going to use in the document. For more information see the Internationalization section.

biblatex

Advanced bibliography handling. It is the package to use for writing a thesis.

bm

Allows use of bold greek letters in math mode using the command. This supersedes the amsbsy package.

booktabs

provides ex­tra com­mands as well as be­hind-the-scenes op­ti­mi­sa­tion for producing tables. Guide­lines are given as to what con­sti­tutes a good ta­ble in the package documentation.

boxedminipage

It introduces the boxedminipage environment, that works exactly like minipage but adds a frame around it.

caption

Allows customization of appearance and placement of captions for figures, tables, etc.

cancel

Provides commands for striking out mathematical expressions. The syntax is

To change header and footer of any page of the document. It is described in the Page Layout section.

float

Im­proves the in­ter­face for defin­ing float­ing ob­jects such as fig­ures and ta­bles, introduces new floating objects types (boxed, ruled, plaintop) and provides an ability to define custom ones.

fontenc

To choose the font encoding of the output text. You might need it if you are writing documents in a language other than English. Check in the Fonts section.

gensymb

Pro­vides generic com­mands , , , and which work both in text and maths mode.

geometry

For easy management of document margins and the document page size. See Page Layout.

glossaries

For creation of glossaries and list of acronyms. For more information, see the relevant chapter.

graphicx

Allows you to insert graphic files within a document.

grffile

Improves the file name pro­cess­ing of graphic/graphicx pack­ages to sup­port a larger range of file names (spaces, multiple dots, etc.).

hyperref

It gives LaTeX the possibility to manage links within the document or to any URL when you compile in PDF. For more information, see the relevant section.

indentfirst

Once loaded, the beginning of any chapter/section is indented by the usual paragraph indentation.

inputenc

To choose the encoding of the input text. You might need it if you are writing documents in a language other than English. Check in the Special Characters section.

latexsym

Other mathematical symbols.

listings

To insert programming code within the document. Many languages are supported and the output can be customized. For more information, see the Source Code Listings.

longtable

Al­lows you to write ta­bles that con­tinue to the next page. You can also define a header and a footer which will be shown on every page the table occupies, for example cont. from last page.

mathptmx

Sets the default font of the entire document (including math formulae) to Times New Roman, which is a more familiar font, and useful in saving space when fighting against page limits.

mathrsfs

Other mathematical symbols.

mathtools

Successor of , some additional functionality, some bugs fixed.

mhchem

allows you to easily type chemical species and equations. It automatically formats chemical species so you don't have to use subscript commands. It also Allows you to draw chemical formulas.

microtype

It provides an improvement to LaTeX's default ty­po­graphic ex­ten­sions, improvements in such areas as char­ac­ter pro­tru­sion and font ex­pan­sion, in­ter­word spac­ing and ad­di­tional kern­ing, and hy­phen­at­able letter-spacing

multicol

provides the mul­ti­cols environment which typesets text into multiple columns.

natbib

Gives additional citation options and styles. Often used for journal submission.

pdfpages

This package simplifies the insertion of external multi-page PDF or PS documents.

rotating

It lets you rotate any kind of object. It is particularly useful for rotating tables. For more information, see the relevant section.

setspace

Lets you change line spacing, e.g. provides the command for making double spaced documents. For more information, see the relevant section.

showkeys

A useful package related to referencing. If you wish to reference an image or formula, you have to give it a name using and then you can recall it using . When you compile the document these will be replaced only with numbers, and you can't know which label you had used unless you take a look at the source. If you have loaded the showkeys package, you will see the label just next or above the relevant number in the compiled version. An example of a reference to a section is . This way you can easily keep track of the labels you add or use, simply looking at the preview (both dvi or pdf). Just before the final version, remove it.

showidx

It prints out all index entries in the left margin of the text. This is quite useful for proofreading a document and verifying the index. For more information, see the Indexing section.

subfiles

The "root" and "child" document can be compiled at the same time without making changes to the "child" document. For more information, see the Modular Documents section.

subcaption

It allows to define multiple floats (figures, tables) within one environment giving individual captions and labels in the form 1a, 1b.

syntonly

If you add the following code in your preamble:

\usepackage{syntonly}\syntaxonly

LaTeX skims through your document only checking for proper syntax and usage of the commands, but doesn’t produce any (DVI or PDF) output. As LaTeX runs faster in this mode you may save yourself valuable time. If you want to get the output, you can simply comment out the second line.

textcomp

Provides extra symbols, e.g. arrows like , various currencies (,...), things like and many others.

theorem

You can change the style of newly defined theorems. For more information see the Theorems section.

todonotes

Lets you insert notes of stuff to do with the syntax .

siunitx

Helps you typeset of SI-units correctly. For example . Automatically handles the correct spacing between the number and the unit. Note that even non-SI-units are set, like dB, rad, ...

ulem

It allows to underline text (either with straight or wavy line). Few examples of usage are added to the Fonts chapter.

url

It defines the command. URLs often contain special character such as '_' and '&', in order to write them you should escape them inserting a backslash, but if you write them as an argument of , you don't need to escape any special character and it will take care of proper formatting for you. If you are using hyperref, you don't need to load url because it already provides the command.

verbatim

It improves the verbatim environment, fixing some bugs. Moreover, it provides the comment environment, that lets you add multiple-line comments or easily comment out big parts of the code.

xcolor

It adds support for colored text. For more information, see the relevant section.

xypic

It is used to create trees, graphs, (commutative) diagrams, and similar things. See Xy-pic.