Biblatex - 显示第一作者、第二作者......最后一位作者

Biblatex - 显示第一作者、第二作者......最后一位作者

我的参考书目需要遵循一种风格。该风格是“ieee”,但带有作者的自定义格式。

正常 ieee:A. Uthor、W. Riter、R. Esearcher、SC Ientist、ST Udent、PR Ofessor 和 LEC Turer,“一篇有很多作者参与的非常有趣的文章”,Journal of Articles,第 5 卷,第 8 期,第 8-12 页,2012 年。doi:12345/6789.10。

我想要的:A. Uthor、W. Riter 等,以及 LEC Turer,“一篇有很多作者参与的非常有趣的文章”,Journal of Articles,第 5 卷,第 8 期,第 8-12 页,2012 年。doi:12345/6789.10。

即,我希望 3 至 (n-1) 位作者不显示而是用 \ldots 代替。

有什么想法如何实现这一点吗?

最小不起作用的示例(参考文献 1 应该缩写,参考文献 2 应该保持不变):

\documentclass[american]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=ieee,backend=biber,maxnames=999]{biblatex}
\usepackage{hyperref}
\addbibresource{\jobname.bib}

\begin{filecontents}{\jobname.bib}
@article{testartlong,
  author        = {Arnold Uthor and William Riter and Rita Esearcher and Steven C. Ientist and Stuart T. Udent and Peter R. Ofessor and Lewis E. C. Turer},
  title         = {A Very Interesting Article With a Lot of Authors},
  journal       = {Journal of Articles},
  volume        = {5},
  number        = {8},
  pages         = {8-12},
  date          = {2012},
  doi           = {12345/6789.10},
}
@article{testart,
  author        = {Arnold Uthor and William Riter},
  title         = {A Very Interesting Article},
  journal       = {Journal of Articles},
  volume        = {7},
  number        = {3},
  pages         = {1-5},
  date          = {2010},
  issn          = {1234-5678},
}
\end{filecontents}

\begin{document}
  Test
  \begin{refsection}
    \nocite{*}
    \printbibliography[heading=none]
  \end{refsection}
\end{document}

答案1

\documentclass[american]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=ieee,backend=biber,maxnames=999]{biblatex}
\usepackage{hyperref}
\addbibresource{\jobname.bib}
\begin{filecontents}{\jobname.bib}
@article{testartlong,
  author        = {Arnold Uthor and William Riter and Rita Esearcher and Steven C. Ientist and Stuart T. Udent and Peter R. Ofessor and Lewis E. C. Turer},
  title         = {A Very Interesting Article With a Lot of Authors},
  journal       = {Journal of Articles},
  volume        = {5},
  number        = {8},
  pages         = {8-12},
  date          = {2012},
  doi           = {12345/6789.10},
}
@article{testart,
  author        = {Arnold Uthor and William Riter},
  title         = {A Very Interesting Article},
  journal       = {Journal of Articles},
  volume        = {7},
  number        = {3},
  pages         = {1-5},
  date          = {2010},
  issn          = {1234-5678},
}
\end{filecontents}

\DeclareNameFormat{FirstLast}{%
  \ifthenelse{\value{listtotal}=1}
    {\namepartgiveni\adddot\addspace\ifblank{\namepartprefix}{}{\namepartprefix\addnbspace}\namepartfamily}
    {\ifthenelse{\value{listtotal}=2}
      {\ifthenelse{\value{listcount}<\value{listtotal}}
        {\namepartgiveni\adddot\addspace\ifblank{\namepartprefix}{}{\namepartprefix\addnbspace}\namepartfamily\addspace}
        {\bibstring{and}\addspace\namepartgiveni\adddot\addspace\ifblank{\namepartprefix}{}{\namepartprefix\addnbspace}\namepartfamily}}
      {\ifthenelse{\value{listcount}=1}
        {\namepartgiveni\adddot\addspace\ifblank{\namepartprefix}{}{\namepartprefix\addnbspace}\namepartfamily\addcomma\addspace\dots\isdot\addcomma \addspace and}
        {\ifthenelse{\value{listcount}<\value{listtotal}}
          {}
          {\addspace\namepartgiveni\adddot\addspace\ifblank{\namepartprefix}{}{\namepartprefix\addnbspace}\namepartfamily}}%
      }%
    }%
}

\DeclareNameAlias{author}{FirstLast}

\begin{document}
  Test
  \begin{refsection}
    \nocite{*}
    \printbibliography[heading=none]
  \end{refsection}
\end{document}

在此处输入图片描述

或多或少改编自此Biblatex 仅引用第一作者和最后作者

编辑

以下方法似乎也有效:

\DeclareNameFormat{FirstLast}{%
  \ifthenelse{\value{listtotal} < 3}
    {\usebibmacro{name:given-family}
      {\namepartfamily}
      {\namepartgiveni}
      {\namepartprefix}
      {\namepartsuffix}}
    {{\renewcommand\finalnamedelim{\addcomma\addspace\dots\isdot\addcomma \addspace\bibstring{and}\addspace}%
        \ifthenelse{\value{listcount}=1 \OR \value{listcount}=\value{listtotal}}
        {\usebibmacro{name:given-family}
         {\namepartfamily}
         {\namepartgiveni}
         {\namepartprefix}
         {\namepartsuffix}}
        {}}%     
    }%
  }% 

相关内容