8

In my references, there is a problem with the doi. When using \usepackage{doi} I get hyperlinks, which is what I want. In combination with \usepackage{apacite} however, I then have to suppress the doi prefix with \renewcommand{\doiprefix}{} (otherwise "doi:" would get displayed two times). This combination of commands results in too many white spaces in front of the doi in the references section, e.g.:

Too many white spaces in front of the doi

Here is a MWE:

\documentclass[11pt, oneside, a4paper]{book}
\usepackage[ngerman]{babel}
\usepackage[tocbib, natbibapa, nosectionbib]{apacite}
\renewcommand{\doiprefix}{}
\usepackage{doi}
\usepackage{hyperref}
\hypersetup{colorlinks, citecolor=black, filecolor=black, linkcolor=black, urlcolor=blue}

\begin{filecontents}{test.bib}
@article{A,
   author = {Ackerman, P. L. and Beier, M. E. and Boyle, M. O.},
   title = {Working memory and intelligence: The same or different constructs?},
   journal = {Psychological Bulletin},
   volume = {131},
   pages = {30-60},
   DOI = {10.1037/0033-2909.131.1.30},
   year = {2005}
   }
\end{filecontents}

\begin{document}
\citet{A}.
\bibliographystyle{apacite}
\renewcommand\bibname{References}
\bibliography{test} 

\end{document}

Does anybody know how to remove one white space in front of the doi? Or does anybody know how to turn the doi's into hyperlinks without using the doi package?

5
  • 3
    If you look in the bbl file, you'll notice \begin{APACrefDOI} \doi{10.1037/0033-2909.131.1.30}. See the space, between \begin{APACrefDOI} and \doi? Define \renewcommand\doiprefix{\ignorespaces} and you will get rid of this extra space. Feb 18, 2016 at 14:51
  • 1
    Alternativelty, you can keep \doiprefix and set \renewcommand\doitext{} (which is the text you get from the doi package). Feb 18, 2016 at 14:59
  • @HenriMenke that works perfectly, thank you very much.
    – piptoma
    Feb 18, 2016 at 15:18
  • @HenriMenke would you like to write your comment up as an answer
    – Dai Bowen
    Sep 10, 2016 at 16:42
  • @DaiBowen Considering that all code written by HenriMenke is released in the public domain, I think you can move on and write that comment as an answer, especially since he didn't answered your message. The license reads: ` You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.`. It is kind of you to ask, though.
    – Clément
    Jan 13, 2017 at 20:50

1 Answer 1

2

From the comments of Henri Menke:

If you look in the .bbl file, you'll notice

\begin{APACrefDOI} \doi{10.1037/0033-2909.131.1.30} \end{APACrefDOI}

See the space, between \begin{APACrefDOI} and \doi? Define

\renewcommand\doiprefix{\ignorespaces}

and you will get rid of this extra space.

Alternativelty, you can keep \doiprefix and set \renewcommand\doitext{} (which is the text you get from the doi package).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .