In my bibtex, there are url links for DOIs with underscores which are causing compilation errors.

Here is the bibtex:

    author = {Author},
    title = {Title},
    doi = {https://doi.org/10.1007/978-3-030-25543-5_1}

And here is my error:

! Missing $ inserted.
<inserted text>
l.72 ...tps://doi.org/10.1007/978-3-030-25543-5_1}
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

My solutions that haven't worked:

  1. changing the doi from a url to just the number
  2. inclulding \url{} and \usepackage{url}
  3. Changing the '_' to '\ _'

Does anyone have any other ideas I could try?

Edit: Bib set up


content here


  • What about trying to use \ just before the _ so that it reads foo\_bar? – oliversm Jun 19 at 14:42
  • How the doi field is handled and typeset will depend on the bibliography style you use (and possibly on additional packages you load in the preamble). It would help us enormously if you could add a full example document to your question where you show us your bibliography setup. – moewe Jun 19 at 14:43
  • Most bibliography styles I know would probably prefer doi = {10.1007/978-3-030-25543-5_1} over doi = {https://doi.org/10.1007/978-3-030-25543-5_1} but the exact implementation is up to the style. Most styles that I know at least have the possibility to use the url/hyperref package. In that case it would be counter-productive to escape _ as \_ (even though it may work). – moewe Jun 19 at 14:44
  • @moewe and @oliversm , I did try using \_ and it didn't work. I updated the example to try to make it more understandable. My apologies, I am still new with stackexchange. – AndyH Jun 19 at 14:50
  • Is splnce04 a typo for splncs04? If not, where can we get hold of that file? (I downloaded the class from springer.com/gp/computer-science/lncs/…) – moewe Jun 19 at 15:01

The llncs class defines a very rudimentary \doi command that cannot deal with special characters.

We can define our own slightly more robust version of \doi by going back to url's \url command. Since llncs defines its \doi in \AtBeginDocument we have to do that as well. The proposed solution requires \usepackage{url} or \usepackage{hyperref} (it will work fine with either package).




  author = {Author},
  title  = {Title},
  doi    = {10.1007/978-3-030-25543-5_1},

content here \cite{LVR19}


1. Author: Title. https://doi.org/10.1007/978-3-030-25543-5_1

| improve this answer | |
  • this gives me an error of ! TeX capacity exceeded, sorry [input stack size=5000]. \@makeother #1->\catcode #1 12\relax l.72 ...ps://doi.org/10.1007/978-3-030-25543-5_1}}` – AndyH Jun 19 at 15:33
  • @AndyH The minimal working example I posted in the answer produces no such error. Please try and reproduce the error in minimal working example you can share. – moewe Jun 19 at 15:37
  • Also make sure your doi field contains only the doi and not a \url or \doi command. To be sure delete your .bbl and .aux files before you recompile with LaTeX, BibTeX, LaTeX, LaTeX. – moewe Jun 19 at 15:39
  • Deleting the .bbl and the .aux and recompiling worked. Thank you. – AndyH Jun 19 at 15:46

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.