61

Trying to get my dissertaion sorted (due in a few hours) and I keep getting this error:

! Missing $ inserted.
<inserted text> 
                $
l.190 ... pp. 225--236, 10.1007/978-0-387-68772-8_
                                                  18. [Online].
? 

Really struggling to sort it out.

I'm fairly new to LaTeX.

Edit: This is 189-204 of the bibtex

@inproceedings{davis,
 author = {Davis, Alan and Dieste, Oscar and Hickey, Ann and Juristo, Natalia and Moreno, Ana M.},
 title = {Effectiveness of Requirements Elicitation Techniques: Empirical Results Derived from a Systematic Review},
 booktitle = {Proceedings of the 14th IEEE International Requirements Engineering Conference},
 series = {RE '06},
 year = {2006},
 isbn = {0-7695-2555-5},
 pages = {176--185},
 numpages = {10},
 url = {http://dx.doi.org/10.1109/RE.2006.17},
 doi = {10.1109/RE.2006.17},
 acmid = {1174006},
 publisher = {IEEE Computer Society},
 address = {Washington, DC, USA},
 keywords = {Systematic review, software engineering, elicitation techniques, empirical studies},
} 

Please help!

  • 2
    You need to supply more information. What does your code look like around line 190 of the file? Seems like an entry in a bibliography. Edit your question and include that detail (perhaps the entire bibliography?). – Werner Sep 11 '12 at 23:58
  • 2
    The solution that avoids the error and liberates from having to change the urls is to ``` \usepackage{url} ``` as suggested here. – Ioannis Filippidis Oct 7 '14 at 8:44

10 Answers 10

51

The line number in the error message is the line of the .bbl file that is generated by bibtex, it is not the line of the .bib file. Therefore the question quotes the wrong lines. The line in the error message contains:

pp. 225--236, 10.1007/978-0-387-68772-8_18. [Online].

Therefore I think the entry in the .bib file contains

doi = {10.1007/978-0-387-68772-8_18},

It seems the DOI numbers are not well supported. The prefix doi: is missing:

doi:10.1007/978-0-387-68772-8_18

Or as URL:

http://dx.doi.org/10.1007/978-0-387-68772-8_18

Also special characters like _ are not well supported. The _ causes the trouble. Make a minimal example (MWE) that shows, how the doi entries in the .bib file are handled in your document.

If there are no special macros that handle the doi numbers, then you can try \_ instead of _ in the .bib file.

  • Cheers for the help guys, bit stressed with the deadline looming. Thanks again. – Jon Sep 12 '12 at 0:37
  • 3
    Why should the prefix doi: be required for the DOI field? A doi number always starts with 10, not with doi: – koppor Jun 22 '15 at 19:55
  • Another likely possibility that I ran into was simply attempting to use the .bib file as a .bbl. This will explain why the doi was not supported properly (underscore would have been supported in the .bib, but not in .bbl). See my answer. – 6005 Jul 10 '18 at 21:29
  • @6005 The error message shows clearly that it comes from the .bbl file, not by including the .bib file in LaTeX. – Heiko Oberdiek Jul 10 '18 at 22:49
  • @HeikoOberdiek If you rename the .bib to a .bbl, you get this error. It just happened to me. When submitting to arXiv – 6005 Jul 11 '18 at 3:10
41

\usepackage[strings]{underscore}

  • 11
    This should be the accepted answer; this completely solves the problem, whereas the currently-accepted answer merely explains the problem. – Tom Church Jul 26 '16 at 21:15
  • 3
    It did not work for me :( – durbachit May 18 '17 at 2:57
  • This didn't work for me. I'm using Overleaf and my bib file is synced from Mendeley. I keep getting a compile error whenever this is added in the preamble. – irene Aug 17 '18 at 6:51
  • 2
    The doi package doesn't seem to work with the Springer style splncs04.bst which defines its own doi command in the bibliography preamble (\providecommand{\doi}[1]{https://doi.org/#1}). Hence, I favorise the solution with the underscore package. – Mario Apr 4 at 12:50
  • 1
    This conflicts with some packages like pstricks, but works well if included in the end of preamble. – Hyperflame Sep 2 at 9:39
19

The problem is the underscore _ in a doi. It occurs in line 190 of the LaTeX file (or in the .bbl) not in the .bib file.

Search for 10.1007/978-0-387-68772-8_18 in your .bib file. You can use the url package and enclose the entry in \url{10.1007/978-0-387-68772-8_18} to avoid the error. Alternatively you can use a bibtex style that knows about dois.

  • 4
    It might also be necessary to delete and remake the .bbl file. (I'm adding that for other readers. Learned it the hard way.) – Mars Oct 8 '15 at 21:43
14

Try using in the preamble \usepackage{url}. This should clear the problem.

  • 2
    worked for me! I wonder why it got downvoted? It doesn't have any analysis or explanation of the problem, but it seems like the quickest fix. I am wary of changing my .bib file in case bibtex starts handling underscores correctly (i.e. without needing an escape character) and prints \_ into the bibliography – craq Apr 13 '16 at 9:44
  • 1
    Didn't work for me... – Roly Jun 20 '16 at 9:46
  • 1
    This only works, if the error occurs in the URL field, not if it is in any other field (which still makes it a valuable answer!). – 3244611user Jun 24 '17 at 12:18
3

Another solution could be to drop the whole "_18" as it says just "chapter 18". If you write "10.1007/978-0-387-68772-8" rather than "10.1007/978-0-387-68772-8_18" the reader will still be referred to the right book, but not to chapter 18 within it.

3

What Werner and Gonzalo said would indeed be very helpful. From the limited info given however, I guess LaTeX struggles with the _ in the line, since it normally sees that as a subscript indicator and only expects it in math mode.

A very short solution (and impossible to say if that works without taking a look at the offending code) is to escape the underscore ("_"), by placing a backslash before it.

  • Which underscore? – Jon Sep 12 '12 at 0:15
1

To get rid of the underscore ("_"), you can use shortdoi.org and doi:10/djzjd6 instead of doi:10.1007/978-0-387-68772-8_18, which is also nice when your readers need to type the doi from a printed version of your thesis instead of being able to click at it in an electronic document.

1

Another future-proof answer, albeit rather tedious, is suggested here:

Change all occurrences of _ in the URL field of your .bib file to their html character code equivalent %5F

  • Why is this better than replacing _ with \_? – lucidbrot Nov 28 '18 at 9:11
0

If you are getting this issue when submitting to arXiv, one possible source of the problem may be that you are trying to use a .bib file as a .bbl.

While renaming the .bib to .bbl is pretty silly in retrospect, that's what I did (not understanding that they are different). And then I ran into these errors. You need to submit the .bbl that is generated when you compile on your machine (or, in my case, download the .bbl file produced by ShareLaTeX online). The format of the .bbl is different from the .bib and the references will not show up correctly or be cited correctly.

0

From a similar question, the answer that worked for me was adding

\usepackage{hyperref}
\usepackage[T1]{fontenc}

to the preamble. (Or \usepackage[hidelinks]{hyperref} to avoid the ugly boxes.)

Credit to Ulrike Fischer and CGFoX

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.