答案1
biblatex
的numeric
样式有 的概念labelprefix
。不幸的是,对我们来说,labelprefix
是一个... 嗯... 前缀,所以它显示在标签编号之前。所以我们可以轻松获得
[A-1]
但不那么容易
[1-A]
您的图像看起来像是在使用gost-numeric
基于的numeric-comp
。numeric-comp
是最复杂的标准样式之一biblatex
,因此需要相当多的代码才能将变成labelprefix
后缀。
请注意,对引用样式的修改numeri-comp
将在未来版本中停止工作biblatex
(见https://github.com/plk/biblatex/issues/900,https://github.com/plk/biblatex/pull/963)。
\documentclass[russian]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=gost-numeric, defernumbers, backend=biber]{biblatex}
\DeclareFieldFormat{labelprefix}{--#1}
\defbibenvironment{bibliography}
{\list
{\printtext[labelnumberwidth]{%
\printfield{labelnumber}%
\printfield{labelprefix}}}
{\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}
\makeatletter
\renewbibmacro*{cite:comp:end}{%
\usebibmacro{cite:dump}%
\ifnumgreater{\value{cbx@tempcntb}}{-1}
{\multicitedelim}
{}%
\printtext[bibhyperref]{%
\printfield{labelnumber}%
\printfield{labelprefix}}}
\renewbibmacro*{cite:comp:inset}{%
\usebibmacro{cite:dump}%
\ifnumgreater{\value{cbx@tempcntb}}{-1}
{\multicitedelim}
{}%
\printtext[bibhyperref]{%
\printfield{labelnumber}%
\printfield{labelprefix}%
\printfield{entrysetcount}}%
\setcounter{cbx@tempcntb}{-1}}
\renewbibmacro*{cite:dump}{%
\ifnumgreater{\value{cbx@tempcnta}}{0}
{\ifnumgreater{\value{cbx@tempcnta}}{1}
{\bibrangedash}
{\multicitedelim}%
\bibhyperref[\cbx@lastkey]{%
\printtext[labelnumber]{\cbx@lastnumber}%
\ifdef\cbx@lastprefix
{\printtext[labelprefix]{\cbx@lastprefix}}
{}}}
{}%
\setcounter{cbx@tempcnta}{0}%
\global\undef\cbx@lastprefix}
\makeatother
\addbibresource{biblatex-examples.bib}
\begin{document}
Lorem \autocite{sigfridsson}
ipsum \autocite{worman,geer,nussbaum}
\newrefcontext[labelprefix=A]
\printbibliography[resetnumbers, heading=subbibliography, type=article]
\newrefcontext
\printbibliography[resetnumbers, heading=subbibliography, nottype=article]
\end{document}
从biblatex
3.15 开始(尚未发布,但dev
版本可在 GitHub 和 Sourceforge 上找到),将之间的块替换\makeatletter...\makeatother
为
\renewbibmacro*{cite:print:labelnumber}{%
\printtext[bibhyperref]{%
\printfield{labelnumber}%
\printfield{labelprefix}}}
\renewbibmacro*{cite:print:subentry:full}{%
\printtext[bibhyperref]{%
\printfield{labelnumber}%
\printfield{labelprefix}%
\printfield{entrysetcount}}}
\makeatletter
\renewbibmacro*{cite:print:last:labelnumber}{%
\printtext[bibhyperref:lastkey]{%
\printtext[labelnumber]{\cbx@lastnumber}%
\ifdef\cbx@lastprefix
{\printtext[labelprefix]{\cbx@lastprefix}}
{}}}
\makeatother