# doi hyperlinks show up as "doi:doi" in my references

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:'?

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}


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}


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}


• @moewe: I would like to follow the third approach, and redefine the doi commmand, but with the latest APA 7 doi format instead, i.e.: https://doi.org/10.2214/ajr.12.9928__##. I'm not familiar with \newcommand, \href, etc. Could you clarify how these latter commands work? You have \href{https://doi.org/... in your code, but I still do not get the desired doi format in my output file Nov 10, 2021 at 17:02