Sphinxcontrib-BibTeX

2.6.5 · active · verified Sun Apr 12

Sphinxcontrib-bibtex is a Sphinx extension that enables BibTeX-style citations in documentation. It allows users to insert citations via roles like `:cite:p:` and `:cite:t:` and generate bibliographies using a `.. bibliography::` directive, similar to LaTeX's `thebibliography` environment. The library is currently at version 2.6.5 and maintains an active development and release cadence.

Warnings

Install

Imports

Quickstart

To quickly set up `sphinxcontrib-bibtex`, first install it via pip. Then, modify your `conf.py` to add `'sphinxcontrib.bibtex'` to your `extensions` list and specify your BibTeX files using `bibtex_bibfiles`. Create a `.bib` file (e.g., `refs.bib`) with your entries. Finally, use `:cite:t:` (textual), `:cite:p:` (parenthetical) roles, and the `.. bibliography::` directive in your reStructuredText files to cite and display your references.

# conf.py
import os
import sys

project = 'My Project'
copyright = '2026, Author'

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.napoleon',
    'sphinxcontrib.bibtex',
]

# Configure paths to your BibTeX files
bibtex_bibfiles = ['refs.bib']

# Optional: Set a default referencing style (e.g., 'author_year')
# bibtex_reference_style = 'author_year'

# index.rst (or any .rst file)
"""
.. _index:

Welcome to My Project's Documentation!
======================================

This is a demonstration of ``sphinxcontrib-bibtex``.

Here's a textual citation: See :cite:t:`1987:nelson` for an introduction to non-standard analysis.
And here's a parenthetical one: Non-standard analysis is fun :cite:p:`1987:nelson`.

References
----------

.. bibliography::
   :all:
   :max_citation_text_length: 80
"""

# refs.bib
"""
@Book{1987:nelson,
  author = {Edward Nelson},
  title = {Radically Elementary Probability Theory},
  publisher = {Princeton University Press},
  year = {1987}
}
"""

view raw JSON →