由于一些大学的要求,我重新定义了biblatex
citesytle
authoryear 以使用方括号代替圆括号。现在我正尝试对 实现相同的效果bibstyle
。
我的方法是重新定义原始样式文件authoryear.bbx
。这对 来说很有效citestyle
,但我在这里就不再重复了,因为样式的工作方式非常不同。
阅读手册 [ 1 ] 后,我发现使用命令 可以在字段周围加上(圆括号)\printtext[parens]{....}
。此处,字段parens
定义为\DeclareFieldFormat{parens}{\mkbibparens{#1}}
[1, p. 268]。与此类似,我尝试定义一个新字段,bracks
如下所示:(\DeclareFieldFormat{bracks}{\mkbibbrackets{#1}}
参见 [1, p. 250])。
parens
我的方法现在是用关联样式文件中的任何位置替换该字段bracks
,请参阅下面的 MWE:
\documentclass{scrartcl}
\usepackage{filecontents}
\begin{filecontents*}{authoryearbrak.bbx}
\ProvidesFile{authoryearbrak.bbx}
[\abx@bbxid]
% authoryear styles are special in the following way:
% The citation labels are "labelname (labelyear)" and since citation
% labels are the keys into the references section, the fact that the
% citation uses labelyear means that the references must also. This
% means we use a special \printdate[extra]label macro to generate the
% references section main date for an entry. Otherwise, if labeldate selects
% anything other than DATE (or equivalently, YEAR/MONTH), then the
% citation won't match the reference.
% Addition!
% Add new field for square brackets
\DeclareFieldFormat{bracks}{\mkbibbrackets{#1}}
\RequireBibliographyStyle{standard}
\DeclareBibliographyOption{dashed}[true]{%
\ifstrequal{#1}{true}
{\ExecuteBibliographyOptions{pagetracker}%
\renewbibmacro*{bbx:savehash}{\savefield{fullhash}{\bbx@lasthash}}}
{\renewbibmacro*{bbx:savehash}{}}}
\DeclareBibliographyOption{mergedate}[true]{%
\ifcsdef{bbx@opt@mergedate@#1}
{\csuse{bbx@opt@mergedate@#1}}
{\PackageError{biblatex}
{Invalid option 'mergedate=#1'}
{Valid values are 'maximum', 'compact', 'basic', 'minimum',\MessageBreak
'true' (=compact), and 'false'.}}}
\providebibmacro*{date+extrayear}{}
\def\bbx@opt@mergedate@true{\bbx@opt@mergedate@compact}
\def\bbx@opt@mergedate@maximum{%
\renewbibmacro*{date+extrayear}{%
\iffieldundef{labelyear}
{}
{\printtext[bracks]{%
\printfield{issue}%
\setunit*{\addspace}%
\printdateextralabel}}}%
\renewbibmacro*{date}{}%
\renewbibmacro*{issue+date}{}%
}
\def\bbx@opt@mergedate@compact{%
\renewbibmacro*{date+extrayear}{%
\iffieldundef{labelyear}
{}
{\printtext[s]{\printdateextralabel}}}%
\renewbibmacro*{date}{}%
\renewbibmacro*{issue+date}{%
\iffieldundef{issue}
{}
{\printtext[bracks]{\printfield{issue}}}%
\newunit}%
}
\def\bbx@opt@mergedate@basic{%
\renewbibmacro*{date+extrayear}{%
\iffieldundef{labelyear}
{}
{\printtext[bracks]{%
\printfield{labelyear}%
\printfield{extrayear}}}}%
\renewbibmacro*{date}{%
\iffieldundef{month}
{}
{\printdate}}%
\renewbibmacro*{issue+date}{%
\ifboolexpr{
test {\iffieldundef{issue}}
and
test {\iffieldundef{month}}
}
{}
{\printtext[bracks]{%
\printfield{issue}%
\setunit*{\addspace}%
\printdate}}%
\newunit}%
}
\def\bbx@opt@mergedate@minimum{%
\renewbibmacro*{date+extrayear}{%
\iffieldundef{labelyear}
{}
{\printtext[bracks]{%
\printfield{labelyear}%
\printfield{extrayear}}}}%
\renewbibmacro*{date}{%
\ifboolexpr{
test {\iffieldundef{month}}
and
test {\iffieldundef{extrayear}}
}
{}
{\printdate}}%
\renewbibmacro*{issue+date}{%
\ifboolexpr{
test {\iffieldundef{issue}}
and
test {\iffieldundef{month}}
and
test {\iffieldundef{extrayear}}
}
{}
{\printtext[bracks]{%
\printfield{issue}%
\setunit*{\addspace}%
\printdate}}%
\newunit}%
}
\def\bbx@opt@mergedate@false{%
\renewbibmacro*{date+extrayear}{%
\iffieldundef{labelyear}
{}
{\printtext[bracks]{%
\printfield{labelyear}%
\printfield{extrayear}}}}%
\renewbibmacro*{date}{\printdate}%
\renewbibmacro*{issue+date}{%
\printtext[bracks]{%
\printfield{issue}%
\setunit*{\addspace}%
\printdate}%
\newunit}%
}
\ExecuteBibliographyOptions{labeldate,sorting=nyt,pagetracker,mergedate}
\DeclareFieldFormat{shorthandwidth}{#1}
\setlength{\bibitemsep}{0pt}
\DeclareNameAlias{author}{sortname}
\DeclareNameAlias{editor}{sortname}
\DeclareNameAlias{translator}{sortname}
\defbibenvironment{bibliography}
{\list
{}
{\setlength{\leftmargin}{\bibhang}%
\setlength{\itemindent}{-\leftmargin}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}}
{\endlist}
{\item}
\defbibenvironment{shorthands}
{\list
{\printfield[shorthandwidth]{shorthand}}
{\setlength{\labelwidth}{\shorthandwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}%
\renewcommand*{\makelabel}[1]{##1\hss}}}
{\endlist}
{\item}
\InitializeBibliographyStyle{%
\global\undef\bbx@lasthash}
\newbibmacro*{bbx:savehash}{%
\savefield{fullhash}{\bbx@lasthash}}
\newbool{bbx@inset}
\DeclareBibliographyDriver{set}{%
\booltrue{bbx@inset}%
\entryset{}{}%
\newunit\newblock
\usebibmacro{setpageref}%
\finentry}
\renewbibmacro*{author}{%
\ifboolexpr{
test \ifuseauthor
and
not test {\ifnameundef{author}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\usebibmacro{bbx:savehash}%
\printnames{author}%
\iffieldundef{authortype}
{\setunit{\addspace}}
{\setunit{\addcomma\space}}}%
\iffieldundef{authortype}
{}
{\usebibmacro{authorstrg}%
\setunit{\addspace}}}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\setunit*{\addspace}}%
\usebibmacro{date+extrayear}}
\renewbibmacro*{editor}{%
\usebibmacro{bbx:editor}{editorstrg}}
\renewbibmacro*{editor+others}{%
\usebibmacro{bbx:editor}{editor+othersstrg}}
\newbibmacro*{bbx:editor}[1]{%
\ifboolexpr{
test \ifuseeditor
and
not test {\ifnameundef{editor}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\printnames{editor}%
\setunit{\addcomma\space}%
\usebibmacro{bbx:savehash}}%
\usebibmacro{#1}%
\clearname{editor}%
\setunit{\addspace}}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\setunit*{\addspace}}%
\usebibmacro{date+extrayear}}
\renewbibmacro*{translator}{%
\usebibmacro{bbx:translator}{translatorstrg}}
\renewbibmacro*{translator+others}{%
\usebibmacro{bbx:translator}{translator+othersstrg}}
\newbibmacro*{bbx:translator}[1]{%
\ifboolexpr{
test \ifusetranslator
and
not test {\ifnameundef{translator}}
}
{\usebibmacro{bbx:dashcheck}
{\bibnamedash}
{\printnames{translator}%
\setunit{\addcomma\space}%
\usebibmacro{bbx:savehash}}%
\usebibmacro{translator+othersstrg}%
\clearname{translator}%
\setunit{\addspace}}%
{\global\undef\bbx@lasthash
\usebibmacro{labeltitle}%
\setunit*{\addspace}}%
\usebibmacro{date+extrayear}}
\newbibmacro*{bbx:dashcheck}[2]{%
\ifboolexpr{
test {\iffieldequals{fullhash}{\bbx@lasthash}}
and
not test \iffirstonpage
and
(
not bool {bbx@inset}
or
test {\iffieldequalstr{entrysetcount}{1}}
)
}
{#1}
{#2}}
\newbibmacro*{labeltitle}{%
\iffieldundef{label}
{\iffieldundef{shorttitle}
{\printfield{title}%
\clearfield{title}}
{\printfield[title]{shorttitle}}}
{\printfield{label}}}
\endinput
\end{filecontents*}
\begin{filecontents*}{bibliography.bib}
@BOOK{Cornelisse1979,
author = {Cornelisse, J. W. and Schöyer, H. Ferry R. and Wakker, Karel F.},
title = {Rocket Propulsion and Spaceflight Dynamics},
year = {1979},
publisher = {Pitman},
}
\end{filecontents*}
\usepackage[bibstyle=authoryearbrak, citestyle=authoryear,%
backend=biber,]{biblatex}
\addbibresource{bibliography.bib}
\begin{document}
\autocite{Cornelisse1979}
\printbibliography
\end{document}
遗憾的是,这不起作用,如下面的屏幕截图所示:
括号完全缺失。应该写成 [1979]。默认authoryear
样式应该写成 (1979)。
这是哪里出了问题?我该如何修复这个问题,才能在年份周围使用方括号而不是圆括号?
[ 1 ] —http://archive.cs.uu.nl/mirror/CTAN/macros/latex/contrib/biblatex/doc/biblatex.pdf
方括号的理由:括号通常表示小的添加或事后想法。然而,引用则完全不同,因此值得用特殊符号表示。这也与有时使用的纯编号样式一致,例如 [23] 表示参考文献 23。
答案1
已经存在为方括号定义的字段格式 - 它被称为brackets
。
在authoryear
样式中,year
标签部分由宏创建\printdateextralabel
。在您的中authoryearbrak
,您有一个错误的[s]
格式\printdatextralabel
(第 59 行)。将其替换[brackets]
为
Cornelisse, JW、H. Ferry R. Schoeyer 和 Karel F. Wakker [1979 年]。火箭推进和航天动力学. 皮特曼。
这回答了问题吗?