引文超連結顏色依引文鍵而不同

引文超連結顏色依引文鍵而不同

我正在寫我的博士論文,我已經成功地在其中包含了參考書目和我使用 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}}}

在此輸入影像描述

相關內容