0

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?

Right now I am using the backref=page option in the hyperref package and get:

enter image description here

With a .bib file:

@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}
}
Jona Engel
  • 175
  • 6
  • \href{DOI 10.1093}{https://doi.org/.....} – David Carlisle Jan 13 '22 at 16:29
  • 1
    @DavidCarlisle the other way round ... – Ulrike Fischer Jan 13 '22 at 16:36
  • Thanks, that was quick. Just to brief for me. Where would I put that? At the URL section in the .bib file? – Jona Engel Jan 13 '22 at 16:39
  • @UlrikeFischer ah I had even chances of getting that right... – David Carlisle Jan 13 '22 at 16:49
  • @DavidCarlisle if you know about catcodes you could guess that the difficult part is first ;-) – Ulrike Fischer Jan 13 '22 at 17:02
  • it is hard to say what to change, at the pure latex/hyperref lavel \url{http://a/b/c} prints the url as the link and \href{link url}{link text} allows link url and text to be specified separately. But you are preumably using bibtex (or biblatex given the tags?) to generate the latex and just using a URL field hard to generate a link text, better would be a DOI field that just had doi=abcde then you could use that as the link text and generate a doi.org URL that worked from that. But that would require changes to your bib file and your bibliography style – David Carlisle Jan 13 '22 at 17:09
  • Seams like I just asked at the right time. I am actually just setting up the .bib files and am actually open to which backend to use. I thought I give biblatex and biber a try. I'd much rather prefer a new ref. section than a particular tool chain. So I am open for your suggestions. At the end. I would want a reference entry in a pdf which does not display the URL but where you could click on the entry and get to the (doi) url – Jona Engel Jan 13 '22 at 17:15
  • Are you looking for something like https://tex.stackexchange.com/q/624758/35864? – moewe Jan 13 '22 at 17:16
  • @moewe not quite. This still prints "DOI" and "URL", what I want is the entire entry in the reference section to be the displayed part of the link. In unix terminology perhaps: ln -s $URL $REF where $DOI is the URL to the DOI and $REF is the corresponding whole entry in the References section. – Jona Engel Jan 13 '22 at 17:22
  • Maybe you can adapt https://tex.stackexchange.com/questions/382796/is-it-possible-to-access-google-directly-from-your-bibtex-citations/383033 to use the url from the url field instead of the (more complicated) approach there to construct the url out of the title and authors. – Marijn Jan 13 '22 at 20:22
  • There is also https://tex.stackexchange.com/questions/534216/when-using-elsarticle-cls-how-to-make-each-bibliography-item-a-clickable-hyperl/534369 – Marijn Jan 13 '22 at 20:53

1 Answers1

2

For BibTeX you can use bibliography styles produced by the urlbst script. This is a script that takes an existing .bst file as input and produces a new .bst file with added url functionality. One of the features of the script is to suppress url and doi fields and make the title a hyperlink to the contents of those fields. This is done using the command line flags --hyperref --inlinelinks.

The following command modifies plain.bst into plainlinks.bst:

$ urlbst --hyperref --inlinelinks `kpsewhich plain.bst` > plainlinks.bst

The kpsewhich substitution is to find the path of the installed plain.bst and provide this path as input to urlbst, of course you can also locate the plain.bst yourself and copy it to your working directory first.

Then you can use the following MWE:

\documentclass{article}
\usepackage{hyperref}
\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},
  doi={10.1093/comjnl/27.2.97}
}
\end{filecontents*}
\begin{document}
\cite{knuth1984}
\bibliographystyle{plainlinks}
\bibliography{\jobname}
\end{document}

Result:

enter image description here

urlbst is compatible with the standard styles (plain, alpha, unsrt, abbrv) but also with Natbib, AMS styles, IEEE, and many other custom styles. It is used by big publishers like ACL for their conferences.

Marijn
  • 37,699