在 biblatex 中缩写显示作者 + 年份,不超过 1 行

在 biblatex 中缩写显示作者 + 年份,不超过 1 行

我正在为我的论文设置biblatex,并且知道只需将显示的作者限制为参考书目中的某个值(例如\maxbibnames=5& \minbibnames=5)。但是,我想实现包括(年份)在内的作者行限制为 number=X(假设显示 5 位作者),但也不能超过第一行。因此,如果“作者包括(年份)”在文档中需要超过 1 行,biblatex 只需删除比最初用\maxbibnames/定义的更多的 bibname \minbibnames(但当然仅限于此条目)。

例如:

爱因斯坦,A.、特斯拉,N.、琼斯,I.、杰斐逊,T. 和胡德,R.

等(1980 年)。真是一篇好论文。自然 1:100-150。

缩写新示例:

爱因斯坦,A.、特斯拉,N.、琼斯,I. 和杰斐逊,T. 等人 (1980 年)。

真是一篇好论文。自然 1:100-150。

答案1

以下代码只是倒数名称的数量并检查它们是否适合一行。

宏的原始定义取自authoryear.bbx,我们只添加了一个倒计时和测量输出长度的薄包装器。

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=authoryear, maxbibnames=999, dashed=false]{biblatex}
\usepackage{hyperref}

\addbibresource{biblatex-examples.bib}

\makeatletter
\newcounter{namecountdown}
\newlength{\bbx@namelength}
\newbibmacro*{bbx:measure:outer}[2]{%
  \settowidth{\bbx@namelength}{\usebibmacro*{#1}{#2}}%
  \ifboolexpr{test {\ifdimgreater{\bbx@namelength}{\linewidth}}
              and test {\ifnumgreater{\value{namecountdown}}{1}}}
    {\advance\c@namecountdown\m@ne
     \usebibmacro{bbx:measure:outer}{#1}{#2}}
    {\usebibmacro*{#1}{#2}}}

\renewbibmacro{author}{%
  \ifnumless{\value{maxnames}}{\value{author}}
    {\c@namecountdown\c@maxnames}
    {\c@namecountdown\c@author}%
  \usebibmacro{bbx:measure:outer}{bbx:measure:author:inner}{}}
\newbibmacro*{bbx:measure:author:inner}{%
  \ifboolexpr{
    test \ifuseauthor
    and
    not test {\ifnameundef{author}}
  }
    {\usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\usebibmacro{bbx:savehash}%
        \printnames[][1-\the\value{namecountdown}]{author}%
        \iffieldundef{authortype}
          {\setunit{\printdelim{nameyeardelim}}}
          {\setunit{\printdelim{authortypedelim}}}}%
     \iffieldundef{authortype}
       {}
       {\usebibmacro{authorstrg}%
        \setunit{\printdelim{nameyeardelim}}}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\printdelim{nonameyeardelim}}}%
  \usebibmacro{date+extradate}}


\renewbibmacro*{bbx:editor}[1]{%
  \ifnumless{\value{maxnames}}{\value{editor}}
    {\c@namecountdown\c@maxnames}
    {\c@namecountdown\c@editor}%
  \usebibmacro{bbx:measure:outer}{bbx:measure:editor:inner}{#1}}
\newbibmacro*{bbx:measure:editor:inner}[1]{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
    {\usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\printnames[][1-\the\value{namecountdown}]{editor}%
        \setunit{\printdelim{editortypedelim}}%
        \usebibmacro{bbx:savehash}}%
     \usebibmacro{#1}%
     \clearname{editor}%
     \setunit{\printdelim{nameyeardelim}}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\printdelim{nonameyeardelim}}}%
  \usebibmacro{date+extradate}}

\renewbibmacro*{bbx:translator}[1]{%
  \ifnumless{\value{maxnames}}{\value{translator}}
    {\c@namecountdown\c@maxnames}
    {\c@namecountdown\c@translator}%
  \usebibmacro{bbx:measure:outer}{bbx:measure:translator:inner}{#1}}
\newbibmacro*{bbx:measure:translator:inner}[1]{%
  \ifboolexpr{
    test \ifusetranslator
    and
    not test {\ifnameundef{translator}}
  }
    {\usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\printnames[][1-\the\value{namecountdown}]{translator}%
        \setunit{\printdelim{translatortypedelim}}%
        \usebibmacro{bbx:savehash}}%
     \usebibmacro{#1}%
     \clearname{translator}%
     \setunit{\printdelim{nameyeardelim}}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\printdelim{nonameyeardelim}}}%
  \usebibmacro{date+extradate}}
\makeatother

\begin{document}
  \cite{companion,aksin,herrmann,sigfridsson,jaffe}
  \printbibliography
\end{document}

在此处输入图片描述

相关内容