TransWikia.com

Citation with DOI that has underscore breaks functionality in BibDesk

TeX - LaTeX Asked by Adam Liter on February 27, 2021

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?

4 Answers

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

Correct answer by moewe on February 27, 2021

If you look at your .bst, i.e. the BibTeX style file, there should be a function formating the DOI output.

There you could use hreffrom the hyperref package and detokenize as mentioned here or here, you can do something like

FUNCTION {format.doilink}
{ duplicate$ empty$
{ pop$ "" }
{ doi empty$
    { skip$ }
    { "{, doi:~href{http://dx.doi.org/" * doi * "}{detokenize{" * doi * "}}}" * }
  if$
}
if$
}

which is based on the naming used in style files of the elsevier BibTeX files, so your function in the .bst file might differ in naming. The function above pouts a “doi:” in front, as your example suggests. So you could just search your style file for that and change the output after that.

Answered by Ronny on February 27, 2021

There is a nice solution to similar issue by Roly in Missing $ inserted issue, who recommends to use usepackage[strings]{underscore}.

The package arranges that, while in text, ‘_’ itself behaves as textunderscore (the behaviour of _ in maths mode is not affected).

Answered by Peter Mukhachev on February 27, 2021

Just use the doi package. It provides a doi command that handles all sorts of nasty characters.

Answered by gi1242 on February 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP