0

I am using multiple url links in my bib source file and at the same time I would like to replace them with link symbol (e.g., \faLink from fontawesome5 in my example).

I insert the character directly in a \DeclareFieldFormat directive, based on question 304569. But this solution has an effect that all links are taken as one.

The \renewbibmacro*{url} to avoid the issue that biblatex converts the space separator between urls to "%20" before it reaches the code, Therefore I use the command to redefine the url bibmacro to use urlraw instead of url.

I need to somehow take link per link and replace them with own link symbols (\falink). Some bib entries have only one or link is missing. The code for handling multiple urls is taken from answer 57865.

My MNWE:

% How to use multiple URLs for one bibtex reference? % https://tex.stackexchange.com/questions/57865/ \RequirePackage{filecontents} \begin{filecontents}{test3.bib} @Misc{oai:CiteSeerPSU:562256, title = "Gerris: {A} Tree-Based Adaptive Solver For The Incompressible Euler Equations In Complex Geometries", author = "St Ephane Popinet", year = "2002", month = sep # "~08", language = "en", oai = "oai:CiteSeerPSU:562256", rights = "unrestricted", URL = "https://1drv.ms/b/s!Ajq2sO-eH2xUh8BQBF8PicG1fNTX_A https://en.wikisource.org/wiki/On_Faraday%27s_Lines_of_Force https://www.isvavai.cz/riv?ss=detail&h=RIV%2F00216208%3A11320%2F00%3A00001579", } \end{filecontents} \documentclass{article} \usepackage{fontawesome5} \usepackage{url} \usepackage[backend=biber]{biblatex} \usepackage[ colorlinks=true, % false: boxed links; true: colored links linkcolor=blue!80, % color of internal links (change box color with linkbordercolor) citecolor=green, % color of links to bibliography filecolor=magenta, % color of file links ]{hyperref} \addbibresource{test3.bib} \renewbibmacro*{url}{\printfield[url]{urlraw}} \let\URL\url \makeatletter \def\url{\begingroup \catcode`\%=12\catcode`\#=12\relax\printurl} \def\printurl#1{\@URL#1 \@nil\endgroup} \def\@URL#1 #2\@nil{\URL{#1}\ifx\relax#2\relax \else; \url{#2\relax}\fi} \makeatother \DeclareFieldFormat{url}{\textsc{URL}: \href{#1}{\faLink}} \begin{document} Cite \cite{oai:CiteSeerPSU:562256} \printbibliography \end{document} 

1 Answer 1

2

I would extend the datamodel and add support for more url's. Then you get a cleaner bib and can format your url independantly.

\begin{filecontents}{moreurl.dbx} \DeclareDatamodelFields[type=field, datatype=uri]{urli,urlii} \DeclareDatamodelEntryfields{urli,urlii} \end{filecontents} \begin{filecontents}{test3.bib} @Misc{oai:CiteSeerPSU:562256, title = "Gerris: {A} Tree-Based Adaptive Solver For The Incompressible Euler Equations In Complex Geometries", author = "St Ephane Popinet", year = "2002", month = sep # "~08", language = "en", oai = "oai:CiteSeerPSU:562256", rights = "unrestricted", URL = "https://1drv.ms/b/s!Ajq2sO-eH2xUh8BQBF8PicG1fNTX_A", URLi="https://en.wikisource.org/wiki/On_Faraday%27s_Lines_of_Force", URLii="https://www.isvavai.cz/riv?ss=detail&h=RIV%2F00216208%3A11320%2F00%3A00001579", } \end{filecontents} \documentclass{article} \usepackage{fontawesome5} \usepackage{url} \usepackage[backend=biber,datamodel=moreurl]{biblatex} \usepackage[ colorlinks=true, % false: boxed links; true: colored links linkcolor=blue!80, % color of internal links (change box color with linkbordercolor) citecolor=green, % color of links to bibliography filecolor=magenta, % color of file links ]{hyperref} \addbibresource{test3.bib} \renewbibmacro*{url}{\printfield[url]{urlraw}\printfield[url]{urli}\printfield[url]{urlii}} \DeclareFieldFormat{url}{\textsc{URL}: \href{#1}{\faLink}} \begin{document} Cite \cite{oai:CiteSeerPSU:562256} \printbibliography \end{document} 
1
  • When I put datamodel into localtexmf folder then it doesn't work. How to prevent this? Commented Jul 6, 2023 at 20:41

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.