如何以作者日期 biblatex 样式压缩 2001a-n 年份?

如何以作者日期 biblatex 样式压缩 2001a-n 年份?

是否可以配置 biblatex-chicago 将“Karasti et al. 2016a, 2016b, 2016c, 2016d”这样的案例压缩为“Karasti et al. 2016a-d”?如果可以,怎么做?

四个条目均具有相同的作者/年份组合,但实际上是不同的出版物。

如果有必要,我很乐意提供 MWE。

答案1

事实证明,这比我最初想象的要复杂一些。可以按照authoryear-comp如下所示的标准样式进行整理,但我对 有点怀疑biblatex-chicago

自 0.5 版本起biblatex-ext包括样式ext-authoryear-ecomp和基于此处提供的代码的列表ext-authoryear-iecomp的本机压缩。请参阅提交extradateGitHub 上的 e1c4116

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

\usepackage[style=ext-authoryear-ecomp, backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}

\usepackage{hyperref}


\begin{document}
\cite{sigfridsson}

\cite{knuth:ct:b,knuth:ct:c,knuth:ct:d,knuth:ct:e}

\printbibliography
\end{document}

解决方案与此类似numeric-comp。主要问题是biblatex通常不知道下一个条目是什么,因为引用列表中的项目是逐个处理的,对整个列表知之甚少。因此,处理引用列表并决定是否跳过特定引用(因为它恰好是b交流电

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

\usepackage[style=authoryear-comp, backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}

\usepackage{hyperref}

\makeatletter
\newcounter{cbx@extradatecount}

\renewbibmacro*{cite:init}{%
  \ifnumless{\value{multicitecount}}{2}
    {\global\boolfalse{cbx:parens}%
     \global\undef\cbx@lastkey
     \global\undef\cbx@lasthash
     \global\undef\cbx@lastyear
     \global\undef\cbx@lastextradate
     \setcounter{cbx@extradatecount}{0}}
    {\iffieldundef{prenote}
       {}
       {\global\undef\cbx@lastkey
        \global\undef\cbx@lasthash
        \global\undef\cbx@lastyear
        \global\undef\cbx@lastextradate
        \setcounter{cbx@extradatecount}{0}}}}

\renewbibmacro*{cite:reinit}{%
  \global\undef\cbx@lastkey
  \global\undef\cbx@lasthash
  \global\undef\cbx@lastyear
  \global\undef\cbx@lastextradate
  \setcounter{cbx@extradatecount}{0}}

\newcommand*{\extradateonlycompcitedelim}{\addcomma}
\newcommand*{\extradateonlycompciterangedelim}{\bibrangedash}


\newbibmacro*{generic:dump:extradate}{%
  \ifundef\cbx@lastkey
    {}
    {\entrydata{\cbx@lastkey}
       {\ifnumless{\value{cbx@extradatecount}}{1}
          {\blx@warning{% This should not happen, so warn when it does
             Uh-oh!
             The extradate compression is quite likely\MessageBreak
             wrong for \cbx@lastkey}}%
          {}%
        \ifnumgreater{\value{cbx@extradatecount}}{1}
          {\setunit{\extradateonlycompciterangedelim}}
          {\setunit{\extradateonlycompcitedelim}}%
        \usebibmacro{cite:extradate}}%
     \setunit{\cbx@thiscitedelim}}%
  \global\undef\cbx@lastkey
  \setcounter{cbx@extradatecount}{0}%
}

\newbibmacro*{cite:dump:extradate}{%
  \def\cbx@thiscitedelim{\multicitedelim}%
  \usebibmacro{generic:dump:extradate}}

\newbibmacro*{textcite:dump:extradate}{%
  \def\cbx@thiscitedelim{%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}%
    \textcitedelim}%
  \usebibmacro{generic:dump:extradate}}

\newbibmacro*{cite:comp:extradate}{%
  \ifnumequal{\cbx@lastextradate+1}{\thefield{extradate}}
    {\stepcounter{cbx@extradatecount}%
     \savefield{entrykey}{\cbx@lastkey}}
    {\usebibmacro{cite:dump:extradate}%
     \setunit{\extradateonlycompcitedelim}%
     \usebibmacro{cite:extradate}}%
  \savefield{extradate}{\cbx@lastextradate}%
}

\renewbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:dump:extradate}%
        \usebibmacro{cite:label}%
        \setunit{\printdelim{nonameyeardelim}}%
        \usebibmacro{cite:labeldate+extradate}%
        \usebibmacro{cite:reinit}}
       {\iffieldequals{namehash}{\cbx@lasthash}
          {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                       \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
             {\usebibmacro{cite:comp:extradate}}
             {\usebibmacro{cite:dump:extradate}%
              \setunit{\compcitedelim}%
              \usebibmacro{cite:labeldate+extradate}%
              \savefield{labelyear}{\cbx@lastyear}%
              \savefield{extradate}{\cbx@lastextradate}%
              \setcounter{cbx@extradatecount}{0}}}}
          {\usebibmacro{cite:dump:extradate}%
           \printnames{labelname}%
           \setunit{\printdelim{nameyeardelim}}%
           \usebibmacro{cite:labeldate+extradate}%
           \savefield{namehash}{\cbx@lasthash}%
           \savefield{labelyear}{\cbx@lastyear}%
           \savefield{extradate}{\cbx@lastextradate}%
           \setcounter{cbx@extradatecount}{0}}}
    {\usebibmacro{cite:dump:extradate}%
     \usebibmacro{cite:shorthand}%
     \usebibmacro{cite:reinit}}%
  \setunit{\multicitedelim}}

\renewbibmacro*{textcite}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\iffieldundef{shorthand}
       {\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
                    \(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
          {\usebibmacro{cite:comp:extradate}}
          {\usebibmacro{textcite:dump:extradate}%
           \setunit{\compcitedelim}%
           \usebibmacro{cite:labeldate+extradate}%
           \savefield{labelyear}{\cbx@lastyear}%
           \savefield{extradate}{\cbx@lastextradate}%
           \setcounter{cbx@extradatecount}{0}}}
       {\usebibmacro{textcite:dump:extradate}%
        \setunit{\compcitedelim}%
        \usebibmacro{cite:shorthand}%
        \global\undef\cbx@lastyear}}
    {\usebibmacro{textcite:dump:extradate}%
     \ifnameundef{labelname}
       {\iffieldundef{shorthand}
          {\usebibmacro{cite:label}%
           \setunit{%
             \global\booltrue{cbx:parens}%
             \printdelim{nonameyeardelim}\bibopenparen}%
           \ifnumequal{\value{citecount}}{1}
             {\usebibmacro{prenote}}
             {}%
           \usebibmacro{cite:labeldate+extradate}}
          {\usebibmacro{cite:shorthand}}}
       {\printnames{labelname}%
        \setunit{%
          \global\booltrue{cbx:parens}%
          \printdelim{nameyeardelim}\bibopenparen}%
        \ifnumequal{\value{citecount}}{1}
          {\usebibmacro{prenote}}
          {}%
        \iffieldundef{shorthand}
          {\iffieldundef{labelyear}
             {\usebibmacro{cite:label}}
             {\usebibmacro{cite:labeldate+extradate}}%
           \savefield{labelyear}{\cbx@lastyear}%
           \savefield{extradate}{\cbx@lastextradate}%
           \setcounter{cbx@extradatecount}{0}}
          {\usebibmacro{cite:shorthand}%
           \global\undef\cbx@lastyear}}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}%
    \textcitedelim}}

\DeclareCiteCommand{\cite}
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:dump:extradate}%
   \usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {}
  {\usebibmacro{cite:dump:extradate}%
   \usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:dump:extradate}%
   \usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibparens]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {}
  {\usebibmacro{cite:dump:extradate}%
   \usebibmacro{postnote}}

\DeclareCiteCommand{\footcite}[\mkbibfootnote]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:dump:extradate}%
   \usebibmacro{postnote}}

\DeclareCiteCommand{\footcitetext}[\mkbibfootnotetext]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:dump:extradate}%
   \usebibmacro{postnote}}

\DeclareCiteCommand{\smartcite}[\iffootnote\mkbibparens\mkbibfootnote]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{cite:dump:extradate}%
   \usebibmacro{postnote}}

\DeclareCiteCommand{\cbx@textcite}
  {\usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {}
  {\usebibmacro{textcite:dump:extradate}%
   \usebibmacro{textcite:postnote}}
\makeatother


\begin{document}
\cite{sigfridsson}

\cite{knuth:ct:b,knuth:ct:c,knuth:ct:d,knuth:ct:e}

\cite{knuth:ct:b,knuth:ct:c,knuth:ct:d}

\cite{knuth:ct:b,knuth:ct:c,knuth:ct:e}

\cite{knuth:ct:b,knuth:ct:d,knuth:ct:e}

\cite{knuth:ct:c,knuth:ct:d,knuth:ct:e}

\cite{knuth:ct:a,knuth:ct:b,knuth:ct:c}


\cite{aksin,knuth:ct:b,knuth:ct:c,knuth:ct:d,knuth:ct:e,sigfridsson}

\cite{aksin,knuth:ct:b,knuth:ct:c,knuth:ct:d,sigfridsson}

\cite{aksin,knuth:ct:b,knuth:ct:c,knuth:ct:e,sigfridsson}

\cite{aksin,knuth:ct:b,knuth:ct:d,knuth:ct:e,sigfridsson}

\cite{aksin,knuth:ct:c,knuth:ct:d,knuth:ct:e,sigfridsson}

\cite{aksin,knuth:ct:a,knuth:ct:b,knuth:ct:c,sigfridsson}

\textcite{sigfridsson}

\textcite{knuth:ct:b,knuth:ct:c,knuth:ct:d,knuth:ct:e}

\textcite{knuth:ct:b,knuth:ct:c,knuth:ct:d}

\textcite{knuth:ct:b,knuth:ct:c,knuth:ct:e}

\textcite{knuth:ct:b,knuth:ct:d,knuth:ct:e}

\textcite{knuth:ct:c,knuth:ct:d,knuth:ct:e}

\textcite{knuth:ct:a,knuth:ct:b,knuth:ct:c}


\textcite{aksin,knuth:ct:b,knuth:ct:c,knuth:ct:d,knuth:ct:e,sigfridsson}

\textcite{aksin,knuth:ct:b,knuth:ct:c,knuth:ct:d,sigfridsson}

\textcite{aksin,knuth:ct:b,knuth:ct:c,knuth:ct:e,sigfridsson}

\textcite{aksin,knuth:ct:b,knuth:ct:d,knuth:ct:e,sigfridsson}

\textcite{aksin,knuth:ct:c,knuth:ct:d,knuth:ct:e,sigfridsson}

\textcite{aksin,knuth:ct:a,knuth:ct:b,knuth:ct:c,sigfridsson}

\textcite{aksin,knuth:ct:b,knuth:ct:c,knuth:ct:d,knuth:ct:e,sigfridsson,worman}

\textcite{aksin,knuth:ct:b,knuth:ct:c,knuth:ct:d,sigfridsson,worman}

\textcite{aksin,knuth:ct:b,knuth:ct:c,knuth:ct:e,sigfridsson,worman}

\textcite{aksin,knuth:ct:b,knuth:ct:d,knuth:ct:e,sigfridsson,worman}

\textcite{aksin,knuth:ct:c,knuth:ct:d,knuth:ct:e,sigfridsson,worman}

\textcite{aksin,knuth:ct:a,knuth:ct:b,knuth:ct:c,sigfridsson,worman}

\printbibliography
\end{document}

在此处输入图片描述

我甚至不想开始为 做这件事biblatex-chicago。其风格比已经很棘手的 复杂得多authoryear-compbiblatex-chicago的日期引用代码比整个代码更长,并且authoryear-comp.cbx的代码也大致一样长。此外,CMS 的引用格式甚至不会省略同一年的引用年份,这种处理方式在概念层面上也使其变得复杂。citetextciteorigyear

相关内容