我想使用两个独立的书目biblatex
,其中一个用于自己的出版物,另一个用于其他出版物。前者应标有字母 [A]、[B]、...,后者标有数字 [1]、[2]、[3]。我在文件中的自己的出版物中插入了“own”.bib
作为关键字。这是我的代码:
\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage[backend=biber,
style=numeric-comp,
defernumbers=true
]{biblatex}
\RequireBibliographyStyle{standard}
\ExecuteBibliographyOptions{labelnumber}
\DeclareNameAlias{author}{default}
\DeclareNameAlias{editor}{default}
\DeclareNameAlias{translator}{default}
\DeclareFieldFormat{bibentrysetcount}{\mkbibparens{\mknumalph{#1}}}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}
\DeclareFieldFormat{shorthandwidth}{\mkbibbrackets{#1}}
%\DeclareFieldFormat{labelnumber}{\mknumalph{#1}}
\defbibenvironment{ownpub}
{\list
{\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\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}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{albert,
author = {Author, A.},
year = {2001},
title = {Alpha},
keywords = {own}
}
@misc{berta,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
@misc{cesar,
author = {Cuthor, C.},
year = {2003},
title = {Charlie},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
own pub: \cite{albert}
other: \cite{berta}
other: \cite{cesar}
\printbibliography[env=bibliography,notkeyword=own]
\printbibliography[env=ownpub,keyword=own,resetnumbers=true]
\end{document}
我复制了numeric.bbx
定义以定义新的 bib 环境“ownpub”。到目前为止,它使用数字标签,显示两个书目,每个书目都以 [1] 开头。但是,当我尝试将环境切换ownpub
为字母标签时(通过注释的\DeclareFieldFormat
,用\mknumalph
), 的更改labelnumber
是全局的,并且两个书目都获得了字母标签。
我怎样才能将第二个参考书目更改为字母标签?
答案1
你可以尝试
\DeclareFieldFormat{labelnumber}{\ifkeyword{own}{\mknumalph{#1}}{#1}}
keyword
own
用字母标签来标记条目。
在下面的 MWE 中,我删除了所有没有改变标准的修改
\documentclass{article}
\usepackage[english]{babel}
\usepackage[backend=biber,
style=numeric-comp,
defernumbers=true
]{biblatex}
\usepackage{hyperref}
\DeclareNameAlias{author}{default}
\DeclareNameAlias{editor}{default}
\DeclareNameAlias{translator}{default}
\DeclareFieldFormat{labelnumber}{\ifkeyword{own}{\mknumalph{#1}}{#1}}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{albert,
author = {Author, A.},
year = {2001},
title = {Alpha},
keywords = {own}
}
@misc{berta,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
@misc{cesar,
author = {Cuthor, C.},
year = {2003},
title = {Charlie},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
own pub: \cite{albert}
other: \cite{berta}
other: \cite{cesar}
\printbibliography[notkeyword=own]
\printbibliography[keyword=own,resetnumbers=true]
\end{document}