A scheme like this needs support on two sides: You need to extract the relevant data from the .bib file and you need to use that data in the citation.
With the normal BibTeX approach the entry data is not available when citations are generated, so the standard method to make something usable in citations is to write it to the .aux file. (In theory there are other methods like usebib that parse the .bib file in LaTeX directly, but that has its limits.)
So firstly, you need to tell your BibTeX style about the new field you intend to use to pass the URL on to LaTeX.
This is fairly straightforward if you have gotten the hang of the BibTeX programming language. The exact steps you have to do will vary from style to style. For this answer I use plain.bst as an example.
Copy plain.bst to a place where LaTeX can find it (the directory of your current document will do) and rename it to plain-hrefcite.bst.
Add a short note about the nature of the file in the comments at the beginning.
Make the new field, say href, (and if necessary url) known to BibTeX by adding it to the first list in ENTRY at the beginning of your .bst file.
Add code to write the href info to the .bbl file. This can be done by adding something like
href empty$
{ url }
{ href }
if$
duplicate$ empty$
'pop$
{
"\bbldefcitehref{" cite$ * "}{" * swap$ * "}" * write$
newline$
}
if$
to the function that prints the \bibitem (in the example FUNCTION {output.bibitem}).
Just to be sure give a fallback definition for \bbldefcitehref in the function that writes \begin{thebibliography} (in our example FUNCTION {begin.bib})
"\providecommand*{\bbldefcitehref}[2]{}" write$ newline$
The exact details of the modification will differ from style to style, but the general idea should be applicable to a broad range of styles.
You can get the modified version of plain.bst called plain-hrefcite.bst from https://gist.github.com/moewew/783770c4abbb3ce7cbfb84069c3c5a32. The changes to the original file are nicely highlighted in the revision tab and come down to
--- plain.bst 2010-12-09 04:18:56.000000000 +0100
+++ plain-hrefcite.bst 2021-01-21 08:04:09.349426800 +0100
@@ -1,3 +1,13 @@
+%%%% plain-hrefcite.bst
+%%%% 2021-01-21 MW
+%%%%
+%%%% add a linked item to citation label
+%%%%
+%%%% https://tex.stackexchange.com/q/579660/35864
+%%%%
+%%%% added a href field and write its contents to the bbl in \bbldefcitehref
+%%%%
+%%%%
% BibTeX standard bibliography style `plain'
% Version 0.99b (8-Dec-10 release) for BibTeX versions 0.99a or later.
% Copyright (C) 1984, 1985, 1988, 2010 Howard Trickey and Oren Patashnik.
@@ -31,6 +41,8 @@
type
volume
year
+ url
+ href
}
{}
{ label }
@@ -88,6 +100,17 @@
cite$ write$
"}" write$
newline$
+ href empty$
+ { url }
+ { href }
+ if$
+ duplicate$ empty$
+ 'pop$
+ {
+ "\bbldefcitehref{" cite$ * "}{" * swap$ * "}" * write$
+ newline$
+ }
+ if$
""
before.all 'output.state :=
}
@@ -1080,6 +1103,7 @@
'skip$
{ preamble$ write$ newline$ }
if$
+ "\providecommand*{\bbldefcitehref}[2]{}" write$ newline$
"\begin{thebibliography}{" longest.label * "}" * write$ newline$
}
Then it is just a matter of transferring the information from the .bbl file to the .aux file so it is available in citations from the start. With that sorted we can print the information in citations by modifying the macro that implements \cite (if you don't load any citation or bibliography-related packages, the relevant macro will be \@citex from the LaTeX kernel).
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{fontawesome}
\usepackage[colorlinks]{hyperref}
\makeatletter
\newcommand*{\bbldefcitehref}[2]{%
\immediate\write@mainaux{\noexpand\auxdefcitehref{\unexpanded{#1}}{\unexpanded{#2}}}}
\newcommand*{\auxdefcitehref}[2]{%
\expandafter\global\expandafter\def\csname citehref@#1\endcsname{#2}}
\newcommand*{\mkcitehref}[1]{%#
\ifx#1\empty
\ \href{https://example.edu}{\faExternalLink}%
\fi
\ifcsname citehref@#1\endcsname
\ \href{\csname citehref@#1\endcsname}{\faExternalLink}%
\fi}
\def@citex[#1]#2{\leavevmode
\let@citea@empty
@cite{@for@citeb:=#2\do
{@citea\def@citea{,\penalty@m\ }%
\edef@citeb{\expandafter@firstofone@citeb@empty}%
\if@filesw\immediate\write@auxout{\string\citation{@citeb}}\fi
@ifundefined{b@@citeb}{\hbox{\reset@font\bfseries ?}%
\G@refundefinedtrue
@latex@warning
{Citation `@citeb' on page \thepage \space undefined}}%
{@cite@ofmt{\csname b@@citeb\endcsname
\mkcitehref{@citeb}}}}}{#1}}
\def@lbibitem[#1]#2{\def\hrefcite@currentkey{#2}\item[@biblabel{#1}\hfill]\if@filesw
{\let\protect\noexpand
\immediate
\write@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces}
\def@bibitem#1{\def\hrefcite@currentkey{#1}\item\if@filesw \immediate\write@auxout
{\string\bibcite{#1}{\the\value{@listctr}}}\fi\ignorespaces}
\newcommand*{\hrefcite@currentkey}{}
\def@biblabel#1{[#1\mkcitehref{\hrefcite@currentkey}]}
\makeatother
\begin{filecontents}{\jobname.bib}
@book{elk,
author = {Anne Elk},
title = {A Theory on Brontosauruses},
year = {1972},
publisher = {Monthy & Co.},
location = {London},
href = {https://example.edu/~elk/bronto.pdf},
}
@book{belk,
author = {Anne Belk},
title = {A Theory on Brontosauruses},
year = {1972},
publisher = {Monthy & Co.},
location = {London},
url = {https://example.edu/~elk/bronto.pdf},
}
@article{sigfridsson,
author = {Sigfridsson, Emma and Ryde, Ulf},
title = {Comparison of methods for deriving atomic charges from the
electrostatic potential and moments},
journal = {Journal of Computational Chemistry},
year = 1998,
volume = 19,
number = 4,
pages = {377-395},
doi = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
}
\end{filecontents}
\begin{document}
Lorem \cite{sigfridsson,elk,belk}
\bibliographystyle{plain-hrefcite}
\bibliography{\jobname}
\end{document}

i6bibliostyle.bstfile. I don't really understand that code. What programming language is that? Where do I find documentation about it? But it looks like I might be able to modify the functioncalc.labelin there to add a\hrefin some way... – Albert Jan 20 '21 at 12:37