Command line interface¶
The pybtex executable is used in the same was as the original bibtex command and accepts the same command line options. The only difference is that you type pybtex instead of bibtex.
For example, to compile the bibliography for a LaTeX file named
book.tex, you need to type:
$ latex book $ pybtex book $ latex book $ latex book # to get cross-references right
See the BibTeX tutorial by Andrew Roberts for a basic explanation of how to use BibTeX.
Pybtex is fully compatible with BibTeX’
Besides that, Pybtex supports other bibliography formats.
The list of supported formats can bee seen in the output of pybtex --help.
By default, the BibTeX format is used. If a LaTeX file
Then this command:
$ pybtex book
will expect to find the bibliography data in a BibTeX-formatted file
Pybtex can be instructed to use a different format with the
For example this command:
$ pybtex --format yaml book
will tell Pybtex to look for a YAML-formatted file
mybook.yaml instead of
Support for additional bibliography formats can be added by plugins.
BibTeX has a built-in stack oriented programming language for defining
bibliography formatting styles. This language is used in
style files. Pybtex is fully compatible with BIbTeX’
.bst style files.
Additionally, Pybtex allows
to write bibliography styles in Python.
Some base BibTeX styles, including
unsrt, have been
already ported to Python. They can be found in
pybtex/style/formatting subdirectory. Additional
styles can be added as plugins.
By default, Pybtex uses BibTeX’
.bst styles. You can switch the style
language from BibTeX to Python with the
$ pybtex --style-language python book
One of the advantage of using Pythonic styles is that they can produce HTML,
Markdown or plain text output besides the usual LaTeX markup.
To change the output backend from LaTeX to something else,
$ pybtex --style-language python --output-backend html book $ pybtex --style-language python --output-backend plaintext book
(In this case Pybtex will write the bibliography to
book.txt instead of
Support for other markup formats can be added by plugins.
Additionally, Pythonic styles are configurable with command line options to
some extent. For example, the
--name-style option tells Pybtex to
use a different name formatting style,
Pybtex to use the abbreviated name format, etc. See pybtex --help
for more options.
Pybtex comes with an additional utility called pybtex-convert. It converts bibliography databases between supported formats:
$ pybtex-convert book.bib book.yaml
Be aware that the conversion is not always lossless. For example:
BibTeX’ string macros are substituted by their values during conversion.
BibTeXML does not support LaTeX preambles.
In the standard BibTeX format, names are stored as single strings. BibTexML and Pybtex’ YAML format store first name, last name, and other name parts seprately.
Sometimes you would want to convert a bibliography database to a human-readable format. Pybtex has another utility called pybtex-format for that:
$ pybtex-format book.bib book.txt $ pybtex-format book.bib book.html
By default, the
unsrt style is used for formatting. This can be changed with the
$ pybtex-format --style alpha book.bib book.txt