16

I am trying to adjust the bibliography style of natbib. There I am facing constructs like these:

FUNCTION {emphasize}
{ duplicate$ empty$
    { pop$ "" }
    { "\emph{" swap$ * "}" * }
  if$
}

Which language is it? I'd like to read about it to better understand it. Is there a manual? I found some documents, but none of them covered the concept in detail like the TeXbook does for TeX concepts.

  • 8
    The language has no name and, as far as I know, it's used only for programming bst files. – egreg Feb 1 '14 at 19:13
  • 2
  • Okay; what would you suggest to better understand it? Is there any chance? I am trying to translate some parts to fit German citation styles (like "und" instead of "and", "Auflage" instead of edition" etc.). Is there an easier way? – Xiphias Feb 1 '14 at 19:14
  • 3
    texdoc tamethebeast is your friend. Here you can find it online. – egreg Feb 1 '14 at 19:16
  • 5
    It has no name, but it's Reverse Polish Notation, also used for decades with HP's awesome calculators. IIRC PostScript uses the same notation. – Uwe Ziegenhagen Feb 1 '14 at 19:23
18

The BibTeX author mentions:

Here's how BibTeX works. It takes as input

  1. an .aux file produced by LaTeX on an earlier run;
  2. a .bst file (the style file), which specifies the general reference-list style and specifies how to format individual entries, and which is written by a style designer (called a wizard throughout this program) in a special-purpose language described in the BibTeX documentation - see the file btxdoc.tex; and
  3. .bib file(s) constituting a database of all reference-list entries the user might ever hope to use.

A "special-purpose language", as described in Designing BibTeX Styles, is a form of "postfix stack language":

Basically the style file is a program, written in an unnamed language, that tells BibTeX how to format the entries that will go in the reference list [..]. This programming language has ten commands [..]. These commands manipulate the language's objects: constants, variables, functions, the stack, and the entry list. (Warning: The terminology [..] chosen for ease of explanation, is slightly different from BibTeX's. For example [..] "variables" and "functions" are both "functions" to BibTeX. [..])

There are two types of functions: built-in ones that BibTeX provides [..] and ones you define using either the MACRO or FUNCTION command.

Your most time-consuming task, as a style designer, will be creating or modifying functions using the FUNCTION command [..].

Another interesting, related read would be Taming the BeaST, which attempts to provide the "B to X of BibTeX" - as complete a reference as possible.

bibtex itself is written in Web (similar to TeX). While we know it as an executable file, the original bibtex.web source is tangled into PASCAL code, and then compiled into a binary executable.

2

You can make your own BibTeX .bst files by running

latex makebst

which uses merlin.mbs, see here, to generate a .dbj (available here). LaTeX then compiles the .dbj file into a .bst. With this method, the command prompt will ask you a long list of questions to create the custom .bst.

An alternative is to generate .bst files by commenting/uncommenting the appropriate lines in a pre-existing .dbj file, e.g. from here, and then compile it using e.g.

latex imsi.dbj

Some example .bst files are also available on this github repo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.