1

My question is exactly the same as this:

Generally, URLs are not pretty nor compact. How can I embed a hyperlink to the documents URL without printing the URL in the reference catalog?

The solution given there is valid for BiBTeX. Is there a similar solution for biblatex?

MWE:

\documentclass{article}

\begin{filecontents}{\jobname.bib} @article{knuth1984, title={Literate Programming}, author={Donald E. Knuth}, journal={The Computer Journal}, volume={27}, number={2}, pages={97--111}, year={1984}, publisher={Oxford University Press}, url={https://doi.org/10.1093/comjnl/27.2.97} } \end{filecontents}

\usepackage{biblatex} \usepackage{hyperref} \usepackage{enumitem} \addbibresource{\jobname.bib}

\begin{document}

\section{Current output:} \nocite{} \printbibliography[heading=none]

\section*{Desired output:} \begin{description}[labelwidth=0.5cm, itemindent=0cm, leftmargin=!, font=\normalfont] \item[{[1]}] Donald E. Knuth, ``\href{https://doi.org/10.1093/comjnl/27.2.97}{Literate Programming}'' In: \emph{The Computer Journal} 27.2 (1984), pp. 97-111. \end{description}

\end{document}

MWE

EDITED:

As comments suggest, the solutions given to this question, or its parent question, give me one solution:

\newbibmacro{string+url}[1]{%
  \iffieldundef{url}{#1}{%
    \href{\thefield{url}}{#1}%
  }%                
}                   
\DeclareFieldFormat[article]{title}{\usebibmacro{string+url}{#1}}               
\DeclareFieldFormat[article]{url}{}    

The small problem is that if you want to respect the original formatting of the bibliography style used, you have to replicate it. With the above code, I have lost the quotation marks in the title. If I want to recover quotations marks:

\DeclareFieldFormat[article]{title}{\usebibmacro{string+url}{\mkbibquote{#1}}}               

This should be done for every entrytype, and, if you want to change the bibliography style, modify accordingly. Maybe not a big deal.

Alternatively, I have found the DeclareFieldInputHandler command. This command define a data input handler for when it is read from the .bbl. according to the biblatex manual. Therefore you can use the following code:

\DeclareFieldInputHandler{title}{\def\Newvalue{\usebibmacro{string+url}{#1}}}               
\DeclareFieldFormat[article]{url}{}    

enter image description here

I am unaware of the possible side effects of this input handler redefinition.

0 Answers0