[Tex/LaTex] doi hyperlinks show up as “doi:doi” in the references

apacitebibtexdoihyperrefnatbib

I am using apacite, natbib and hyperref to reference my article in APA style on TexWorks using BibTex. I would like for the DOIs in my bibliography to link to their DOI URLs.

Using the package doi converts them to links, but every link in my bibliography now shows up as, e.g.

Author. (year). Title.Journal. Vol (Issue).pages. doi:
doi
:10.2214/ajr.12.9928

The entry in my .bib file contains

doi = {10.2214/ajr.12.9928},

How do I remove the extra 'doi:'?

Best Answer

There are several ways to deal with this.

  1. Tell the doi package to drop its "doi:" prefix, which is saved in \doitext.

    \documentclass[british]{article}
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
    \usepackage{babel}
    \usepackage[natbibapa]{apacite}
    \usepackage{hyperref}
    
    \usepackage{doi}
    \renewcommand{\doitext}{}
    
    \usepackage{filecontents}
    \begin{filecontents}{\jobname.bib}
    @article{appleby,
      author  = {Humphrey Appleby},
      title   = {On the Importance of the Civil Service},
      year    = {1980},
      journal = {Civil Service Journal},
      doi     = {10.2214/ajr.12.9928__##},
    }
    \end{filecontents}
    
    \begin{document}
    \cite{appleby}
    \bibliographystyle{apacite}
    \bibliography{\jobname}
    \end{document}
    

    Appleby, H. (1980). On the importance of the civil service. Civil Service Journal. doi:10.2214/ajr.12.9928__##

  2. Tell apacite to drop its "doi:" prefix, which is saved in \doiprefix.

    \documentclass[british]{article}
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
    \usepackage{babel}
    \usepackage[natbibapa]{apacite}
    \usepackage{hyperref}
    
    \usepackage{doi}
    
    \renewcommand{\doiprefix}{}
    
    \usepackage{filecontents}
    \begin{filecontents}{\jobname.bib}
    @article{appleby,
      author  = {Humphrey Appleby},
      title   = {On the Importance of the Civil Service},
      year    = {1980},
      journal = {Civil Service Journal},
      doi     = {10.2214/ajr.12.9928__##},
    }
    \end{filecontents}
    
    \begin{document}
    \cite{appleby}
    \bibliographystyle{apacite}
    \bibliography{\jobname}
    \end{document}
    

    Appleby, H. (1980). On the importance of the civil service. Civil Service Journal. doi:10.2214/ajr.12.9928__##

  3. Build your own \doi command without prefix and don't load the doi package. Since you are loading hyperref I recommend to follow the slightly more complicated approach by Michael Ummels in Getting those %#!^& signs in the footnote!. That will allow you to use 'dangerous' characters in the DOI without having to worry about most of them (as opposed to the more straightforward \newcommand{\doi}[1]{\href{https://doi.org/#1}{#1}}, which would break if the DOI contained # or %.).

    \documentclass[british]{article}
    \usepackage[T1]{fontenc}
    \usepackage[utf8]{inputenc}
    \usepackage{babel}
    \usepackage[natbibapa]{apacite}
    \usepackage{hyperref}
    
    \newcommand*{\doi}{}
    \makeatletter
    \newcommand{\doi@}[1]{\href{https://doi.org/#1}{#1}}
    \DeclareRobustCommand{\doi}{\hyper@normalise\doi@}
    \makeatother
    
    \usepackage{filecontents}
    \begin{filecontents}{\jobname.bib}
    @article{appleby,
      author  = {Humphrey Appleby},
      title   = {On the Importance of the Civil Service},
      year    = {1980},
      journal = {Civil Service Journal},
      doi     = {10.2214/ajr.12.9928__##},
    }
    \end{filecontents}
    
    \begin{document}
    \cite{appleby}
    \bibliographystyle{apacite}
    \bibliography{\jobname}
    \end{document}
    

    Appleby, H. (1980). On the importance of the civil service. Civil Service Journal. doi:10.2214/ajr.12.9928__##

Related Question