如何自动消除自定义参考书目样式中相同参考书目键的歧义?

如何自动消除自定义参考书目样式中相同参考书目键的歧义?

我正在尝试在 biblatex 中重现我的大学书目风格。

在参考书目中,每条条目前面都加一个括号内的标签,标签由机构或作者、年份和引用页码(可选)组成。当有两个条目的机构或作者相同且年份相同时,应使用连续的字母加上年份后缀,如下图所示:

大学模板

此时,生成书目的代码如下:

\defbibenvironment{bibliography}{%
  \list{%
    \printtext[parens]{%
      \printlist{institution}%
      \setunit*{\addcomma\addspace}%
      \printnames[author-label][-2]{author}%
      \setunit*{,\addspace}%
      \printfield{year}%
      \iffieldundef{thiscite}{}
        {\addcomma\space\printfield{thiscite}}%
    }%
    \enspace---\enspace%
  }{%
    \setlength{\labelwidth}{\labelnumberwidth}%
    \setlength{\leftmargin}{\labelwidth}%
    \setlength{\labelsep}{0pt}%
    \addtolength{\leftmargin}{\labelsep}%
    \setlength{\itemsep}{\bibitemsep}%
    \setlength{\parsep}{\bibparsep}}%
    \renewcommand*{\makelabel}[1]{\hss##1}
}{\endlist}{\item}

…结果如下:

书目环境插图

我只能在 biblatex 文档中找到部分片段,但没有具体的示例,因此我无法从中得出任何结论。

如何检查是否有两个具有相同机构/作者和年份的标签,并在年份后插入后缀?

平均能量损失

wsb.bbx

\ProvidesFile{wsb.bbx}[2020/01/11 WSB bibliography style]

\RequireBibliographyStyle{standard}

\DeclareDatamodelFields[type=field, datatype=range, skipout=false]{thiscite}
\DeclareFieldFormat{thiscite}{\mkpageprefix{#1}}

\def\printname{\usebibmacro{name:family}{\namepartfamily}{\namepartgiven}{\namepartprefix}{\namepartsuffix}}
\DeclareNameFormat{author-label}{%
  % If there are more than three names, print only the first one
  \ifmorenames%
    {\ifthenelse{\value{listcount}=1}
      {\printname{} \bibstring{andothers}}
      {}}
    {\printname{}}%
}

\DeclareNameFormat{author}{%
  \namepartfamily%
  \ifdefvoid{\namepartgiven}
    {}{\addcomma\space\namepartgiveni}%
  \ifthenelse{\value{listcount}=\value{liststop}}
    {}{\addcomma\space}%
  \usebibmacro{name:andothers}%
}

\defbibenvironment{bibliography}{%
  \list{%
    \printtext[parens]{%
      \printlist{institution}%
      \setunit*{\addcomma\addspace}%
      \printnames[author-label][-2]{author}%
      \setunit*{,\addspace}%
      \printfield{year}%
      \iffieldundef{thiscite}{}
        {\addcomma\space\printfield{thiscite}}%
    }%
    \enspace---\enspace%
  }{%
    \setlength{\labelwidth}{\labelnumberwidth}%
    \setlength{\leftmargin}{\labelwidth}%
    \setlength{\labelsep}{0pt}%
    \addtolength{\leftmargin}{\labelsep}%
    \setlength{\itemsep}{\bibitemsep}%
    \setlength{\parsep}{\bibparsep}}%
    \renewcommand*{\makelabel}[1]{\hss##1}
}{\endlist}{\item}

\newbibmacro*{institution+author+year}{%
  \printlist{institution}%
  \setunit*{\addcomma\addspace}%
  \printnames{author}%
  \setunit{,\addspace}%
  \printfield{year}%
}

\DeclareBibliographyDriver{report}{%
  \usebibmacro{institution+author+year}%
  \newunit\newblock%
  \printfield{title}%
  \setunit{\addcomma\addspace}%
  \iffieldundef{journaltitle}{}
    {\usebibmacro{in:}%
      \printfield{journaltitle}}%
  \setunit{\addcomma\addspace}%
  \printfield{number}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{url+urldate}%
  \setunit{\addcomma\addspace}%
  \printfield{pages}%
  \newunit\newblock%
\finentry}

mve.tex

\documentclass[]{article}

\usepackage[
    bibstyle=wsb,
    sortcites=true,
    sorting=nty,
]{biblatex}

\usepackage{filecontents}
\begin{filecontents*}{sample.bib}
@report{gus_2016,
    title = "Działalność innowacyjna przedsiębiorstw w~latach 2013-2016",
    institution = "GUS",
    url = "http://stat.gov.pl/obszary-tematyczne/nauka-i-technikaspoleczenstwo-informacyjne/nauka-i-technika/dzialanosc-innowacyjnaprzedsiebiorstw-w-latach-2013-2015,2,14.html",
    urldate = "2017-07-18",
    thiscite = "3",
    year = 2016,
}

@report{gus_2016a,
    title = "Badanie organizacji i~rozkładu czasu pracy w~Polsce w~2015 roku",
    institution = "GUS",
    url = "http://stat.gov.pl/obszary-tematyczne/rynekpracy/opracowania/badanie-organizacji-i-rozkladu-czasu-pracy-wpolsce-w-2015-r-,12,1.html",
    urldate = "2017-07-18",
    thiscite = "38",
    year = 2016,
}
\end{filecontents*}
\addbibresource{sample.bib}

\begin{document}
Citation number one \cite{gus_2016}.

Citation number two \cite{gus_2016a}.

\printbibliography{}
\end{document}

答案1

我建议您以authoryear或其衍生品之一为基础来设计您的风格。biblatex(或者更确切地说是 Biber/BibTeX)自动计算作者/编辑年份组合的唯一性信息,并使其在现场可用(使用、和朋友extradate自动打印)。\printlabeldateextra\printdateextra

然后,可以像在我的样式中一样实现参考书目中的重复引用biblatex-extintrocite=plain,功能)。这样就可以删除一些现在未使用的宏。

风格上也有一些小的变化

  • 确保所有参考书目驱动程序都以 开头\usebibmacro{bibindex}\usebibmacro{begentry}和结尾是一种很好的做法\usebibmacro{finentry}
  • 数据模型命令需要放在单独的.dbx文件中。

GUS最后,我将示例条目中的字段从 改为institutionauthorauthoreditor功能角色,因此如果作者是机构,则没有理由不将其包括在那里。institutionorganization字段的作用与 字段相似publisher。 也比较一下如果没有作者使用组织或机构

总计(使用.bbxinline生成的文件.cbx,使示例自成一体).dbxfilecontents

\documentclass[polish]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\begin{filecontents}{wsb.bbx}
\ProvidesFile{wsb.bbx}[2020/01/24 WSB bibliography style]

\RequireBibliographyStyle{authortitle}

\DeclareFieldFormat{thiscite}{\mkpageprefix{#1}}

\newbibmacro*{bbx:introcite}{\usebibmacro{cite}}

\newcommand*{\extblx@introcite@init}{%
  \iftoggle{blx@citation}
    {}
    {\togglefalse{blx@bibliography}%
     \toggletrue{blx@citation}}%
  \delimcontext{bbx@introcite}%
  \csuse{blx@hook@cite}%
  \csuse{blx@hook@citekey}%
  \DeclareFieldFormat{bibhyperref}{##1}%
  \undef\cbx@lasthash
  \undef\cbx@lastyear
  \citetrackerfalse\pagetrackerfalse\backtrackerfalse
  \defcounter{maxnames}{\blx@maxcitenames}%
  \defcounter{minnames}{\blx@mincitenames}%
}

\newbibmacro{introcite:typeset}{%
  \begingroup
    \extblx@introcite@init
    \printtext[bbx@introcite]{\usebibmacro{bbx:introcite}}%
  \endgroup
}

\newbibmacro{introcite:plain}{%
  \usebibmacro{introcite:typeset}%
  \printunit*{\introcitepunct}}

\DeclareFieldFormat{bbx@introcite}{\mkbibparens{#1}}
\newcommand*{\introcitepunct}{\enspace---\enspace}%

\renewbibmacro{begentry}{%
  \usebibmacro{introcite:plain}}


\newbibmacro*{institution+author+year}{%
  \printlist{institution}%
  \setunit*{\addcomma\space}%
  \printnames{author}%
  \setunit{\addcomma\space}%
  \printdate
}

\DeclareBibliographyDriver{report}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{institution+author+year}%
  \newunit\newblock%
  \printfield{title}%
  \setunit{\addcomma\addspace}%
  \iffieldundef{journaltitle}
    {}
    {\usebibmacro{in:}%
      \printfield{journaltitle}}%
  \setunit{\addcomma\addspace}%
  \printfield{number}%
  \setunit{\addcomma\addspace}%
  \usebibmacro{url+urldate}%
  \setunit{\addcomma\addspace}%
  \printfield{pages}%
  \newunit\newblock%
  \usebibmacro{finentry}}

\endinput
\end{filecontents}

\begin{filecontents}{wsb.cbx}
\ProvidesFile{wsb.cbx}[2020/01/24 WSB citation style]

\RequireCitationStyle{authoryear}

\ExecuteBibliographyOptions{autocite=inline}

\DeclareDelimFormat{nameyeardelim}{\addcomma\space}

\endinput
\end{filecontents}

\begin{filecontents}{wsb.dbx}
\ProvidesFile{wsb.dbx}[2020/01/24 WSB bib/cite style data model]

\DeclareDatamodelFields[type=field, datatype=range, skipout=false]{thiscite}

\DeclareDatamodelEntryfields{thiscite}

\endinput
\end{filecontents}

\usepackage[
  style=wsb,
  sortcites=true,
]{biblatex}

\begin{filecontents*}{\jobname.bib}
@report{gus_2016,
  title       = {Działalność innowacyjna przedsiębiorstw w~latach 2013-2016},
  author      = {GUS},
  url         = {http://stat.gov.pl/obszary-tematyczne/nauka-i-technikaspoleczenstwo-informacyjne/nauka-i-technika/dzialanosc-innowacyjnaprzedsiebiorstw-w-latach-2013-2015,2,14.html},
  urldate     = {2017-07-18},
  thiscite    = {3},
  year        = 2016,
}
@report{gus_2016a,
  title       = {Badanie organizacji i~rozkładu czasu pracy w~Polsce w~2015 roku},
  author      = {GUS},
  url         = {http://stat.gov.pl/obszary-tematyczne/rynekpracy/opracowania/badanie-organizacji-i-rozkladu-czasu-pracy-wpolsce-w-2015-r-,12,1.html},
  urldate     = {2017-07-18},
  thiscite    = {38},
  year        = 2016,
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
Citation number one \autocite{gus_2016}.

Citation number two \autocite{gus_2016a}.

\printbibliography
\end{document}

(GUS,2016a)— GUS,2016。2015 年以来波兰的组织和人口普查实践,网址:http://stat.gov.pl/obszary-tematyczne/rynekpracy/opracowania/badanie-organizacji-i-rozkladu-czasu-pracy-wpolsce-w-2015-r-,12,1.html(截止日期:2017 年 7 月 18 日)。//(GUS,2016b)— GUS,2016。2013-2016 年波兰的创新实践,网址: http://stat.gov.pl/obszary-tematyczne/nauka-i-technikaspoleczenstwo-informacyjne/nauka-i-technika/dzialanosc-innowacyjnaprzedsiebiorstw-w-latach-2013-2015,2,14.html(截止日期:2017 年 7 月 18 日)。

相关内容