我正在尝试调整食谱两个或多个不同的书目。参考书目样式应该基本相同,但在单独的情况下,我想使用作者姓名的首字母,而不是拼写出来的名字。我想我不知道该写什么了defbibenvironment
。以下是我所取得的进展:
\documentclass[a4paper,10pt]{article}
\usepackage[pdftex,hidelinks]{hyperref}
\usepackage[lf]{venturis}
\usepackage[condensed]{roboto}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,natbib=true,citestyle=authoryear-ibid,isbn=false,maxnames=20,maxcitenames=3,bibstyle=authoryear,useprefix=true]{biblatex} % citereset=chapter,
\usepackage{hyperref}
%Append keywords to identify different bibliography entries.
\DeclareSourcemap{
\maps[datatype=bibtex,overwrite]{
\map{
\perdatasource{test1.bib}
\step[fieldset=KEYWORDS,fieldvalue=primary,append]
}
\map{
\perdatasource{test2.bib}
\step[fieldset=KEYWORDS,fieldvalue=secondary,append]
}
}
}
\defbibenvironment{bib2}
{\list
{}
{\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}
\begin{filecontents}{test1.bib}
@BOOK{key1,
author = {Lastfoo, Foo},
title = {Some Title},
address = {Somewhere},
publisher = {Some Publisher},
year = {2003},
}
@BOOK{key2,
author = {Lastfoo, Foo},
title = {Other Title},
address = {Somewhere},
publisher = {Some Publisher},
year = {2004},
}
\end{filecontents}
\begin{filecontents}{test2.bib}
@BOOK{key3,
author = {Lastbar, Bar and Lastbaz,Baz},
title = {Some Title},
address = {Somewhere},
publisher = {Some Publisher},
year = {2004},
}
@BOOK{key4,
author = {Lastbar, Bar and Lastbaz,Baz},
title = {Other Title},
address = {Somewhere},
publisher = {Some Publisher},
year = {2005},
}
\end{filecontents}
\addbibresource{test1.bib}
\addbibresource{test2.bib}
\begin{document}
\noindent
The main citations are \autocite[123]{key1} and \autocite{key2}.\\
The others are implicit. \nocite{key3}\nocite{key4}
\printbibliography[title=Refs1,keyword=primary]
\newrefcontext[sorting=none]
\printbibliography[title=Refs2,keyword=secondary,env=bib2,resetnumbers]
\end{document}
但我想打印“Ref2”
Lastbar,B.和B.Lastbaz(2004)......
或者,APA 格式
Lastbar,B.&Lastbaz,B.(2004)......
就像我使用选项一样giveninits
,biblatex
但仅适用于“Ref2”参考书目。
答案1
没有官方接口可以giveninits
在文档中间切换选项的值,但选项的实现非常简单。\toggletrue{abx@bool@giveninits}
当您想要获得与 相同的结果时,您可以直接说(对于giveninits=true
也类似)。\togglefalse{abx@bool@giveninits}
giveninits=false
\documentclass[a4paper,10pt]{article}
\usepackage[T1]{fontenc}
\usepackage[backend=biber,
style=authoryear-ibid,
maxnames=20, maxcitenames=3,
useprefix=true,
isbn=false,
]{biblatex}
\usepackage[hidelinks]{hyperref}
\DeclareSourcemap{
\maps[datatype=bibtex,overwrite]{
\map{
\perdatasource{test1.bib}
\step[fieldset=KEYWORDS,fieldvalue=primary,append]
}
\map{
\perdatasource{test2.bib}
\step[fieldset=KEYWORDS,fieldvalue=secondary,append]
}
}
}
\defbibenvironment{bib2}
{\list
{}
{\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}
\begin{filecontents}{test1.bib}
@BOOK{key1,
author = {Lastfoo, Foo},
title = {Some Title},
address = {Somewhere},
publisher = {Some Publisher},
year = {2003},
}
@BOOK{key2,
author = {Lastfoo, Foo},
title = {Other Title},
address = {Somewhere},
publisher = {Some Publisher},
year = {2004},
}
\end{filecontents}
\begin{filecontents}{test2.bib}
@BOOK{key3,
author = {Lastbar, Bar and Lastbaz,Baz},
title = {Some Title},
address = {Somewhere},
publisher = {Some Publisher},
year = {2004},
}
@BOOK{key4,
author = {Lastbar, Bar and Lastbaz,Baz},
title = {Other Title},
address = {Somewhere},
publisher = {Some Publisher},
year = {2005},
}
\end{filecontents}
\addbibresource{test1.bib}
\addbibresource{test2.bib}
\begin{document}
The main citations are \autocite[123]{key1} and \autocite{key2}.
The others are implicit. \nocite{key3}\nocite{key4}
\printbibliography[title=Refs1,keyword=primary]
\newrefcontext[sorting=none]
\toggletrue{abx@bool@giveninits}
\printbibliography[title=Refs2,keyword=secondary,env=bib2,resetnumbers]
\end{document}
由于一般不可能在文档中切换完整的参考书目样式,因此仅为第二个参考书目获取完整的 APA 样式(由 实现)biblatex-apa
会变得更加困难。style=apa