テキスト内の参照の括弧に色を付けるには、次のコードを使用します。括弧内のカンマやハイフンにも同様に機能します。ただし、後続の句読点の色も変更されます。これらの句読点が標準のテキスト色で表示されるようにする解決策はありますか?
以下の例をコンパイルするには、デフォルトの参考文献ツールを Biber に変更する必要がある可能性があることに注意してください。
\documentclass[a4paper,twoside,openright,chapterprefix=true,11pt]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[doi=false,url=true,isbn=false,sorting=none,style=numeric-comp,bibencoding=utf8,babel=other,backend=biber]{biblatex}
\usepackage[utf8]{inputenc}
\usepackage[ngerman,american]{babel}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor}
\definecolor{CeruleanRef}{RGB}{12,127,172}
\usepackage[colorlinks=true, citecolor=CeruleanRef]{hyperref}
\begin{filecontents}{bibname.bib}
@book{Lehner2014,
author = {Lehner, Markus and Tichler, Robert and Koppe, Markus},
doi = {10.1007/978-3-319-03995-4},
file = {:Users/lima/ICP/Literatur/Power-to-Gas- Technology and Business Models.pdf:pdf},
isbn = {978-3-319-03994-7},
title = {{Power-to-Gas: Technology and Business Models}},
year = {2014}
}
@article{Garcia2014,
author = {Garcia-Fresnillo, L. and Shemet, V. and Chyrkin, A. and de Haart, L.G.J. and Quadakkers, W.J.},
doi = {10.1016/j.jpowsour.2014.07.189},
file = {:Users/lima/Library/Application Support/Mendeley Desktop/Downloaded/Garcia-Fresnillo et al. - 2014 - Long-term behaviour of solid oxide fuel cell interconnect materials in contact with Ni-mesh during e(2).pdf:pdf},
issn = {03787753},
journal = {J. Power Sources},
month = dec,
pages = {213--222},
publisher = {Elsevier B.V},
title = {{Long-term behaviour of solid oxide fuel cell interconnect materials in contact with Ni-mesh during exposure in simulated anode gas at 700 and 800}},
url = {http://linkinghub.elsevier.com/retrieve/pii/S0378775314012531},
volume = {271},
year = {2014}
}
\end{filecontents}
\bibliography{bibname.bib}
\DeclareCiteCommand{\cite}[\color{CeruleanRef}\mkbibbrackets]
{\usebibmacro{cite:init}%
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}%
\usebibmacro{postnote}}
\begin{document}
test
\cite{Lehner2014} and \cite{Garcia2014} but \cite{Lehner2014}. Or \cite{Lehner2014,Garcia2014}, which has
\end{document}
答え1
独自のブラケット コマンドを定義できます (または \mkbibbrackets を再定義できます)。
\makeatletter
\newrobustcmd{\mkbibbracketscolor}[1]{%
\begingroup%
\blx@blxinit
\blx@setsfcodes
\color{CeruleanRef}\bibopenbracket#1\bibclosebracket%
\endgroup}
\makeatother
\DeclareCiteCommand{\cite}[\mkbibbracketscolor]
{\usebibmacro{cite:init}%
\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite:comp}}
{}
{\usebibmacro{cite:dump}%
\usebibmacro{postnote}}