我正在寻求格式化我的参考书目的某些部分(比如用不同的颜色标记作者姓名),但是,这种格式化也适用于文档正文中使用的引用。
在上面的例子中,我希望参考文献中的名称被格式化(小写,红色),但是我不希望它能够应用于实际的引用。
以下是上述示例的 MWE 代码。如果有人知道如何实现这一点,我将不胜感激。
\documentclass{article}
\usepackage{helvet}
\usepackage{xcolor}
\renewcommand\familydefault\sfdefault
\usepackage[natbib,backend=biber,firstinits=true,citestyle=numeric-comp,backref=true,sorting=none]{biblatex}
\begin{filecontents}{dummy.bib}
@ARTICLE{einstein1905electrodynamics,
author = {Einstein, Albert},
title = {On the Electrodynamics of Moving Bodies},
journal = {Annalen der Physik},
year = {1905},
volume = {17},
pages = {50},
number = {891},
abstract = {N/A},
}
\end{filecontents}
\addbibresource{dummy.bib}
%THE FORMATTING IN BIBLIOGRAPHY
\renewcommand{\finentrypunct}{}
\renewcommand{\mkbibnamefirst}[1]{\textcolor{red}{\textsc{#1}}}
\renewcommand{\mkbibnamelast}[1]{\textcolor{red}{\textsc{#1}}}
\renewcommand{\mkbibnameprefix}[1]{\textcolor{red}{\textsc{#1}}}
\renewcommand{\mkbibnameaffix}[1]{\textcolor{red}{\textsc{#1}}}
%COMMENCE
\begin{document}
Test citation by \citet{einstein1905electrodynamics}
\printbibliography
\end{document}
答案1
如果你希望代码的某一部分仅有的适用于参考书目,而不是引文,你可以简单地把它包起来
\AtBeginBibliography{%
...
}
所以它将在建立书目之前执行。
然后你的 MWE 得出
\documentclass{article}
\usepackage{helvet}
\usepackage{xcolor}
\renewcommand\familydefault\sfdefault
\usepackage[natbib,backend=biber,firstinits=true,citestyle=numeric-comp,backref=true,sorting=none]{biblatex}
\begin{filecontents}{dummy.bib}
@ARTICLE{einstein1905electrodynamics,
author = {Einstein, Albert},
title = {On the Electrodynamics of Moving Bodies},
journal = {Annalen der Physik},
year = {1905},
volume = {17},
pages = {50},
number = {891},
abstract = {N/A},
}
\end{filecontents}
\addbibresource{dummy.bib}
\AtBeginBibliography{%
%THE FORMATTING IN BIBLIOGRAPHY
\renewcommand{\finentrypunct}{}
\renewcommand{\mkbibnamefirst}[1]{\textcolor{red}{\textsc{#1}}}
\renewcommand{\mkbibnamelast}[1]{\textcolor{red}{\textsc{#1}}}
\renewcommand{\mkbibnameprefix}[1]{\textcolor{red}{\textsc{#1}}}
\renewcommand{\mkbibnameaffix}[1]{\textcolor{red}{\textsc{#1}}}
}
%COMMENCE
\begin{document}
Test citation by \citet{einstein1905electrodynamics}
\printbibliography
\end{document}