[Tex/LaTex] biblatex: how to make \fullcite a clickable link

biblatexhyperref

I am using biblatex to cite articles with full reference in the text, and therefore have no references section.

The biblatex setup that I use is the following

\documentclass{article}
\usepackage{filecontents}

\begin{filecontents}{bibliography.bib}
    @article{reference,
    author = {F Author and S Author}, 
    journal = {Obsc. J.},
    title = {Article Title},
    pages = {13},
    volume = {400},
    year = {2013},
    month = {Oct},
    doi = {10.1111/123},
    URL = {http://dx.doi.org/10.1111/123}}
\end{filecontents}

\usepackage[maxnames=1,backend=bibtex,doi=false,isbn=false,url=false,firstinits=true,uniquename=false,useprefix=true]{biblatex}
\addbibresource{bibliography.bib}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}
\DeclareFieldFormat[article]{year}{\mkbibparens{#1}}
\DeclareFieldFormat{journaltitle}{\mkbibemph{#1}} % italic journal title 
\DeclareFieldFormat{pages}{#1}
\renewbibmacro{in:}{} % remove "in:"
\renewcommand{\newunitpunct}{, }
\renewcommand{\newblockpunct}{, }
% remove first name
\DeclareNameFormat{first-last}{\usebibmacro{name:last}{#1}{#3}{#5}{#7}\usebibmacro{name:andothers}}
\AtEveryCitekey{\clearfield{title}} % remove title


\begin{document}
Cite the article \fullcite{reference}.
\end{document}

This way, a reference cited with \fullcite gives something like "Author et al., Obsc. J. 400 (2013), 13".

So far so good, but now I would like to make the citation (or at least the first author if thats easier) a hyperlink leading to the URL of the article (each article entry in the bib-file has a URL entry and/or a DOI). Is there a way to do this?

Edit: something similar is used in the reference section of some Journals, see e.g. this open access article.

Best Answer

Instead of redefining each and every field format you might like this more general approach to redefine the \fullcite command.

\DeclareCiteCommand{\fullcite}
  {\usebibmacro{prenote}}
  {\iffieldundef{doi}
    {\iffieldundef{url}
      {\usedriver
       {\DeclareNameAlias{sortname}{default}}
       {\thefield{entrytype}}}
      {\href{\thefield{url}}
        {\usedriver
          {\DeclareNameAlias{sortname}{default}}
          {\thefield{entrytype}}}}}
    {\href{http://dx.doi.org/\thefield{doi}}{\usedriver
     {\DeclareNameAlias{sortname}{default}}
     {\thefield{entrytype}}}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

This will link the full citation as printed by the bibdriver to the DOI-URL or URL (in that order of precedence).

The MWE

\documentclass{article}
\usepackage{filecontents}

\begin{filecontents}{bibliography.bib}
@article{reference,
  author = {F Author and S Author}, 
  journal = {Obsc. J.},
  title = {Article Title},
  pages = {13},
  volume = {400},
  year = {2013},
  month = {10},
  url = {http://dx.doi.org/10.1111/123},
  doi = {10.1111/123},
}
\end{filecontents}

\usepackage[maxnames=1,backend=bibtex,doi=false,isbn=false,url=false,firstinits=true,uniquename=false,useprefix=true]{biblatex}
\addbibresource{bibliography.bib}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}
\DeclareFieldFormat[article]{year}{\mkbibparens{#1}}
\DeclareFieldFormat{journaltitle}{\mkbibemph{#1}} % italic journal title 
\DeclareFieldFormat{pages}{#1}
\renewbibmacro{in:}{} % remove "in:"
\renewcommand{\newunitpunct}{\addcomma\space}
\renewcommand{\newblockpunct}{\addcomma\space}
\DeclareNameFormat{first-last}{\usebibmacro{name:last}{#1}{#3}{#5}{#7}\usebibmacro{name:andothers}}
\AtEveryCitekey{\clearfield{title}} % remove title

\DeclareCiteCommand{\fullcite}
  {\usebibmacro{prenote}}
  {\iffieldundef{doi}
    {\iffieldundef{url}
      {\usedriver
       {\DeclareNameAlias{sortname}{default}}
       {\thefield{entrytype}}}
      {\href{\thefield{url}}
        {\usedriver
          {\DeclareNameAlias{sortname}{default}}
          {\thefield{entrytype}}}}}
    {\href{http://dx.doi.org/\thefield{doi}}{\usedriver
     {\DeclareNameAlias{sortname}{default}}
     {\thefield{entrytype}}}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\usepackage{hyperref}

\begin{document}
Cite the article \fullcite{reference}.
\end{document}

yields

enter image description here

Related Question