I was recently tasked with extracting information and consolidating a large number of BibTeX files. Should be easy enough, there are perl and python modules to parse it... Well, that's what I thought. Turns out that the files I was given have all kinds of oddities. And all of the parsers I threw at it, would error out at some point or other. The files are known to be "correct" as in so far that bibtex and LaTeX don't show any errors and produce the expected output. So, it must be clearly the third-party parsers. I tried to figure out what the bibtex file syntax is supposed to be, but could only find partial and informal definitions here and there. I tried to read the bibtex source code, which, considering its age, the language it is written in (web) and being two hand written parsers, is not an easy task.

Before I start wasting time, I wanted to ask whether there is somewhere a formal definition of the bibtex file? Or, if not, whether there is an easier place where I can extract it from, than the 36 year old artefact that is called bibtex.web.

Edit: I looked already through the tex docs that is concerned about bibtex and also read the LaTeX Companion's chapter on bibtex. I googled for all terms I could think of, but none gave me any result.

  • I'd be curious to see the .bib entries that are successfully parsed by BibTeX but not by the third-party parsers.
    – Don Hosek
    Feb 10 at 21:03
  • Oh, that's easy to do: Just stick some random character into the citation key. E.g. : (colon) breaks a few bibtex tools. I have a file with a ton of ' (single quote) in the key. So, e.g., an entry like @misc{foo:bar'baz, title = .... } will not work on anything I have tried, but bibtex accepts it. Feb 10 at 21:16

texdoc beast should bring up Tame the Beast which is the nearest there is to an official bibtex manual and specification , section 15 "The structure of a bst file" may be what you are looking for

  • Yes, I had a look at this already. Unfortunately, section 8, which describes the .bib file, does not contain anything more than a vague prose description. Section 15 is about the .bst file, which is an entirely different structure altogether. The LaTeX Companion's chapter 13 is more thorough, but even that does not contain, for example, the list of allowed characters for identifiers. Feb 10 at 20:41
  • Oh sorry actually I read your question as being about bst rather than bib, In that case I don't know if there is a grammar anywhere but it's just a comma separate list of key={value} or key="value" items. Feb 10 at 20:58

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.