Skip to main content

Sphinx extension for BibTeX style citations.

Project description

ci codecov latest version license

Sphinx extension for BibTeX style citations.

Overview

The bibtex extension allows BibTeX citations to be inserted into documentation generated by Sphinx, via a bibliography directive, along with :cite:p: and :cite:t: roles. These work similarly to LaTeX’s thebibliography environment and the \citet and \citep commands.

For formatting, the extension relies on pybtex written by Andrey Golovizin. The extension is inspired by Matthew Brett’s bibstuff.sphinxext.bibref and Weston Nielson’s sphinx-natbib.

Installation

Install the module with pip install sphinxcontrib-bibtex, or from source using pip install -e .. Then add:

extensions = ['sphinxcontrib.bibtex']
bibtex_bibfiles = ['refs.bib']

to your project’s Sphinx configuration file conf.py.

Minimal Example

In your project’s documentation, you can use :cite:t: for textual citation references, :cite:p: for parenthetical citation references, and .. bibliography:: for inserting the bibliography. For example:

See :cite:t:`1987:nelson` for an introduction to non-standard analysis.
Non-standard analysis is fun :cite:p:`1987:nelson`.

.. bibliography::

where refs.bib would contain an entry:

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

In the default style, this will get rendered as:

See Nelson [Nel87a] for an introduction to non-standard analysis. Non-standard analysis is fun [Nel87a].

[Nel87a] (1,2)

Edward Nelson. Radically Elementary Probability Theory. Princeton University Press, 1987.

Citations in sphinx are resolved globally across all documents. Typically, you have a single bibliography directive across your entire project which collects all citations. Advanced use cases with multiple bibliography directives across your project are also supported, but some care needs to be taken from your end to avoid duplicate citations.

In contrast, footnotes in sphinx are resolved locally per document. To achieve local bibliographies per document, you can use citations represented by footnotes as follows:

See :footcite:t:`1987:nelson` for an introduction to non-standard analysis.
Non-standard analysis is fun\ :footcite:p:`1987:nelson`.

.. footbibliography::

which will get rendered as:

See Nelson[1] for an introduction to non-standard analysis. Non-standard analysis is fun[1].

Note the use of the backslash escaped space to suppress the space that would otherwise precede the footnote.

Typically, you have a single footbibliography directive at the bottom of each document that has footnote citations. Advanced use cases with multiple footbibliography directives per document are also supported. Since everything is local, there is no concern with duplicate citations when using footnotes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinxcontrib_bibtex-2.7.0.tar.gz (120.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinxcontrib_bibtex-2.7.0-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

Details for the file sphinxcontrib_bibtex-2.7.0.tar.gz.

File metadata

  • Download URL: sphinxcontrib_bibtex-2.7.0.tar.gz
  • Upload date:
  • Size: 120.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sphinxcontrib_bibtex-2.7.0.tar.gz
Algorithm Hash digest
SHA256 fee700f7aae29bb8f654c62913f00d34ac44fc0b8ca0fa67ac922ff4453addee
MD5 7ad86ddfee351fbb9fe344abaa25a3e3
BLAKE2b-256 156a8e0b2c2420286389e7fed78ff361ec30e2f1d58c8560af8d64df5e7b61e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinxcontrib_bibtex-2.7.0.tar.gz:

Publisher: release.yml on mcmtroffaes/sphinxcontrib-bibtex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinxcontrib_bibtex-2.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinxcontrib_bibtex-2.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28cf0ec7a957d1c7548d5749317ed472ce877e1b629f430f88e3789aa51f87b1
MD5 6dd5b19aedea221c0423e91ddafcc627
BLAKE2b-256 52c0d28e62407f4733bbe0169287bc012f0ac3b4a2021066b285570654119c8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinxcontrib_bibtex-2.7.0-py3-none-any.whl:

Publisher: release.yml on mcmtroffaes/sphinxcontrib-bibtex

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page