2

Consider the following MWE:

\documentclass{article}

\usepackage[isbn=false,giveninits=true,uniquename=init,style=authoryear-comp,backend=biber,sorting=ynt,natbib,maxbibnames=99,maxcitenames=3,hyperref=true,sortcites=true,language=british,doi=false,url=false,backref=true]{biblatex}

\RequirePackage[colorlinks=true,urlcolor=blue,linkcolor=black]{hyperref}

\addbibresource{References.bib}

% DOCUMENT

\begin{document}

\cite{bop_22}

\printbibliography

\end{document}

And a References.bib file with an entry like this:

@online{bop_22,
    title = {Inmate Statistics},
    author = {{Federal Boreau of Prisons}},
    year = {2022},
    url = {https://www.bop.gov/about/statistics/statistics_inmate_offenses.jsp}
}

This is the output:

enter image description here

I want the title (Inmate Statistics) to be clickable while keeping the ugly and long url totally out of sight, but I can't achieve it. Can you please help me achieve that?

3
  • 1
    Literally just the title or is the whole reference clickable acceptable?
    – JamesT
    Oct 3, 2022 at 21:16
  • 1
    Thank you for your comment. And yes: literally just the title. Actually, my true (not-MWE) document already achieves the title as clickable only, so the issue is to hide the url (something I have achieved with all entry types except the online one, for some reason). However, I thought I would mention the title issue because any solution that breaks it won't be a solution.
    – EoDmnFOr3q
    Oct 3, 2022 at 21:21
  • 1
    Fair enough :) I have in my template documents a means to hyperlink entire entries (bar the cit. on etc. page numbers) and then disable the URL's which I always use with a bibnote explaining they are clickable (as the color box does not look nice). Hope someone more experienced in these dark arts can answer, best of luck!
    – JamesT
    Oct 3, 2022 at 21:23

1 Answer 1

3

Taken from this question: biblatex: make title hyperlink to DOIs, URL or ISBN. The option [online] limits this change only to online type references.

\documentclass{article}

\usepackage[isbn=false,giveninits=true,uniquename=init,style=authoryear-comp,backend=biber,sorting=ynt,maxbibnames=99,maxcitenames=3,hyperref=true,sortcites=true,language=british,doi=false,url=false,backref=true]{biblatex}

\RequirePackage[colorlinks=true,urlcolor=blue,linkcolor=black]{hyperref}

\addbibresource{References.bib}

% reference: https://tex.stackexchange.com/q/48400/133968
\newbibmacro{string+url}[1]{%
    \iffieldundef{url}{#1}{\href{\thefield{url}}{#1}}}
\DeclareFieldFormat[online]{title}{\usebibmacro{string+url}{\mkbibemph{#1}}}
\DeclareFieldFormat[online]{url}{}

% DOCUMENT

\begin{document}
    
    \cite{bop_22}
    
    \printbibliography
    
\end{document}

enter image description here

You must log in to answer this question.

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