引文超链接颜色根据引文关键词而不同

引文超链接颜色根据引文关键词而不同

我正在撰写博士论文,我已设法使用 biber 和 biblatex 在论文中加入了参考书目和出版物列表。我认为,当我的出版物在论文中被引用时,通过为它们使用不同的 \cite{...} 编号来突出显示会很有趣。例如,我希望 \cite{Amariti:2023hev} 的输出为橙色而不是绿色。

论文的基本设置如下

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{xcolor}
\definecolor{newred}{rgb}{0.8, 0.0, 0.0}
\definecolor{ao}{rgb}{0.0, 0.5, 0.0}

\usepackage{hyperref}
\hypersetup{
    colorlinks = true,
    linkcolor= newred,
    citecolor= ao,
    linktoc=page
} 
\usepackage[backend=biber, style=authoryear]{biblatex}

\DeclareSourcemap{
  \maps[datatype=bibtex, overwrite]{
    \map{
      \perdatasource{bib1.bib}
      \step[fieldset=keywords, fieldvalue={, }, appendstrict]
      \step[fieldset=keywords, fieldvalue=one, append]
    }
    \map{
      \perdatasource{bib2.bib}
      \step[fieldset=keywords, fieldvalue={, }, appendstrict]
      \step[fieldset=keywords, fieldvalue=two, append]
    }
  }
}

\begin{filecontents}{bib1.bib}
@article{Amariti:2023hev,
    author = "Amariti, Antonio and Morgante, Davide and Pasternak, Antoine and Rota, Simone and Tatitscheff, Valdo",
    title = "{One-form symmetries in $\mathcal{N} = 3$ S-folds}",
    eprint = "2303.07299",
    archivePrefix = "arXiv",
    primaryClass = "hep-th",
    doi = "10.21468/SciPostPhys.15.4.132",
    journal = "SciPost Phys.",
    volume = "15",
    number = "4",
    pages = "132",
    year = "2023"
}
}
\end{filecontents}
\begin{filecontents}{bib2.bib}
@article{Gaiotto:2012xa,
    author = "Gaiotto, Davide and Rastelli, Leonardo and Razamat, Shlomo S.",
    title = "{Bootstrapping the superconformal index with surface defects}",
    eprint = "1207.3577",
    archivePrefix = "arXiv",
    primaryClass = "hep-th",
    doi = "10.1007/JHEP01(2013)022",
    journal = "JHEP",
    volume = "01",
    pages = "022",
    year = "2013"
}
\end{filecontents}
\addbibresource{bib1.bib}
\addbibresource{bib2.bib}

\begin{document}
I want the color of \cite{Gaiotto:2012xa} from bib2 to be the default (green) and the one of \cite{Amariti:2023hev} from bib1 to be another color like orange.

\printbibliography[title={First Bibliography}, keyword=one]
\printbibliography[title={Second Bibliography}, keyword=two]
\end{document}

此外,我不想仅仅针对散布在论文各处的少数引用定义不同的 \cite 命令。

这样的事可能吗?

答案1

您可以使用

\AtEveryCitekey{\ifkeyword{two}
     {\hypersetup{citecolor=ao}}
     {\hypersetup{citecolor=orange}}}

在此处输入图片描述

相关内容