# How do I turn titles into hyperlinks in verbose mode using BibLaTeX and hyperref?

I'm using hyperref and BibLaTeX's verbose style, and would like for bibliography entries and initial (but not subsequent) citations, instead of printing out a URL, to use the URL to make the titles of entries and citations into external hyperlinks. Is there a way to do this?

I see how I might get part way there, in the bibliography, but I'm not sure how to get what I'm looking for in the initial citations as well.

\documentclass[nobib,nohyper]{tufte-handout}
\usepackage{lipsum}
\RequirePackage{xpatch}     % For the patches below
\RequirePackage[
backend=bibtex,
natbib=true,
bibstyle=verbose, citestyle=verbose,    % bibstyle extensively modifed below
doi=true, url=true,                     % excluded from citations below
citecounter=true, citetracker=true,
block=space,
backref=true, backrefstyle=two,
abbreviate=false
]{biblatex}

% For tufte-like behavior (I never use \cite itself); see -- https://tex.stackexchange.com/a/47763/7844
% Not directly related to the question but included for completeness
\let\citep\footcite

% Some customizations
\AtEveryCitekey{\clearfield{url}\clearfield{doi}\clearfield{eprint}\clearfield{isbn}}
\renewbibmacro*{in:}{}

% Some reordering and exclusions; see -- https://tex.stackexchange.com/q/46804/7844
% I'd like to preserve these changes, making the feature requested here an option
\clearfield{pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\clearlist{pageref}%

\RequirePackage[]{hyperref}
\RequirePackage[all]{hypcap}        % See -- https://tex.stackexchange.com/a/27349/7844

\begin{filecontents}{\jobname.bib}
@book{9780201134476,
author = {Knuth, Donald E},title = {{Computers & Typesetting, Volume A: The TeXbook}},
publisher = {Addison-Wesley Professional},year = {1986},isbn = {0201134470},
url = {http://www.amazon.com/dp/0201134470}}
@book{9780226458083,
author = {Kuhn, Thomas S},title = {{The Structure of Scientific Revolutions}},
publisher = {University Of Chicago Press},year = {1996},isbn = {0226458083},
url = {http://www.amazon.com/dp/0226458083}}
@book{9781903436837,
publisher = {Arden Shakespeare},year = {2005},isbn = {1903436834},
url = {http://www.amazon.com/dp/1903436834}}
@book{9780765303615,
author = {Brin, David},title = {{Existence}},
publisher = {Tor Books},year = {2012},isbn = {0765303612},
url = {http://www.amazon.com/dp/0765303612}}
@book{9780691122946,
author = {Frankfurt, Harry G},title = {{On Bullshit}},
publisher = {Princeton University Press},year = {2005},isbn = {0691122946},
url = {http://www.amazon.com/dp/0691122946}}
\end{filecontents}

\begin{document}

\subsection*{Some initial citations}

This\citep{9780691122946} is an initial citation, which in verbose style, it has no hyperlink and I've customized the style to omit the URL in the citation, though not in the bibliographic entry. Here's another,\citep{9780226458083} and here\citep{9781903436837,9780765303615,9780691122946} are some additional ones for good measure.

I'd like the titles for these to link externally, using the URL field from the \texttt{.bib} entry (using the DOI instead of there's no URL there).

\subsection*{Something to take up some space to demonstrate internal linking}

\lipsum[1]\lipsum[2]\lipsum[3]\lipsum[4]

\subsection*{Some subsequent citations, showing back links}
This\citep{9780691122946} is a subsequent  citation, which hyperlinks back to the first corresponding citation.
So are these.\citep{9780226458083, 9781903436837,9780765303615,9780691122946}.

These work as I want them to.

\defbibnote{@prenote}{Here, as an option, instead of displaying the URL, I'd like to have the title behave as desired in the first section above:  as an external link, using the URL field from the \texttt{.bib} entry.}
\printbibliography[prenote=@prenote]

\end{document}

• In my answer just comment out \AtEveryCite{\DeclareFieldAlias{linked}{default}}. You'll probably want to omit the fix for multiple URLs because that use of the url field is non-standard. BTW: If this answers your question, I can make an edit about that so we can close this post as a duplicate. – Audrey Mar 26 '12 at 23:07
• @Audrey: Almost. I want to hide the URL everywhere (easy) but I also want to have DOIs and ISBNs in the bibliography, but not in citations. So there's a bit more to do to integrate with the MWE. (Also not that I prefer your second approach to changing the title format definition.) – orome Mar 27 '12 at 0:06
• OK. I think this is worth its own answer. – Audrey Mar 27 '12 at 0:59
• @Audrey: Thanks. I'm close, but I need (1) to have no ISBN, DOI, etc. in citations (but still be able to use them there to link in the title); (2) to have ISBN, and DOI print in the bibliography, and (3) optionally have the URL print in the bibliography, on its own line (after the back reference). I can get these things to work individually (almost) but can't figure out how to get them all to work together. – orome Mar 27 '12 at 1:03
• You should've stated (3) in your question. The url option isn't settable on a per-entry basis. lockstep posted a workaround here. I think we've discussed how to print the URL on its own line already elsewhere. – Audrey Mar 27 '12 at 1:31

The url et al. fields should be suppressed in citations only after the titles are set. This can't be done inside a formatting command. So all the necessary edits can be made to bibliography macros that apply the title format.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage[american]{babel}
\usepackage[style=verbose,backref=true]{biblatex}
\usepackage{xpatch}

% Define new format to apply hypertext references
\ifhyperref
{\iffieldundef{url}
{\iffieldundef{doi}
{\iffieldundef{isbn}
{\iffieldundef{issn}
{\iffieldundef{eprint}
{#1}
{\mkhrefeprint{#1}}}
{\href{\worldcatsearch\thefield{issn}}{#1}}}
{\href{\worldcatsearch\thefield{isbn}}{#1}}}
{\href{http://dx.doi.org/\thefield{doi}}{#1}}}
{\href{\thefield{url}}{#1}}}
{#1}}

\def\worldcatsearch{http://www.worldcat.org/search?qt=worldcat_org_all&q=}

\makeatletter

\newrobustcmd*{\mkhrefeprint}[1]{%
\iffieldequalstr{eprinttype}{arxiv}
{\href{http://arxiv.org/\abx@arxivpath/\thefield{eprint}}{#1}}
{\iffieldequalstr{eprinttype}{hdl}
{\href{http://hdl.handle.net/\thefield{eprint}}{#1}}
{\iffieldequalstr{eprinttype}{jstor}
{\href{http://www.jstor.org/stable/\thefield{eprint}}{#1}}
{\iffieldequalstr{eprinttype}{pubmed}
{\href{http://www.ncbi.nlm.nih.gov/pubmed/\thefield{eprint}}{#1}}
{#1}}}}}}

% Add missing space in arXiv format
\DeclareFieldFormat{eprint:arxiv}{%
\ifhyperref
{\href{http://arxiv.org/\abx@arxivpath/#1}{%
\iffieldundef{eprintclass}
\iffieldundef{eprintclass}

\makeatother

% Use new format in titles
\renewbibmacro*{title}{% Based on generic definition from biblatex.def
\ifboolexpr{ test {\iffieldundef{title}} and test {\iffieldundef{subtitle}} }
{}
\printfield[titlecase]{title}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{subtitle}}}%
\newunit}%

\renewbibmacro*{periodical}{% Based on generic definition from biblatex.def
\iffieldundef{title}
{}
\printfield[titlecase]{title}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{subtitle}}}}

% Suppress url everywhere, suppress URLs/identifiers in citations
\clearfield{url}\clearfield{urlyear}%
\ifcitation
{\clearfield{doi}\clearfield{eprint}\clearfield{isbn}\clearfield{issn}}
{}}

% Suppress \finentrypunct after linebreaking URLs/identifiers
\newtoggle{bbx:urlbreak}
\xpretobibmacro{finentry}
{\iftoggle{bbx:urlbreak}{\nopunct}{}%
\global\togglefalse{bbx:urlbreak}}{}{}

% Print URLs/identifiers at end of entry, after a linebreak
\clearfield{pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\clearlist{pageref}%
\setunit{%
\finentrypunct\par\nobreak%
\global\toggletrue{bbx:urlbreak}}}

\begin{filecontents}{\jobname.bib}
@book{wilde,
title={The Importance of Being Earnest: A Trivial Comedy for Serious People},
author={Wilde, Oscar},
series={English and American drama of the nineteenth century},
eprint={4HIWAAAAYAAJ},
year={1899},
publisher={Leonard Smithers and Company}}
@Periodical{jcg,
title = {Computers and Graphics},
issuetitle = {Semantic {3D} Media and Content},
volume = {35},
number = {4},
year = {2011},
issn = {0097-8493}}
@Manual{cmso,
label = {CMS Online},
title = {The Chicago Manual of Style Online},
edition = {16},
publisher = {University of Chicago},
date = {2010},
url = {http://www.chicagomanualofstyle.org}}
\end{filecontents}

\begin{document}
\null\vfill
Filler text.\footnote{Filler text \smartcite{kastenholz,itzhaki}.}
Filler text.\footcites[e.g][]{companion}[section 5]{cms}[10--15]{jcg}{ctan}
Filler text.\footcites[e.g][]{companion}[section 5]{cms}[10--15]{jcg}{ctan}
Filler text.\footcites[e.g.][10--15]{itzhaki}[cf.][10]{wilde}
\printbibliography
\end{document}


• Excellent! Two questions: (1) is there a way to get rid of the period after URLs and DOIs when I have url=true or doi=true; and, (2) is there a way to remove the URL from online entries (unless I have url=true)? – orome Mar 27 '12 at 3:29
• @raxacoricofallapatorius I've made edits. Next go round, try to state your requirements up front. If they're somewhere in your MWE, then that might be sign your example isn't minimal enough (or I'm a lazy reader). If you want ISBN/ISSN printed like DOI - after back references and a linebreak - open up a new question. It can be done, but it's a pain because the standard drivers uses \printfield directly. xpatchbibdriver should come in handy. – Audrey Mar 27 '12 at 6:18
• The ISBN/ISSNs are fine where they are, so this is perfect. Thank you! One nit: the changes to addendum+pubstate+pageref replace the semicolons (;) between multiple initial citations with periods (.). Any idea how to fix that? – orome Mar 27 '12 at 18:18
• @raxacoricofallapatorius Yeah, I should've noticed that. It gives bad punctuation in other cases, too. I'll take a look into a better solution in a bit. – Audrey Mar 27 '12 at 22:16
• @raxacoricofallapatorius It should be fixed in the edit I just posted. I also threw in title links to URLs based on the eprint field. – Audrey Mar 28 '12 at 1:04