![]() |
The BibTEX engine and bibliography styles | ![]() |
TeXmacs can produce bibliographies in two ways: by running the external bibtex program on a .bst style and importing the resulting .bbl file, or by doing everything itself, with a C++ parser for .bib files, a C++ implementation of the string functions of the BibTEX language, and bibliography styles written in Scheme. The second way is used for the styles whose name starts with tm- and whenever bibtex is not installed.
The chapter the database and bibliographies describes the markup of citations and bibliographies, how the generation is triggered, how the strategy is chosen (with or without the database tool), how bibtex is run and how .bib files are edited as TeXmacs documents. The guide writing TeXmacs bibliography styles documents the Scheme functions available to style writers. The present chapter goes one level deeper and describes the engine itself: the exact grammar accepted by the parser and the trees it produces, the conversion of field values and person names, the semantics of the built-in functions and how they differ from those of BibTEX, the style dispatch, the shipped styles, and the known problems.
Paths of C++ files are relative to
src/src/
, paths of Scheme files to
src/TeXmacs/progs/
.
Without the database tool, edit_process_rep::generate_bibliography (
Edit/Process/edit_process.cpp
) follows one of three paths:
style tm-xxx, or no bibtex program other style
| |
.bib + texmacs.bib bibtex_run
| parse_bib | temp.aux, bibtex
(document (bib-entry …) …) temp.bbl
| bib_entries (cited keys) | bibtex_load_bbl
| bib-process (Scheme style) |
+----------> (bib-list n (document (concat (bibitem* ..) ..) ..))
no .bib file, but a .bbl file: bibtex_load_bbl only |
With the database tool, the Scheme function bib-compile replaces both branches; for the internal styles it ends in the same bib-process. In all cases the result is a bib-list which replaces the body of the bibliography tag.
The engine has three layers:
parse_bib turns the text of a .bib file into a TeXmacs tree of bib-entry tags, expands @string abbreviations, converts all field values from LaTeX to TeXmacs, splits person names into first, von, last and jr parts and normalizes page ranges. serialize-bibtex goes the other way. See parsing and serializing .bib files.
TeXmacs analogues of the BibTEX built-in functions purify$, text.length$, text.prefix$, change.case$, add.period$ and of the abbreviation of first names, working on trees instead of strings. See the built-in functions.
The style engine of
bibtex/bib-utils.scm
and the shipped styles, which override each other through Scheme modes. See the style engine and the shipped styles.
Plugins/Bibtex/bibtex.cpp,
bibtex.hpp
The interface to the external program: set_bibtex_command, bibtex_present, bibtex_run, bibtex_load_bbl.
Plugins/Bibtex/bibtex_functions.cpp,
bibtex_functions.hpp
The built-in functions, the splitting of names, the conversion of field values (bib_parse_fields), the @string dictionary and the selection of cited entries (bib_entries).
Data/Convert/BibTeX/parsebib.cpp
The parser parse_bib.
Data/Convert/BibTeX/conservative_bib.cpp
Conservative import and export, see the database chapter.
Edit/Process/edit_process.cpp
generate_bibliography and its helpers find_bib_file, copy_bst_file, arrange_bib.
Scheme/Glue/build-glue-basic.scm
The glue: set-bibtex-command, supports-bibtex?, bibtex-run, parse-bib, conservative-bib-import, conservative-bib-export and the bib-… built-ins.
bibtex/bib-utils.scm
The style engine (bib-process, bib-define-style, the output helpers).
bibtex/plain.scmand the other files of bibtex/
The shipped styles plain, abbrv, abstract, acm, alpha, elsart-num, ieeetr, siam and unsrt.
bibtex/bib-complete.scm,
bibtex/bib-widgets.scm
Completion of citation keys and the dialog which inserts or modifies a bibliography.
convert/bibtex/
The registration of the bibtex and tmbib formats and converters (
init-bibtex.scm
), and the serializer
bibtexout.scm
.
src/TeXmacs/misc/bib/texmacs.bib
Entries with keys TeXmacs:…, appended to every bibliography so that documents may cite the TeXmacs papers without a .bib file.