[Tex/LaTex] Citation with DOI that has underscore breaks functionality in BibDesk

bibdeskbibliographiesbibtexdoi

One functionality of BibDesk that is nice is the ability to click on a link at the end of the Doi entry field, which will open up the link http://dx.doi.org/DOI-HERE in a browser.

enter image description here

One problem I've just run into with bibliography styles that display DOIs in the References section (e.g., unified) is that a Doi entry that contains an underscore will be printed as a subscript in the References section.

For example, this code:

\documentclass{article}

\usepackage{natbib}

\begin{document}

\citet{chomsky1977b}
\citet{chomsky1977b-test}

\bibliographystyle{unified}
\bibliography{master}

\end{document}

produces this output

enter image description here

where chomsky1977b is

@article{chomsky1977b,
    Author = {Chomsky, Noam and Lasnik, Howard},
    Doi = {10.1007/978-94-015-6859-3_4},
    Journal = {Linguistic Inquiry},
    Keywords = {control theory, syntax},
    Number = {3},
    Pages = {425-504},
    Title = {Filters and Control},
    Volume = {8},
    Year = {1977}}

and chomsky1997b-test is

@article{chomsky1977b-test,
    Author = {Chomsky, Noam and Lasnik, Howard},
    Doi = {10.1007/978-94-015-6859-3{\_}4},
    Journal = {Linguistic Inquiry},
    Keywords = {control theory, syntax},
    Number = {3},
    Pages = {425-504},
    Title = {Filters and Control},
    Volume = {8},
    Year = {1977}}

Of course, the Doi entry in chomsky1997b-test breaks the BibDesk functionality of opening the link in a browser, as it opens http://dx.doi.org/10.1007/978-94-015-6859-3{\_}4 rather than http://dx.doi.org/10.1007/978-94-015-6859-3_4.

Is there a way to retain this functionality yet still ensure that the DOI is printed correctly in the References section when using a style that prints the DOI?

Best Answer

For your particular example (of the unified.bst) style, it suffices to add the following line to your preamble (and load the hyperref package)

\newcommand{\doi}[1]{\textsc{doi}: \href{http://dx.doi.org/#1}{\nolinkurl{#1}}}

The MWE

\documentclass{article}

\usepackage{natbib}
\usepackage{hyperref}

\begin{filecontents}{\jobname.bib}
@article{chomsky1977b,
    Author = {Chomsky, Noam and Lasnik, Howard},
    Doi = {10.1007/978-94-015-6859-3_4},
    Journal = {Linguistic Inquiry},
    Keywords = {control theory, syntax},
    Number = {3},
    Pages = {425-504},
    Title = {Filters and Control},
    Volume = {8},
    Year = {1977}}
\end{filecontents}

\newcommand{\doi}[1]{\textsc{doi}: \href{http://dx.doi.org/#1}{\nolinkurl{#1}}}

\begin{document}

\citet{chomsky1977b}

\bibliographystyle{unified}
\bibliography{\jobname}

\end{document}

then yields enter image description here

Related Question