Typevia
References and Citations

Introduction to Bibliographies in LaTeX

Managing citations and bibliographies is one of LaTeX’s most powerful features. For academic writing, manual formatting of references is tedious and prone to error. BibLaTeX is the modern standard for handling references in LaTeX, offering a flexible and powerful way to automate the process.

In this guide, you will learn how to create a bibliography database, link it to your document, and generate professional-looking citations and reference lists automatically.

Note: While older tutorials might mention "BibTeX," modern LaTeX users should prefer BibLaTeX combined with the Biber backend. It supports full Unicode (special characters/accents) and offers much easier customization.


1. Creating the Bibliography Database (.bib)

The first step in managing references is creating a separate file with the extension .bib. This file acts as a database where you store all your source information (books, articles, websites, etc.).

Each entry in a .bib file follows a specific format:

  • An entry type (e.g., @article, @book)
  • A citation key (a unique nickname you create to reference the work)
  • Several fields (e.g., author, title, year)

Create a file named references.bib and add the following examples:

@book{lamport94,
  author    = {Leslie Lamport},
  title     = {LaTeX: A Document Preparation System},
  year      = {1994},
  publisher = {Addison-Wesley},
  address   = {Reading, Massachusetts}
}

@article{einstein1905,
  author  = {Albert Einstein},
  title   = {Zur Elektrodynamik bewegter Körper},
  journal = {Annalen der Physik},
  volume  = {322},
  number  = {10},
  pages   = {891--921},
  year    = {1905}
}

Key Rules for .bib Files:

  1. Citation Keys: These must be unique and contain no spaces (e.g., einstein1905).
  2. Authors: Always use the format Lastname, Firstname and separate multiple authors with the word and.
  3. Capitalization: BibLaTeX sometimes automatically converts titles to lowercase. To prevent this, wrap the specific letter or word in curly braces: {LaTeX}.

2. Setting Up BibLaTeX in the Preamble

To use BibLaTeX, you need to load the package in your document's preamble and point it to your .bib file.

\documentclass{article}
\usepackage[utf8]{inputenc}

% 1. Load the biblatex package
\usepackage[style=authoryear, backend=biber]{biblatex}

% 2. Specify the bibliography file
\addbibresource{references.bib}

\begin{document}
Hello World!
\end{document}

Common Package Options:

  • style: Defines how citations and the bibliography look. Popular options include numeric, authoryear, apa, mla, and ieee.
  • backend: Always set this to biber. Biber is the engine that processes your bibliography data.

3. Citing Sources in Your Text

Once your database is linked, you can cite your sources using the citation keys you defined. BibLaTeX provides several commands depending on how you want the citation to appear in your sentence.

Here are the most common citation commands:

\section{Introduction}

% Standard citation (usually in parentheses)
It has been argued that physics is interesting \parencite{einstein1905}.

% Narrative citation (author's name is part of the sentence)
\textcite{lamport94} explains that LaTeX is a powerful tool for scientists.

% Citation with specific page numbers
LaTeX is widely used for academic publishing \parencite[p. 45]{lamport94}.

% Multiple citations
Several works discuss these topics \parencite{einstein1905, lamport94}.

Tip: If you are using the numeric style, \cite and \parencite will usually look the same (e.g., [1]). If using authoryear, \parencite gives (Einstein 1905) while \textcite gives Einstein (1905).


4. Displaying the Bibliography

To display the list of references at the end of your document, use the \printbibliography command.

\section{Conclusion}
The importance of structured documents cannot be overstated.

% This command generates the actual list of references
\printbibliography[title={References}]

A Complete Example (MWE)

If you combine everything, your .tex file should look like this:

\documentclass{article}
\usepackage[style=numeric, backend=biber]{biblatex}
\addbibresource{references.bib}

\begin{document}

\section{Main Content}
The foundations of modern physics were laid by \textcite{einstein1905}. 
Furthermore, document preparation has been simplified by \parencite{lamport94}.

\printbibliography

\end{document}

5. Compiling Your Document

This is the part that often confuses beginners. Because BibLaTeX uses an external tool (Biber) to sort and format your references, you cannot just "Run LaTeX" once. You must follow a specific sequence:

  1. PDFLaTeX: Scans the document and notes which keys you cited.
  2. Biber: Looks into the .bib file and matches the keys.
  3. PDFLaTeX: Includes the processed bibliography data.
  4. PDFLaTeX: Corrects all cross-references.

Note: Most modern editors like Typevia or VS Code can be configured to do this automatically with one click (often called "Build" or "Compile"). If using Typevia, it handles this sequence for you behind the scenes.


6. Best Practices and Common Pitfalls

Use a Reference Manager

Don't write .bib files by hand if you have many sources. Use tools like Zotero, Mendeley, or JabRef. These programs allow you to export your library directly into a .bib format, saving you from syntax errors.

Keep the "and" in Authors

A common mistake is using commas to separate authors in the .bib file.

  • Incorrect: author = {Smith, John, Doe, Jane}
  • Correct: author = {Smith, John and Doe, Jane}

Handling Special Characters

If your author's name has an accent (e.g., Müller), BibLaTeX and Biber handle this perfectly as long as your file is saved with UTF-8 encoding.

The "Empty Bibliography" Error

If your bibliography doesn't show up:

  1. Check that you actually cited the source in the text using \cite or \parencite. (By default, LaTeX only shows works you actually referred to).
  2. Check the "Messages" or "Log" panel for Biber errors. Usually, it's a typo in the citation key.
  3. Ensure your .bib file is in the same folder as your .tex file.

Forcing All References to Appear

If you want to display every entry in your .bib file, even those you didn't cite in the text, add this command anywhere in your document:

\nocite{*}

By following this structure, you'll find that BibLaTeX takes the stress out of referencing, allowing you to focus entirely on the content of your writing.