正如问题所述Biblatex 仅对选定的关键字使用前缀,我需要用前缀突出显示一些参考文献,例如 [A2]。按照上述问题的答案,我能够得到想要的结果。但是,当我应用特定的 biblatex 样式时,\cite 键前面的前缀会消失。参考书目本身不受影响。这是一个 MWE:
\documentclass{scrartcl}
\usepackage{filecontents}
\usepackage[
backend = biber,
sorting = none,
%style = ieee
]{biblatex}
\begin{filecontents*}{references.bib}
@ARTICLE{art1,
author={John Doe and Jane Roe},
journal={Journal of Teamwork},
title={Some title},
year={2007},
}
@ARTICLE{art2,
author={John Doe},
journal={Some Journal},
title={A great paper},
year={2009},
}
@ARTICLE{art3,
author={Jane Roe},
journal={Journal of Articles},
title={An Article by Jane},
year={2010},
}
\end{filecontents*}
\DeclareBibliographyCategory{catA}
\addtocategory{catA}{art2}
\addbibresource{references.bib}
\renewbibmacro*{cite}{%
\printtext[bibhyperref]{%
\printfield{labelprefix}%
\ifcategory{catA}{A.}{}%
\printfield{labelnumber}%
\ifbool{bbx:subentry}
{\printfield{entrysetcount}}
{}}}
\defbibenvironment{bibliography}
{\list
{\printtext[labelnumberwidth]{%
\printfield{labelprefix}%
\ifcategory{catA}{A.}{}%
\printfield{labelnumber}}}
{\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
{\item}
\begin{document}
\cite{art1}, \cite{art2}, \cite{art3}
\printbibliography[heading = none]
\end{document}
正如所期望的,输出是
但取消注释该行后
style = ieee
输出变为
其他风格也同样如此。
答案1
由于 IEEE 样式使用numeric-comp
底层的编号样式,因此对 bibmacro 进行简单的更改cite
不起作用,这就是为什么更改样式时标签会消失的原因。numeric-comp 宏需要跟踪起始和结束引用编号,因此需要修改的宏更多。以下内容经过了轻微测试,但似乎可以满足您的要求。其中一位开发人员biblatex
在网站上很活跃,因此在接受这个答案之前,您可能需要等到他们同意(或解释其中的问题)。您可以尝试其他引用顺序,看看它是否也能正确处理最后一个数字。
\documentclass{scrartcl}
\usepackage{filecontents}
\usepackage[
backend = biber,
sorting = none,
style = ieee
]{biblatex}
\begin{filecontents*}{\jobname.bib}
@ARTICLE{art1,
author={John Doe and Jane Roe},
journal={Journal of Teamwork},
title={Some title},
year={2007},
}
@ARTICLE{art2,
author={John Doe},
journal={Some Journal},
title={A great paper},
year={2009},
}
@ARTICLE{art3,
author={Jane Roe},
journal={Journal of Articles},
title={An Article by Jane},
year={2010},
}
\end{filecontents*}
\DeclareBibliographyCategory{catA}
\addtocategory{catA}{art2}
\addbibresource{\jobname.bib}
\renewbibmacro*{cite:print:labelnumber}{%
\printtext[bibhyperref]{%
\printfield{labelprefix}%
\ifcategory{catA}{A.}{}%
\printfield{labelnumber}}}
\makeatletter
\renewbibmacro*{cite:print:last:labelnumber}{%
\printtext[bibhyperref:lastkey]{%
\ifdef\cbx@lastprefix
{\printtext[labelprefix]{\cbx@lastprefix}}
{}%
\ifcategory{catA}{A.}{}%
\printtext[labelnumber]{\cbx@lastnumber}}}
\renewbibmacro*{cite:print:last:subentry:comp}{%
\printtext[bibhyperref:lastkey]{%
\printtext[entrysetcount]{\cbx@lastentrysetcount}}}
\renewbibmacro*{cite:print:last:labelnumber}{%
\printtext[bibhyperref:lastkey]{%
\ifdef\cbx@lastprefix
{\printtext[labelprefix]{\cbx@lastprefix}}
{}%
\ifcategory{catA}{A.}{}%
\printtext[labelnumber]{\cbx@lastnumber}}}
\makeatother
\defbibenvironment{bibliography}
{\list
{\printtext[labelnumberwidth]{%
\printfield{labelprefix}%
\ifcategory{catA}{A.}{}%
\printfield{labelnumber}}}
{\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
{\item}
\begin{document}
\cite{art1,art2,art3}
\cite{art1,art2}
\cite{art1} \cite{art2}
\printbibliography[heading = none]
\end{document}