目前我的 LaTeX 中的 iob.bbx 文件如下所示:
\ProvidesFile{iob.bbx}[2021/02/24 v1.1z biblatex bibliography style]
%basis
\RequireBibliographyStyle{numeric-comp}
% New options
\newtoggle{bbx:articletitle}
\newtoggle{bbx:chaptertitle}
\newtoggle{bbx:pageranges}
\DeclareBibliographyOption{articletitle}[true]{%
\settoggle{bbx:articletitle}{#1}%
}
\DeclareBibliographyOption{chaptertitle}[true]{%
\settoggle{bbx:chaptertitle}{#1}%
}
\DeclareBibliographyOption{pageranges}[true]{%
\settoggle{bbx:pageranges}{#1}%
}
\DeclareBibliographyOption{biblabel}{%
\ifstrequal{#1}{plain}
{\DeclareFieldFormat{labelnumberwidth}{##1}}
{%
\ifstrequal{#1}{brackets}
{\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{##1}}}%
{%
\ifstrequal{#1}{dot}
{\DeclareFieldFormat{labelnumberwidth}{##1\adddot\midsentence}}
{\DeclareFieldFormat{labelnumberwidth}{\mkbibparens{##1}}}%
}%
}%
}
% Alter settings that carry through from biblatex
\ExecuteBibliographyOptions
{
date = year ,
doi = false ,
eprint = false ,
giveninits = true ,
isbn = false ,
maxnames = 15 ,
maxcitenames = 2 ,
pageranges = true ,
url = false ,
useprefix = true
}
%name bold and family-given
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{\mkbibquote{#1\isdot}}
% Modify the name format\name bold and family-given
{
\DeclareNameFormat{family-given-bold}{\mkbibbold{%
\renewcommand*{\multinamedelim}{\addsemicolon\addspace}%
\renewcommand*{\finalnamedelim}{\addcolon\addspace}%
{\usebibmacro{name:family-given}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffix}}
\usebibmacro{name:andothers}}}
\DeclareNameAlias{sortname}{family-given-bold}
\DeclareNameAlias{author}{family-given-bold}
\DeclareNameAlias{editor}{family-given-bold}
\DeclareNameAlias{translator}{family-given-bold}
% Custom field formats
\DeclareFieldFormat[article]{date}
\DeclareFieldFormat{doi}{%
DOI\addcolon\space
\ifhyperref
{\href{https://doi.org/#1}{\nolinkurl{#1}}}
{\nolinkurl{#1}}%
}
\DeclareFieldFormat{labelnumberwidth}{\mkbibparens{#1}}
\DeclareFieldFormat[article]{pages}{%
\iftoggle{bbx:pageranges}{#1}{\mkfirstpage{#1}}%
}
\DeclareFieldFormat*{title}{#1}
\DeclareFieldFormat[report]{title}
\DeclareFieldFormat[book, collection, inproceedings]{title}
\DeclareFieldFormat{url}{\url{#1}}
\DeclareFieldFormat[article]{volume}
% Simple modifications to punctuation, etc.
\renewcommand*{\begrelateddelim}{\addsemicolon\space}%
\renewcommand*{\finalnamedelim}{\addcolon\space}{%
\renewcommand*{\intitlepunct}{\addspace}
\renewcommand*{\labelnamepunct}{\addspace}
\renewcommand*{\newunitpunct}{\addcomma\addspace}
% Bibliography strings
\DefineBibliographyStrings{english}{%
chapter = Chapter ,
editor = Ed\adddot ,
editors = Eds\adddot ,
in = In ,
page = p ,
pages = pp ,
patentus = US Patent ,
phdthesis = Ph.D.\space Thesis ,
urlseen = accessed ,
volume = Vol\adddot
}
% Bibliography macros
\renewbibmacro*{byholder}{%
\ifnameundef{holder}
{}
{%
\printtext[parens]{\printnames{holder}}%
\adddot
}%
}
\renewbibmacro*{date}{%
\iffieldundef{year}
{}
{\printtext[date]{\printdate}}%
}
\renewbibmacro*{event+venue+date}{%
\printfield{eventtitle}%
\ifboolexpr{
test {\iffieldundef{venue}}
and
test {\iffieldundef{eventyear}}
}
{}
{%
\printfield{venue}%
\newunit
\printeventdate
\newunit
}%
}
\renewbibmacro*{journal+issuetitle}{%
\usebibmacro{journal}%
\setunit*{\addspace}%
\usebibmacro{date}%
\newunit
\usebibmacro{volume+number+eid}%
\newunit
}
\renewbibmacro*{maintitle+booktitle}{%
\iffieldundef{maintitle}
{}
{%
\usebibmacro{maintitle}%
\newunit\newblock
}%
\usebibmacro{booktitle}%
\newunit
}
\renewbibmacro*{maintitle+title}{%
\iffieldsequal{maintitle}{title}
{%
\clearfield{maintitle}%
\clearfield{mainsubtitle}%
\clearfield{maintitleaddon}%
}
{%
\iffieldundef{maintitle}
{}
{\usebibmacro{maintitle}}%
\newunit\newblock
}%
\usebibmacro{title}%
\newunit
}
\renewbibmacro*{note+pages}{%
\printfield{note}%
\setunit{\bibpagespunct}%
\printfield{pages}%
\iffieldundef{pages}
{%
\printfield{doi}%
\clearfield{doi}%
}%
{%
\iftoggle{bbx:doi}
{}
{\clearfield{doi}}%
}%
}
\renewbibmacro*{publisher+location+date}{%
\printlist{publisher}%
\iflistundef{publisher}
{\newunit}
{\setunit*{\addcolon\space}}%
\printlist{location}%
\setunit*{\addcomma\space}%
\usebibmacro{date}%
\newunit
}
\newbibmacro*{related:translatedas}[1]{%
\entrydata{#1}{%
\usebibmacro{journal+issuetitle}%
\newunit
\usebibmacro{byeditor+others}%
\newunit
\usebibmacro{note+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{issn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
}%
}
\renewbibmacro*{series+number}{%
\printfield{series}%
\setunit*{\addspace}%
\printfield{number}%
\newunit
\iffieldundef{series}
{}
{%
\printfield{volume}%
\clearfield{volume}%
\newunit
}%
}
\renewbibmacro*{volume+number+eid}{%
\printfield{volume}%
\setunit*{\addspace}%
\printfield{eid}%
}
% New bibliography drivers, using the required order of fields. These
% are mainly copied from standard.bbx then modified.
\DeclareBibliographyDriver{article}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\iftoggle{bbx:articletitle}
{%
\usebibmacro{title}%
\printunit{\adddot\addspace}%
}
{}%
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{bytranslator+others}%
\newunit\newblock
\printfield{version}%
\setunit{\addspace}%
\usebibmacro{journal+issuetitle}%
\newunit
\usebibmacro{byeditor+others}%
\newunit
\usebibmacro{note+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{issn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}%
}
\DeclareBibliographyDriver{book}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{maintitle+title}%
\newunit
\printfield{edition}%
\newunit
\printfield{volumes}%
\newunit\newblock
\usebibmacro{byauthor}%
\setunit{\addsemicolon\space}%
\usebibmacro{editor+others}%
\setunit{\addsemicolon\space}%
\usebibmacro{series+number}%
\newunit\newblock
\printfield{note}%
\setunit{\addsemicolon\space}%
\usebibmacro{publisher+location+date}%
\setunit{\addsemicolon\space}%
\printfield{volume}%
\setunit{\addsemicolon\space}%
\usebibmacro{chapter+pages}%
\setunit{\addsemicolon\space}%
\printfield{pagetotal}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}%
}
\DeclareBibliographyDriver{booklet}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{howpublished}%
\newunit\newblock
\printfield{type}%
\newunit\newblock
\printfield{note}%
\setunit{\addsemicolon\space}%
\usebibmacro{location+date}%
\setunit{\addsemicolon\space}%
\printfield{volume}%
\setunit{\addsemicolon\space}%
\usebibmacro{chapter+pages}%
\newunit
\printfield{pagetotal}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}%
}
\DeclareBibliographyDriver{collection}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{maintitle+title}%
\newunit
\printfield{edition}%
\newunit
\printfield{volumes}%
\newunit
\printlist{language}%
\setunit{\addsemicolon\space}%
\usebibmacro{editor+others}%
\newunit\newblock
\setunit{\addsemicolon\space}%
\usebibmacro{series+number}%
\newunit\newblock
\printfield{note}%
\setunit{\addsemicolon\space}%
\usebibmacro{publisher+location+date}%
\setunit{\addsemicolon\space}%
\printfield{volume}
\setunit{\addsemicolon\space}%
\usebibmacro{chapter+pages}%
\newunit
\printfield{pagetotal}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}%
}
\DeclareBibliographyDriver{inbook}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{byauthor}%
\newunit
\iftoggle{bbx:chaptertitle}
{\usebibmacro{title}}
{}%
\setunit{\addspace}%
\usebibmacro{in:}%
\usebibmacro{bybookauthor}%
\setunit{\addspace}%
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{editor+others}%
\newunit\newblock
\printfield{edition}%
\newunit
\printfield{volumes}%
\setunit{\addsemicolon\space}%
\usebibmacro{series+number}%
\newunit\newblock
\printfield{note}%
\setunit{\addsemicolon\space}%
\usebibmacro{publisher+location+date}%
\setunit{\addsemicolon\space}%
\printfield{colume}%
\setunit{\addsemicolon\space}%
\usebibmacro{chapter+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}%
}
\DeclareBibliographyDriver{incollection}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{byauthor}%
\newunit
\iftoggle{bbx:chaptertitle}
{\usebibmacro{title}}
{}%
\setunit{\addspace}%
\usebibmacro{in:}%
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{editor+others}%
\newunit\newblock
\printfield{edition}%
\newunit
\printfield{volumes}%
\setunit{\addsemicolon\space}%
\usebibmacro{series+number}%
\newunit\newblock
\printfield{note}%
\setunit{\addsemicolon\space}%
\usebibmacro{publisher+location+date}%
\setunit{\addsemicolon\space}%
\printfield{volume}%
\setunit{\addsemicolon\space}%
\usebibmacro{chapter+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}%
}
\DeclareBibliographyDriver{inproceedings}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{byauthor}%
\setunit{\addspace}%
\usebibmacro{in:}%
\usebibmacro{maintitle+booktitle}%
\newunit\newblock
\usebibmacro{event+venue+date}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{volumes}%
\setunit{\addsemicolon\space}%
\printfield{note}%
\newunit\newblock
\usebibmacro{publisher+location+date}%
\setunit{\addsemicolon\space}%
\printfield{volume}%
\setunit{\addsemicolon\space}%
\usebibmacro{chapter+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}%
}
\DeclareBibliographyDriver{manual}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor}%
\newunit\newblock
\printfield{edition}%
\newunit\newblock
\usebibmacro{series+number}%
\newunit\newblock
\printfield{type}%
\newunit
\printfield{version}%
\newunit
\printfield{note}%
\setunit{\addsemicolon\space}%
\printlist{organization}%
\newunit
\usebibmacro{publisher+location+date}%
\newunit\newblock
\usebibmacro{chapter+pages}%
\newunit
\printfield{pagetotal}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}%
}
\DeclareBibliographyDriver{online}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\printunit{\addspace}%
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{version}%
\newunit
\printfield{note}%
\newunit\newblock
\printlist{organization}%
\newunit\newblock
\iftoggle{bbx:eprint}
{\usebibmacro{eprint}}
{}%
\newunit\newblock
\usebibmacro{url+urldate}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}%
}
\DeclareBibliographyDriver{patent}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit{\addspace}%
\usebibmacro{byholder}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\usebibmacro{byauthor}%
\setunit{\addspace}%
\printfield{type}%
\newunit
\printfield{number}%
\iflistundef{location}
{}
{\setunit*{\addspace}%
\printtext[parens]{%
\printlist[][-\value{listtotal}]{location}}}%
\newunit\newblock
\newunit\newblock
\printfield{note}%
\newunit\newblock
\usebibmacro{date}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}%
}
\DeclareBibliographyDriver{report}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\usebibmacro{byauthor}%
\setunit{\addsemicolon\space}%
\printfield{type}%
\setunit*{\addspace}%
\printfield{number}%
\newunit\newblock
\printfield{version}%
\newunit
\printfield{note}%
\setunit{\addsemicolon\space}%
\usebibmacro{institution+location+date}%
\newunit\newblock
\usebibmacro{chapter+pages}%
\newunit
\printfield{pagetotal}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isrn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}%
}
我的 bibstyle 看起来像这样: (3)苏丹蒂,YA:Al-Shammari,NN工程杂志,67-80。
但它应该看起来像这样: [2] Alsultannty,YA;Al-Shammari,NN:空气分离装置的氧气比功耗比较,工程杂志 18 (2014),第 2 期,第 67–80 页
此外,尽管我在 main.tex 中写道:
\usepackage[
backend=biber,bibstyle=iob,
citestyle=numeric,
]{biblatex}
答案1
这种风格存在一些问题;其中之一是,定义的大多数函数都出现在条件构造中(在 if_then_else 结构内),我不清楚为什么需要这样的构造。
使用圆括号代替方括号:标签在 3 级 if_then_else 结构中定义
\DeclareBibliographyOption{biblabel}{%
\ifstrequal{#1}{plain}
{\DeclareFieldFormat{labelnumberwidth}{##1}}
{%
\ifstrequal{#1}{brackets}
{\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{##1}}}%
{%
\ifstrequal{#1}{dot}
{\DeclareFieldFormat{labelnumberwidth}{##1\adddot\midsentence}}
{\DeclareFieldFormat{labelnumberwidth}{\mkbibparens{##1}}}%
}%
}%
}
并且没有biblabel
调用任何选项。因此,3 个选项为假,最后一个选项else
适用。
文章标题也类似。切换按钮bbx:articletitle
未设置为 true。该命令将切换按钮的值设置为#1
not true。
\DeclareBibliographyOption{articletitle}[true]{%
\settoggle{bbx:articletitle}{#1}%
}
因此改变
\DeclareBibliographyOption{articletitle}[true]{%
\settoggle{bbx:articletitle}{true}%
}
此外,必须调用该选项(在 \ExecuteBibliopgraphyOptions
或在\usepackage[...]{biblatex}
)。
对于姓名之间的分隔符,\finalnamedelim
将分隔符设置在姓氏之前,而不是之后,一般用于指定是否使用“and”。
最后,原帖中有很多语法错误\DeclareFieldFormat
。该命令接受两个强制参数,即字段名称和如何呈现字段的说明。
字段格式说明的部分应如下所示:
\DeclareFieldFormat[article]{pages}{%
\bibstring{page}\iftoggle{bbx:pageranges}{#1}{\mkfirstpage{#1}}%
}
\DeclareFieldFormat*{title}{#1}
\DeclareFieldFormat[report]{title}{#1}
\DeclareFieldFormat[book,collection,inproceedings]{title}{#1}
\DeclareFieldFormat{url}{\url{#1}}
\DeclareFieldFormat[article]{volume}{\bibstring{volume}#1}
以及以下缩写/字符串部分
\DefineBibliographyStrings{english}{%
chapter = Chapter ,
editor = Ed\adddot ,
editors = Eds\adddot ,
in = In ,
page = S\adddot\addnbspace ,
pages = S\adddot\addnbspace ,
patentus = US Patent ,
phdthesis = Ph.D.\space Thesis ,
urlseen = accessed ,
volume = Nr\adddot\addnbspace
}
和
\usepackage[
backend=biber,bibstyle=iob,
citestyle=numeric,biblabel=brackets,articletitle
]{biblatex}