5

Background:

Something I did recently has caused me to get loads of "missing { inserted" errors when I compile after running biber, as pdflatex typesets the bibliography. It's not as many as one per entry, on even one per page of output. The line for the error given on the command line is always the one following the \printbibliography, and the output is fine if I hit enter after each error.

Question:

(I mean this in the general case, if I produce an MWE by stripping down and building up I'll post something more specific)

How does one go about finding where in a .bib file an error occurs, if that error is given by pdflatex and not biber? In my case biber is happy, no errors, or warnings, and every file in my project has a matched number of {s and }s

Chris H
  • 8,705
  • That error can occur in tables especially, but that may not be the case here. I'd do two things first: (1) try commenting out the \printbibliography line and see if the error disappears; (2) construct a minimal document that just includes that .bib file and a \nocite{*} and see if that document produces the same error. At that point you should hopefully be able to tell if there is some subtle mistake in your .bib file or not. – jon May 13 '14 at 14:07
  • @Jon, (1) yes it does, (2), no it doesn't. So possibly something conflicting somewhere, which is why I thought isolating the problem entries would be a good place to start. – Chris H May 13 '14 at 14:09
  • If the error doesn't appear in the \nocite document, then I don't see how it can be related to the .bib file itself: a faulty .bib file should produce the same error in two different files. I'd look at the things around \printbibliography more carefully, including any optional arguments you are giving it. Compiling with the option -file-line-error and adding in the preamble a \errorcontextlines=3 (or 2, etc.) might help. Nothing beats the MWE for getting others to help directly, of course. – jon May 13 '14 at 14:17
  • @Jon, I know - that's why it's odd. I was using file-line-error to no benefit but \errorcontextlines looks to help - I now know it's something to do with \MakeLowerCase and maths mode (in titles). – Chris H May 13 '14 at 14:23
  • Sounds like a good trick. – jon May 13 '14 at 14:26

1 Answers1

4

Debugging tricks in answer to the question within my question:

  1. Commenting out the \printbibliography is a quick check that the error is actually caused by the bibliography not the surrounding code.
  2. Adding \errorcontextlines=3 (or similar) to the preamble shows what was happening at the time of the error, and in the cases of biblatex means the actual problem is shown.
  3. A previous answer (for bibtex) suggested creating an empty document with \nocite{*} in it (essentially an MWE). This has to be used with care, especially with biblatex, where some of the more complex code may or may not be run depending on the biblatex-related parts of the preamble. If taken too literally, this will indicate that your .bib file is fine.
  4. Adding \AtEveryBibitem{\clearpage} causes each bibliography entry to be printed on its own page. The page number in the .log file where the error occurs then uniquely identifies an entry. However what actually happens is that the reference number (for numbered styles) is printed, then the \clearpage is issued, then the bibliographic data is output. The page number in the .log (and at the commandline) refers to the page on which the reference number appears; the offending key is on the next page.

In response more to the background to my question, the underlying issue is maths mode in titles of articles etc. In my case it's Al$_x$Ga$_{1-x}N and similar. If this is in the .bib file in the format: {Al}{$_{x}}${Ga}{$_{1-x}$}{N} it's typeset correctly but I still get an error -- I've asked about this in a question of its own.

Chris H
  • 8,705
  • The main debugging points in the comments are above, feel free to add to them. I'll update with a link to my more specific question soon. – Chris H May 13 '14 at 15:13
  • You seem to have a typo in your \AtEveryBibitem call. (It should be lower case i in item) – HansHarhoff Jul 07 '15 at 18:01