我正在创建一个包含两个不同参考书目的文档,这两个参考书目必须采用不同的格式。我发现 lockstep 对问题 10104 的回答非常出色(同一文档中存在两种不同风格的书目),并且我已经在使用它了。
我已经为主书目加载了作者年份书目样式。但第二个书目必须采用标题在作者姓名之前的格式。
关于如何实现这一点有什么建议吗?
答案1
我还没有对此进行详尽的测试,并且它可能不适用于一些@inbook
带有booktitle
或其他类似附加功能的疯狂标题。
基本上,我添加了一个标志,用于检查我们在参考书目中是否希望首先显示标题。然后,对于这些bibitems
,我们bibmacro
在条目开头添加一个新标题,并清除原始标题bibmacro
。对于具有额外标题字段的其他项目,您可能还必须清除其他字段,具体取决于您希望它如何工作。(例如,某些条目类型不使用\usebibmacro{title}
,但使用\usebibmacro{maintitle+title}
;这没有考虑到这一点。)
我添加了一些额外的条目来演示用法。
代码
\documentclass{article}
\usepackage{biblatex}
\usepackage{etoolbox} % For boolean flags
\DeclareBibliographyCategory{cited}
\AtEveryCitekey{\addtocategory{cited}{\thefield{entrykey}}}
% Boolean flags to detect environment
\newbool{titlefirst}
% The following definition is copied from authortitle.bbx/authoryear.bbx
\defbibenvironment{nolabelbib}
{\booltrue{titlefirst}\list
{}
{\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist\boolfalse{titlefirst}}
{\item}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{B02,
author = {Buthor, B.},
year = {2002},
title = {Bravo},
}
@misc{C03,
author = {Cuthor, C.},
year = {2003},
title = {Charlie},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\nocite{C03,companion,worman,piccato,aristotle:physics}
% Enable sort by title
\DeclareSortingScheme{titleauthor}{
\sort{\field{sorttitle}\field{title}}
\sort{\field{author}\field{editor}\field{translator}}}
% Redefine titlefirst to be the same as the original title from biblatex.def
\newbibmacro*{titlefirst}{%
\ifboolexpr{
test {\iffieldundef{title}}
and
test {\iffieldundef{subtitle}}
}
{}
{\printtext[title]{%
\printfield[titlecase]{title}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{subtitle}}%
\newunit}%
\printfield{titleaddon}}
% Each bibitem, check if we're in titlefirst env
% If so, put a title at the beginning, clear original title bibmacro
\AtEveryBibitem{
\ifbool{titlefirst}{
\renewbibmacro*{begentry}{\usebibmacro{titlefirst}\newunit}
\renewbibmacro*{title}{} % Clear original title bibmacro
}
}
\begin{document}
\noindent Some text \autocite{A01,B02}.
\printbibliography[title={References},category=cited]
\printbibliography[env=nolabelbib,sorting=titleauthor,title={Further Reading},notcategory=cited]
% Print the first bibliography again to be sure we haven't ruined
% Something permanantly
\printbibliography[title={References},category=cited]
\end{document}