4

I am using the apacite and hyperref packages and the apacite bibliography style to create the formatted bibliographic entries for my document 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:'?

Mico
  • 506,678
apsara
  • 41
  • 1
  • 2

2 Answers2

5

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__##

moewe
  • 175,683
  • @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 – Euclides Nov 10 '21 at 17:02
  • 1
    @Euclides Try \newcommand{\doi@}[1]{\url{https://doi.org/#1}} instead of \newcommand{\doi@}[1]{\href{https://doi.org/#1}{#1}} in the third code example. – moewe Nov 10 '21 at 19:45
1

For APA 7th DOI style: https://doi.org/10.2214/ajr.12.9928__## (all as a link) as asked by @euclides you need to suppress the doi text. So combining @moewe's answers:

\newcommand*{\doi}{}
\renewcommand{\doiprefix}{}
\makeatletter
\newcommand{\doi@}[1]{\urlstyle{same}\url{https://doi.org/#1}}
\DeclareRobustCommand{\doi}{\hyper@normalise\doi@}
\makeatother