我在我的 bib 源文件中使用了多个 url 链接,同时我想用链接符号替换它们(例如,在我的示例中来自 fontawesome5 的 \faLink)。
\DeclareFieldFormat
我根据问题直接在指令中插入字符304569但此解决方案的效果是,所有链接都被视为一个。
为了\renewbibmacro*{url}
避免 biblatex 在到达代码之前将 url 之间的空格分隔符转换为“%20”的问题,因此我使用命令重新定义 url bibmacro 以使用 urlraw 而不是 url。
我需要以某种方式逐个链接并将它们替换为自己的链接符号 (\falink)。一些 bib 条目只有一个或缺少链接。处理多个 url 的代码取自答案57865。
我的 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
我会扩展数据模型并添加对更多 URL 的支持。然后您将获得更清晰的 bib 并可以独立格式化您的 URL。
\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}