2

Using BibLaTeX (not BibTeX), I want to put a link over the entire reference and not the parts separately. In addition, I want to remove the period between the date and the pages.

A minimal example is as follows:

\documentclass{article}

\usepackage[backend=biber, doi=false, hyperref=true]{biblatex}
    \bibliography{references}

\usepackage{hyperref}

\usepackage{filecontents}
\begin{filecontents}{references.bib}
@article{ref,
  author = {Surname, Initials},
  title = {Title},
  doi = {11.1111/111111},
  journal = {Journal Name},
  pages = {11},
  volume = {1},
  year = {2018}
}
\end{filecontents}

\begin{document}
Reference~\cite{ref}.
\printbibliography
\end{document}

This should give the bibliography output equivalent to

Initials Surname. "Title". In: \href{http://dx.doi.org/11.1111/111111}{Journal Name \textbf{1} (2018) 11}.

I am currently able to put the link over the journal, volume, year and date separately using

\newbibmacro{string+doi}[1]{\iffieldundef{doi}{#1}{\href{http://dx.doi.org/\thefield{doi}}{#1}}}
\DeclareFieldFormat[article]{volume}{\usebibmacro{string+doi}{\textbf{#1}}\space}
\DeclareFieldFormat[article]{journaltitle}{\usebibmacro{string+doi}{#1}}
\DeclareFieldFormat[article]{date}{\usebibmacro{string+doi}{#1}}
\DeclareFieldFormat[article]{pages}{\usebibmacro{string+doi}{#1}}

As I said, I would like it to appear over the entire reference as shown above. In addition, I haven't been successful in removing that comma between the date and page in analogy with other such cases (discussed extensively here) – probably I'm only lacking the appropriate bibmacro?

3

It is not enough to use field formats here, since those are confined to the output of one field. If you want one long hyperlink you will have to wrap several bibmacros up in the linking macro. Unfortunately, this has to be done on the bibliography driver level since the journal+issuetitle macro does not inlcude the page number. In the MWE below we use xpatch to modify the driver.

\documentclass{article}

\usepackage[backend=biber, doi=false, hyperref=true]{biblatex}
\addbibresource{biblatex-examples.bib}

\usepackage{hyperref}

\DeclareFieldFormat{doilink}{\iffieldundef{doi}{#1}{\href{http://dx.doi.org/\thefield{doi}}{#1}}}
\DeclareFieldFormat[article,periodical]{volume}{\mkbibbold{#1}}
\DeclareFieldFormat[article,periodical]{journaltitle}{#1}
\DeclareFieldFormat[article,periodical]{pages}{#1}

\usepackage{xpatch}
\xpatchbibdriver{article}
  {\usebibmacro{journal+issuetitle}%
   \newunit
   \usebibmacro{byeditor+others}%
   \newunit
   \usebibmacro{note+pages}}
  {\printtext[doilink]{%
     \usebibmacro{journal+issuetitle}%
     \newunit
     \usebibmacro{byeditor+others}%
     \newunit
     \usebibmacro{note+pages}}}
  {}{}

\begin{document}
Reference~\cite{sigfridsson}.
\printbibliography
\end{document}

enter image description here

|improve this answer|||||
  • Putting a \nopunct at the right place in addition gets rid of the punctuation before the pages. So, problem solved. Thanks! – Cari Baur Apr 11 '18 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.