后续标点符号的颜色

后续标点符号的颜色

我使用以下代码为文本中参考文献的括号着色。这对括号之间的逗号和连字符也有效。但是后续标点符号的颜色也会改变。有没有办法让这些标点符号以标准文本颜色显示?

请注意,为了编译下面的示例,您可能必须将默认参考书目工具更改为 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}}

相关内容