我想使用 biblatex 字母引文样式为我的引文着色。但是,我并不想只为“关键”着色(就像这张纸)但整个区块包括:
- 左括号(或大括号)
- (可能的)预先说明:例如'参见‘
- “关键”(取决于引用风格 - 'Abc90' 就我而言)
- (可能的)后注:例如'第 1337 页'。
- 右括号(或花括号)
我成功地为键 + 引用周围的括号 (+ 在引用多个键的情况下为冒号) 着色。
但是,我不知道如何给附注着色('第 43 页' 在 MWE 中) 和参考书目中的关键 ('约翰73')
我的 MWE 是:
\documentclass{article}
%== inclue bib file ==%
\usepackage{filecontents}
\begin{filecontents}{referencia.bib}
@misc{john-73,
author = {John, S.},
year = {1973},
title = {The best book ever},
}
\end{filecontents}
%== use and define color ==%
\usepackage[dvipsnames]{xcolor}
\definecolor{bleu_cite}{RGB}{12,127,172}
%== use color in citations ==%
\usepackage[
colorlinks=true,
allcolors = black,
citecolor=bleu_cite,
]{hyperref}
%== biblatex options ==%
\PassOptionsToPackage{
natbib=true,
backend=biber,
style=alphabetic,
}{biblatex}
\usepackage{biblatex}
\addbibresource{referencia.bib}
\makeatletter
\renewcommand*{\bibleftbracket}{\blx@postpunct\textcolor{bleu_cite}{[}}
\renewcommand*{\bibrightbracket}{\blx@postpunct\textcolor{bleu_cite}{]}\midsentence}
\renewcommand*{\multicitedelim}{\textcolor{bleu_cite}{\addsemicolon\space}}
\renewcommand*{\citesetup}{\textcolor{bleu_cite}}
\makeatother
\begin{document}
``Some quotation'' \citep[43]{john-73}.
\printbibliography
\end{document}
答案1
要仅对特定的引用命令进行着色,最简单的方法是定义一个新的彩色包装器来替换\mkbibbrackets
\newcommand{\mkbibbracketscol}[1]{\textcolor{bleu_cite}{\mkbibbrackets{#1}}}
然后,所有使用\mkbibbrackets
我们希望着色的命令都需要使用新命令,而那些不使用任何命令的命令只需进入\textcolor{bleu_cite}
其包装器即可。下面的定义是从相关.cbx
文件(在我们的例子中)复制的alphabetic.cbx
,并根据需要对其进行修改以使用\mkbibbracketscol
或\textcolor{bleu_cite}
。
\DeclareCiteCommand{\cite}[\mkbibbracketscol]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\parencite}[\mkbibbracketscol]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\cbx@textcite}[\textcolor{bleu_cite}]
{\usebibmacro{textcite:init}}
{\usebibmacro{citeindex}%
\usebibmacro{textcite}}
{}
{\usebibmacro{textcite:postnote}}
平均能量损失
\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\definecolor{bleu_cite}{RGB}{12,127,172}
\usepackage[
colorlinks=true,
allcolors = black,
citecolor=bleu_cite,
]{hyperref}
\PassOptionsToPackage{
natbib=true,
backend=biber,
style=alphabetic,
}{biblatex}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
%\AtEveryCite{\color{bleu_cite}}
\newcommand{\mkbibbracketscol}[1]{\textcolor{bleu_cite}{\mkbibbrackets{#1}}}
\DeclareCiteCommand{\cite}[\mkbibbracketscol]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\parencite}[\mkbibbracketscol]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\cbx@textcite}[\textcolor{bleu_cite}]
{\usebibmacro{textcite:init}}
{\usebibmacro{citeindex}%
\usebibmacro{textcite}}
{}
{\usebibmacro{textcite:postnote}}
\begin{document}
Lorem \citep[43]{geer} ipsum \citeauthor{worman} dolor \citet[43]{geer} sit \citetitle{worman} amet.
\printbibliography
\end{document}
如果你想要的是所有引用命令的颜色,而不是超链接,那么你应该满意
\AtEveryCite{\color{bleu_cite}}
这将使整个引用变成一个很好的蓝色色调;然而,链接仍然局限于标签。