![Biblatex 格式,寻求格式化参考书目,但不在正文中](https://linux22.com/image/277451/Biblatex%20%E6%A0%BC%E5%BC%8F%EF%BC%8C%E5%AF%BB%E6%B1%82%E6%A0%BC%E5%BC%8F%E5%8C%96%E5%8F%82%E8%80%83%E4%B9%A6%E7%9B%AE%EF%BC%8C%E4%BD%86%E4%B8%8D%E5%9C%A8%E6%AD%A3%E6%96%87%E4%B8%AD.png)
我正在寻求格式化我的参考书目的某些部分(比如用不同的颜色标记作者姓名),但是,这种格式化也适用于文档正文中使用的引用。
在上面的例子中,我希望参考文献中的名称被格式化(小写,红色),但是我不希望它能够应用于实际的引用。
以下是上述示例的 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}