8

I prepared my article with elsarticle, using \citep & \citet throughout. I originally used apalike bibliographystyle but now need to change it to elsarticle-num-names for citation formatting requirements (see point #2 below).

Now, I am attempting to make 2 changes:

  1. add DOIs to the bibliography
  2. change reference style to [1] for \citep and Author et al. [1] for \citet.

I want to keep hyperref and do not want explicit URLs (only DOIs) but cannot make this work!

Thank you for any help you might have!

MWE:

\documentclass[preprint,12pt]{elsarticle}
%\usepackage{hyperref}

\journal{Test Journal}
\begin{document}
\begin{frontmatter}
\title{The Title}
\author{Prof. Big Ol' Wanker}
\address{123 Happy Lane}
\begin{abstract}
TEXT
\end{abstract}
\begin{keyword}
keyword 1 \sep keyword 2 \sep keyword 3
\end{keyword}
\end{frontmatter}

\section{SECTION1TEST}
\noindent cite: \cite{Richards1931} \\
citep: \citep{Richards1931} \\
citet: \citet{Richards1931} \\

\bibliography{library}
\bibliographystyle{elsarticle-num-names}

\end{document}

Here is the reference for Richards1931 from my library.bib file:

@article{Richards1931,
author = {Richards, LA},
doi = {10.1063/1.1745010},
file = {:D$\backslash$:/Papers/Richards - 1931 - Capillary Conduction of Liquids Through Porous Mediums - Journal of Applied Physics.pdf:pdf},
issn = {01486349},
journal = {Journal of Applied Physics},
pages = {318},
title = {{Capillary Conduction of Liquids Through Porous Mediums}},
url = {http://scitation.aip.org/content/aip/journal/jap/1/5/10.1063/1.1745010},
volume = {1},
year = {1931}
}

without hyperref (wanted hyperlinks present, DOI displays correctly, but unwanted URL is present):

without hyperref

with hyperref (hyperlinks not present, DOI displays incorrectly, and unwanted URL is present):

with hyperref

6
  • Welcome to TeX.SE. The write-up of your document setup is a bit confusing: The code says you use the elsarticle-num-names bibliography style, but in the body of the posting you say you use the apalike style. Please clarify. Separately, it would be helpful if you posted the bib code for the entry Richards1931 to void spurious duplication of effort by readers who may be considering coming up with a solution.
    – Mico
    Aug 5, 2015 at 7:21
  • Thanks for the welcome. I have clarified the first sentence and added the Richards1931 entry. My bibtex file is generated automatically from my Mendeley database. Aug 5, 2015 at 10:52
  • Not tested but you can either remoave manually all url entries in your bib file or create you own myelsarticle-num-names.bst file [from math.pitt.edu/~troy/stewart/elsevierversion/… and remove all the print.url output lines. I think it would work. Otherwise, you could use biblatex but the targeted style might not be available.
    – pluton
    Aug 5, 2015 at 13:09
  • @pluton Thanks, this kind of works if I make a new .bst file with those edits... strangely, when I use the doi package instead of the hyperref package, the doi links now work, but the doi is displayed as: doi:doi:10.1063/1.1745010 Any idea how to get rid of that second doi: ? Aug 6, 2015 at 1:22
  • I am not sure why you are facing so many difficulties. If this is for a paper, why don't you leave the effort to the editor?
    – pluton
    Aug 7, 2015 at 6:52

1 Answer 1

8

This problem occurs because elsarticle does not define a \doi macro that hyperref requires.

Hyperref calls \doi{\bibinfo{doi}{XXX}} to produce the URL for the DOI in the reference XXX. If the \doi macro is not defined, the resulting output will be something like \let\@tempa\bibinfo@X@doi{XXX}

As a workaround, you can define a \doi macro that solve the problem

\documentclass{elsarticle}

\usepackage{hyperref}

\makeatletter
\providecommand{\doi}[1]{%
  \begingroup
    \let\bibinfo\@secondoftwo
    \urlstyle{rm}%
    \href{http://dx.doi.org/#1}{%
      doi:\discretionary{}{}{}%
      \nolinkurl{#1}%
    }%
  \endgroup
}
\makeatother

You must log in to answer this question.

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