Skip to content

bib.bibtexparser.bibtex_format

Classes

BibtexFormat

BibtexFormat()

Definition of formatting (alignment, ...) when writing a BibTeX file.

For more manual, GUI-based formatting, see the bibtex-tidy tool:

https://flamingtempura.github.io/bibtex-tidy/

Source code in pybibtexer/bib/bibtexparser/bibtex_format.py
def __init__(self):
    self._indent: str = "  "  # "\t"
    self._align_field_values: int | str = "auto"
    self._block_separator: str = ""  # "\n\n"
    self._trailing_comma: bool = True
    self._parsing_failed_comment: str = PARSING_FAILED_COMMENT

Attributes

block_separator property writable
block_separator

Character(s) for separating BibTeX entries.

Default: Two lines breaks, i.e., two blank lines.

indent property writable
indent

Character(s) for indenting BibTeX field-value pairs. Default: single space.

parsing_failed_comment property writable
parsing_failed_comment

Comment to use for blocks that could not be parsed.

trailing_comma property writable
trailing_comma

Use the trailing comma syntax for BibTeX entries. Default: True.

BibTeX syntax allows an optional comma at the end of the last field in an entry.

value_column property writable
value_column

Controls the alignment of field- and string-values. Default: no alignment.

This impacts String and Entry blocks.

An integer value x specifies that spaces should be added before the " = ", such that, if possible, the value is written at column len(self.indent) + x. Note that for long keys, the value may be written at a later column.

Thus, a value of 0 means that the value is written directly after the " = ".

The special value "auto" specifies that the bibtex field value should be aligned based on the longest key in the library.