![]() |
Pitfalls and known bugs | ![]() |
The general pitfalls of the bibliography pipeline (the two modes with and without the database tool, stale entries in the database) are listed in the database chapter. This page lists the problems of the engine itself. Items marked (checked) were reproduced by calling the functions from Scheme; the others come from reading the code.
(checked) Inside a value delimited by double quotes, braces are not counted (bib_within, Data/Convert/BibTeX/parsebib.cpp:83-102, the test cbegin != cend). A value such as "A {"} b" ends at the quote inside the braces; the rest of the entry, including the following fields, ends up in a bib-comment. BibTEX allows this, so files written for BibTEX may lose fields.
(checked) Inside a @string definition, a reference to an earlier abbreviation is only found if it is written in lower case: bib_strings_dict stores the names in lower case but looks them up with their original case (
Plugins/Bibtex/bibtex_functions.cpp:1045
). With @string{Foo = "X"} @string{bar = FOO # "Y"}, bar is "Y".
(checked) An unknown abbreviation is kept as its name when it is the whole value, but replaced by nothing inside a # concatenation (bib_subst_str,
bibtex_functions.cpp:1063
), without any warning.
The month abbreviations jan, …, dec, defined by the standard .bst files, are not predefined; with the internal styles month = jan prints jan.
(checked) @preamble items are parsed but dropped from the result of parse_bib (
parsebib.cpp:411
), so macros defined there are unknown when the field values are converted and are not available to the internal styles.
The conversion of field values is all or nothing: if the number of pieces produced by the LaTeX parser does not match the number of fields, bib_parse_fields (
bibtex_functions.cpp:957
) converts no field of the file, and every value of every entry stays a raw LaTeX string. One unusual value can therefore spoil the whole bibliography.
(checked) Page ranges which do not start with a digit (article numbers such as e1002--e1010, roman numerals) become (bib-pages "0") (bib_field_pages,
bibtex_functions.cpp:824
). The original value is lost, also when a modified entry is saved back to the .bib file.
(checked) bib_tree_length (
bibtex_functions.cpp:692
) adds up the lengths of the children of a concat in a local variable but then returns 0, so bib-text-length is 0 for every compound tree. The styles then use a non-breaking space where a space was intended after long compound values.
(checked) bib_get_prefix (
bibtex_functions.cpp:713
) computes the index of the body of a with but never descends into it, so bib-prefix of a formatted value is empty. It also counts bytes, so that the prefix of <Ccaron>apek of length three is the invalid string <Cc; alpha labels of authors whose last name starts with such a character are broken.
(checked) bib-upcase-first and bib-locase-first change the first character even inside keepcase (iPhone in braces becomes IPhone), unlike bib-upcase and bib-locase.
bib-add-period replaces a final comma or semicolon by a period, which BibTEX does not do. bib-purify keeps punctuation, which purify$ removes; sort keys therefore differ slightly from those of BibTEX.
bib-default-upcase-first changes no case at all; it only removes keepcase.
The command line built by bibtex_run (
Plugins/Bibtex/bibtex.cpp:192
) starts with cd $TEXMACS_HOME_PATH/system/bib; without quotes, so it fails when the home path contains spaces; the directory of the .bib file is quoted with double quotes, which does not protect it against " or $ in the name.
Any non-zero exit status of the shell command is reported as an error, with the whole log, and the warnings are then not extracted (
bibtex.cpp:202
). In both cases temp.bbl is loaded afterwards: if bibtex stopped before writing it (for instance because the style does not exist), the bibliography of the previous run is silently used.
All runs share temp.aux, temp.log and temp.bbl (
bibtex.cpp:186
), so two instances of TeXmacs generating bibliographies at the same time interfere.
copy_bst_file (
Edit/Process/edit_process.cpp:71
) only copies a .bst file from the directory of the document if no copy exists yet, so a later version of the file is not copied. Whether bibtex then uses the old copy or the new file depends on its search path (BSTINPUTS lists the directory of the .bib file first, which is not always the directory of the document).
When TeXmacs: keys are cited, complete_bib_file writes name-extended.bib in the directory of the user's .bib file (
bibtex.cpp:157
), which may be read only or under version control.
bibtex_load_bbl accesses the second argument of every bibitem* and bibitem-with-key item (
bibtex.cpp:121
) after only checking that it has at least one, so an unusual .bbl file can read past the end of the tree.
(checked) serialize-bibtex writes atomic values verbatim between braces (
convert/bibtex/bibtexout.scm:133
). 50\% caf\'e read from a .bib file is written back as 50% caf followed by the raw Cork byte of e acute: the percent sign then starts a LaTeX comment, and the accent becomes an 8-bit character. Thanks to the conservative export this only happens for new and modified entries.
bib-define-style sets the global bib-default-style to the fallback of the style being loaded (
bibtex/bib-utils.scm:83
, 87), and bib-mode? also tests this global. All shipped styles use plain as fallback, so this is harmless today, but a style with another fallback would make the overrides of that fallback active for every style once it has been loaded.
The preview of the bibliography dialog loads the module (bibtex name) for whatever style is selected (
bibtex/bib-widgets.scm:49
); for an external style such as amsplain there is no such module. The preview also formats every entry of the .bib file, which is slow for large files.
Completion of citation keys resolves the file name of the bibliography tag directly relative to the buffer (
bibtex/bib-complete.scm:47
), without the .bib suffix and ancestor directory search of find_bib_file, so it may find nothing for bibliographies which compile fine. The result is cached per buffer, and the code itself notes that a change of the file name is not noticed.