2.2. BibTeX Citations

PyPI Package

https://pypi.org/project/sphinxcontrib-bibtex/

Documentation

https://sphinxcontrib-bibtex.readthedocs.org/

Git Repository

https://github.com/mcmtroffaes/sphinxcontrib-bibtex

Allowing BibTeX citations to be inserted into documentation via a .. bibliography:: directive, and a :cite: role, which work similarly to LaTeX’s \begin{thebibliography} ... \end{thebibliography} environment and \cite{cite_key} command. For formatting, the extension relies on Pybtex. It consists:

Create a citation to a bibliographic entry.

Todo

In the case of the LaTeX/PDF builder the usage of :ref:`bibliography` leads to an invalid and unresolved reference.

:cite:

For more details, see cite role.

The example
1
See :cite:`sweigart2020automate` for an practical guide in Python.
Which gives

See [Swe19] for an practical guide in Python.

For this sample you will need a corresponding bibliography for all cited references.

.. bibliography::

For more details, see bibliography directive.

The example
1
2
3
4
.. bibliography:: bibtex/example.bib
   :style: ldspalpha
   :encoding: utf-8
   :all:
Which gives

All entries are placed in the central document bibliography list, mostly on the end of the document.

Here in HTML you got this list at Bibliography.

Which needs

The example above processed the following BibTeX file content:

Listing 2.1 BibTeX example file (bibtex/example.bib)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
@book{ sweigart2020automate,
    author = { Sweigart, Al },
    title = {
        Automate the boring stuff with Python :
        practical programming for total beginners
    },
    edition = { 2. },
    publisher = { No Starch Press },
    address = { San Francisco, United States of America },
    year = { 2019 },
    language = { English },
    type = { Paperback or Hardcover) },
    isbn = { 1593279922 },
    isbn10 = { 1-59327-992-2 },
    isbn13 = { 978-1593279929 },
    oclc = { 1140126955 },
    url = { https://www.amazon.com/dp/1593279922 },
    urldate = { September 2020 },
}