0

I have a style in my bibliography that I need to follow. The style is "ieee" but with a custom format of the authors.

Normal ieee: A. Uthor, W. Riter, R. Esearcher, S. C. Ientist, S. T. Udent, P. R. Ofessor, and L. E. C. Turer, “A very interesting article with a lot of authors,” Journal of Articles, vol. 5, no. 8, pp. 8–12, 2012. doi: 12345/6789.10.

What I want: A. Uthor, W. Riter, ..., and L. E. C. Turer, “A very interesting article with a lot of authors,” Journal of Articles, vol. 5, no. 8, pp. 8–12, 2012. doi: 12345/6789.10.

I.e., I want authors number 3 through (n-1) to not be shown but \ldots instead.

Any ideas how to achieve this?

Minimal not working example (Ref 1 should be abbreviated and Ref 2 should stay the same):

\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}
3
\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}

enter image description here

More or less adapted from this Biblatex citations first and last author only

Edit

The following seems to work too:

\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}}
        {}}%     
    }%
  }% 
  • I'd have preferred if this solution called \usebibmacro{name:given-family} or \usebibmacro{name:family-given} instead of trying to format the names directly. That way the names obey \ifuseprefix, \ifprefchar, \mkbibname... etc. – moewe Jan 26 '18 at 11:14
  • @moewe I was to lazy ;-). Perhaps I will edit later. Are you already a TUG member? If not consider to add your name here: tex.meta.stackexchange.com/questions/7543/… – Ulrike Fischer Jan 26 '18 at 12:23
  • I see. Maybe I should complain to Guido as well. In fact I became a Dante+TUG member this January. – moewe Jan 26 '18 at 12:26
  • @moewe I can't use \usebibmacro{name:given-family}. I get errors like ! You can't use \begingroup' after \advance. \ifprefchar ->\ifhmode \begingroup ` . – Ulrike Fischer Jan 26 '18 at 12:46
  • I'll have a look later. It should work I'd have thought. – moewe Jan 26 '18 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.