[Tex/LaTex] The most basic biblatex example

biblatex

I am looking for the most basic example code for using biblatex.

Consider the following bib entries (copied from the answer for this question)

\begin{filecontents}{\jobname.bib}
@book{Labov1972,
    Address = {Philadelphia},
    Author = {William Labov},
    Publisher = {University of Pennsylvania Press},
    Title = {Sociolinguistic Patterns},
    Year = {1972}}

@book{Chomsky1957,
    Address = {The Hague},
    Author = {Noam Chomsky},
    Publisher = {Mouton},
    Title = {Syntactic Structures},
    Year = {1957}}
\end{filecontents}

and this code

\documentclass[a4paper,11pt]{article}
\usepackage[style=numeric,backend=biber]{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
As first example citation here is \cite{Chomsky1957}. 
Here is another example citation \cite{Labov1972}
\printbibliography
\end{document}

How should I load biblatex (what should I change in the above code) in order to get numeric citation style that would look like: [1] (a number in a square brackets).

How different (what exactly to change) in order to get author-year style that would look like Labov (1972).

For some reason the list does not print. It is not the main issue here.
However, here is an arbitrary option to list the entries (copied from the same answer above).

What are the additional minimal required commands to print it?

enter image description here

Best Answer

Bibliography and citation formatting is complicated, and that's why the biblatex package, which has thought through the issues extremely thoroughly, is also complicated. As end users, we tend to think of simple cases without realizing that making the simple case more general is not always simple.

For this reason, especially if you are a beginner, (and even if you're not) you should try to adapt to some of the standard styles offered by the biblatex package itself, or use one of the many excellent user contributed styles that implement most of the major schemes. This is especially true if you have any flexibility in your choice of styles (i.e., you are not bound to a very particular style by a specific journal, for example.)

For a list of available styles see the biblatex section of:

For author/year citations, the apa style for biblatex is an excellent implementation of the APA style.

Citation styles and bibliography styles

There are two main formatting considerations for any citation system: the formatting of the citations themselves in the text, and the formatting of the bibliography items in the bibliography. The biblatex package treats both of these separately, although there are obviously dependencies between the two. In this answer I will discuss only author/year and numeric schemes, which are common in the natural and social sciences. Footnote style citations as used in the humanities are quite different, and pose their own set of problems (although biblatex is also designed to deal with them.)

Citation commands

There are three basic citation commands in biblatex plus some automatic ones. All of the citation commands allow two optional arguments: a prenote and a postnote.

  1. \cite standard citation
  2. \parencite standard citation in parentheses
  3. \footcite like \cite but puts the citation in a footnote.

There are many variants of these commands. See §3.7 of the biblatex manual for more details.

Among the more useful special cite commands are:

  1. \textcite is like \cite but puts the label text (like the year in an author/year system) in parentheses.
  2. \autocite is designed for (almost) seamlessly transitioning between \parencite and \footcite, for example, and provides a higher level markup that can be mapped to either command.

Author/Year Style

\begin{filecontents}{\jobname.bib}
@book{Labov1972,
    Address = {Philadelphia},
    Author = {William Labov},
    Publisher = {University of Pennsylvania Press},
    Title = {Sociolinguistic Patterns},
    Year = {1972}}

@book{Chomsky1957,
    Address = {The Hague},
    Author = {Noam Chomsky},
    Publisher = {Mouton},
    Title = {Syntactic Structures},
    Year = {1957}}
}
\end{filecontents}

\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
Some famous linguists wrote a couple of books \autocite{Labov1972,Chomsky1957}.
\printbibliography
\end{document}

enter image description here

Numeric style

\documentclass{article}
\usepackage[style=numeric]{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
Some famous linguists wrote a couple of books \autocite{Labov1972,Chomsky1957}.
\printbibliography
\end{document}

enter image description here

Author/year citations with numeric bibliography

\documentclass{article}
\usepackage[citestyle=authoryear,bibstyle=numeric]{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
Some famous linguists wrote a couple of books \autocite{Labov1972,Chomsky1957}.
\printbibliography
\end{document}

output of code

Compiling documents that use biblatex

As with other bibliography packages, compiling documents with biblatex requires a multi-step process. First you compile your document using your regular TeX engine (pdflatex, xelatex, or lualatex) and then you run a separate program biber which processes the bibliography. For example, if you are compiling any of the of the MWEs shown above, using the filename test.tex, then the full compilation command chain would be the following. (Replace pdflatex with xelatex or lualatex as needed.)

pdflatex test.tex
biber test
pdflatex test.tex
pdflatex test.tex

where biber test is short-hand for biber test.bcf.

Since most people use IDEs to process their source documents, it's helpful to know how to set up your editor to use biber instead of bibtex. See this question for details on that.

Do I have to use biber? Why can't I use bibtex?

Although it's possible with some biblatex styles to use bibtex to process the bibliography by passing the [backend=bibtex] option to the package, most modern styles depend on the use of biber so you should generally not use bibtex to process documents that use biblatex.

Related Question