79

Trying to get my dissertation 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!

3
  • 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, 2012 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.
    – 0 _
    Oct 7, 2014 at 8:44
  • I resolved the same error with _ instead of _ at the end of doi Jan 22, 2021 at 11:49

13 Answers 13

66

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.

5
  • 5
    Why should the prefix doi: be required for the DOI field? A doi number always starts with 10, not with doi:
    – koppor
    Jun 22, 2015 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. Jul 10, 2018 at 21:29
  • @6005 The error message shows clearly that it comes from the .bbl file, not by including the .bib file in LaTeX. Jul 10, 2018 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 Jul 11, 2018 at 3:10
  • @6005 Very likely this can be detected by seeing the key in the error message, e.g. l42. doi = 10.1007/978-0-387-68772-8_. Jul 11, 2018 at 5:55
75

\usepackage[strings]{underscore}

11
  • 18
    This should be the accepted answer; this completely solves the problem, whereas the currently-accepted answer merely explains the problem.
    – Tom Church
    Jul 26, 2016 at 21:15
  • 5
    It did not work for me :(
    – durbachit
    May 18, 2017 at 2:57
  • 2
    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, 2018 at 6:51
  • 3
    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, 2019 at 12:50
  • 1
    This conflicts with some packages like pstricks, but works well if included in the end of preamble.
    – Fractalic
    Sep 2, 2019 at 9:39
24

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.

1
  • 6
    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, 2015 at 21:43
16

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

3
  • 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, 2016 at 9:44
  • 1
    Didn't work for me...
    – Roly
    Jun 20, 2016 at 9:46
  • 2
    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!). Jun 24, 2017 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.

1
  • Which underscore?
    – Jon
    Sep 12, 2012 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

1
  • Why is this better than replacing _ with \_?
    – lucidbrot
    Nov 28, 2018 at 9:11
1

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

1

The short way:

  1. open "*.bib" file
  2. Replace:

         "-" >>>> "\_"
         "&" >>>> "\&" (specially check in the links)
         "\" >>>> "\\" (specially check in the links)
    
  3. Delete all temporary files: In Texmaker:

         Tools -> Clean
         Bibliography -> Clean
    
  4. You are done! Very Important Note: You do not need any extra package, so do not use them, in order to prevent further problems.
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

In my case there was a problem with the encoding. I used \usepackage[macintosh]{inputenc}.

I solved the problem by switching to \usepackage[utf8]{inputenc} but i also had to update the encoding of my files by using iconv.

0

If you are handling complex tex when using new packages might incur even more problems, I find a simple solution by replacing the underscore in the bib files' DOI link with \textunderscore, like this:

doi = {10.1007/978-3-319-45738-3\textunderscore9}

It should solve your issue in a second.

1
  • 2
    Does the hyperlink work with this approach? If not, the other solutions would be better.
    – dexteritas
    Mar 31 at 13:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .